diff --git a/clients/algoliasearch-client-go/algolia/abtesting/client.go b/clients/algoliasearch-client-go/algolia/abtesting/client.go index 4ebc0865d71..fa92ef4519b 100644 --- a/clients/algoliasearch-client-go/algolia/abtesting/client.go +++ b/clients/algoliasearch-client-go/algolia/abtesting/client.go @@ -218,14 +218,14 @@ func reportError(format string, a ...any) error { } // A wrapper for strict JSON decoding. -func newStrictDecoder(data []byte) *json.Decoder { +func newStrictDecoder(data []byte) *json.Decoder { dec := json.NewDecoder(bytes.NewBuffer(data)) dec.DisallowUnknownFields() return dec } // A wrapper for validating a struct, returns nil if value is not a struct. -func validateStruct(v any) error { +func validateStruct(v any) error { err := validator.New().Struct(v) validationErrors, ok := err.(validator.ValidationErrors) if ok && len(validationErrors) > 0 { diff --git a/clients/algoliasearch-client-go/algolia/analytics/client.go b/clients/algoliasearch-client-go/algolia/analytics/client.go index 6c5a7421b69..0b288b041be 100644 --- a/clients/algoliasearch-client-go/algolia/analytics/client.go +++ b/clients/algoliasearch-client-go/algolia/analytics/client.go @@ -218,14 +218,14 @@ func reportError(format string, a ...any) error { } // A wrapper for strict JSON decoding. -func newStrictDecoder(data []byte) *json.Decoder { +func newStrictDecoder(data []byte) *json.Decoder { dec := json.NewDecoder(bytes.NewBuffer(data)) dec.DisallowUnknownFields() return dec } // A wrapper for validating a struct, returns nil if value is not a struct. -func validateStruct(v any) error { +func validateStruct(v any) error { err := validator.New().Struct(v) validationErrors, ok := err.(validator.ValidationErrors) if ok && len(validationErrors) > 0 { diff --git a/clients/algoliasearch-client-go/algolia/ingestion/api_ingestion.go b/clients/algoliasearch-client-go/algolia/ingestion/api_ingestion.go index 0c655349153..43ecd18422b 100644 --- a/clients/algoliasearch-client-go/algolia/ingestion/api_ingestion.go +++ b/clients/algoliasearch-client-go/algolia/ingestion/api_ingestion.go @@ -3844,8 +3844,8 @@ ListAuthentications calls the API and returns the raw response from it. @param itemsPerPage int32 - Number of items per page. @param page int32 - Page number of the paginated API response. @param type_ []AuthenticationType - Type of authentication resource to retrieve. - @param platform []PlatformWithNone - Ecommerce platform for which to retrieve authentication resources. - @param sort AuthenticationSortKeys - Property by which to sort the list of authentication resources. + @param platform []PlatformWithNone - Ecommerce platform for which to retrieve authentication. + @param sort AuthenticationSortKeys - Property by which to sort the list of authentication. @param order OrderKeys - Sort order of the response, ascending or descending. @param opts ...RequestOption - Optional parameters for the API call @return *http.Response - The raw response from the API @@ -3910,8 +3910,8 @@ Request can be constructed by NewApiListAuthenticationsRequest with parameters b @param itemsPerPage int32 - Number of items per page. @param page int32 - Page number of the paginated API response. @param type_ []AuthenticationType - Type of authentication resource to retrieve. - @param platform []PlatformWithNone - Ecommerce platform for which to retrieve authentication resources. - @param sort AuthenticationSortKeys - Property by which to sort the list of authentication resources. + @param platform []PlatformWithNone - Ecommerce platform for which to retrieve authentication. + @param sort AuthenticationSortKeys - Property by which to sort the list of authentication. @param order OrderKeys - Sort order of the response, ascending or descending. @return ListAuthenticationsResponse */ @@ -3992,6 +3992,15 @@ func (r *ApiListDestinationsRequest) UnmarshalJSON(b []byte) error { } } } + if v, ok := req["transformationID"]; ok { + err = json.Unmarshal(v, &r.transformationID) + if err != nil { + err = json.Unmarshal(b, &r.transformationID) + if err != nil { + return fmt.Errorf("cannot unmarshal transformationID: %w", err) + } + } + } if v, ok := req["sort"]; ok { err = json.Unmarshal(v, &r.sort) if err != nil { @@ -4020,6 +4029,7 @@ type ApiListDestinationsRequest struct { page *int32 type_ []DestinationType authenticationID []string + transformationID *string sort DestinationSortKeys order OrderKeys } @@ -4053,6 +4063,12 @@ func (r ApiListDestinationsRequest) WithAuthenticationID(authenticationID []stri return r } +// WithTransformationID adds the transformationID to the ApiListDestinationsRequest and returns the request for chaining. +func (r ApiListDestinationsRequest) WithTransformationID(transformationID string) ApiListDestinationsRequest { + r.transformationID = &transformationID + return r +} + // WithSort adds the sort to the ApiListDestinationsRequest and returns the request for chaining. func (r ApiListDestinationsRequest) WithSort(sort DestinationSortKeys) ApiListDestinationsRequest { r.sort = sort @@ -4080,6 +4096,7 @@ ListDestinations calls the API and returns the raw response from it. @param page int32 - Page number of the paginated API response. @param type_ []DestinationType - Destination type. @param authenticationID []string - Authentication ID used by destinations. + @param transformationID string - Get the list of destinations used by a transformation. @param sort DestinationSortKeys - Property by which to sort the destinations. @param order OrderKeys - Sort order of the response, ascending or descending. @param opts ...RequestOption - Optional parameters for the API call @@ -4108,6 +4125,9 @@ func (c *APIClient) ListDestinationsWithHTTPInfo(r ApiListDestinationsRequest, o if !utils.IsNilOrEmpty(r.authenticationID) { conf.queryParams.Set("authenticationID", utils.QueryParameterToString(r.authenticationID)) } + if !utils.IsNilOrEmpty(r.transformationID) { + conf.queryParams.Set("transformationID", utils.QueryParameterToString(*r.transformationID)) + } if !utils.IsNilOrEmpty(r.sort) { conf.queryParams.Set("sort", utils.QueryParameterToString(r.sort)) } @@ -4146,6 +4166,7 @@ Request can be constructed by NewApiListDestinationsRequest with parameters belo @param page int32 - Page number of the paginated API response. @param type_ []DestinationType - Destination type. @param authenticationID []string - Authentication ID used by destinations. + @param transformationID string - Get the list of destinations used by a transformation. @param sort DestinationSortKeys - Property by which to sort the destinations. @param order OrderKeys - Sort order of the response, ascending or descending. @return ListDestinationsResponse @@ -4908,7 +4929,7 @@ ListSources calls the API and returns the raw response from it. @param itemsPerPage int32 - Number of items per page. @param page int32 - Page number of the paginated API response. @param type_ []SourceType - Source type. Some sources require authentication. - @param authenticationID []string - Authentication IDs of the sources to retrieve. 'none' returns sources that doesn't have an authentication resource. + @param authenticationID []string - Authentication IDs of the sources to retrieve. 'none' returns sources that doesn't have an authentication. @param sort SourceSortKeys - Property by which to sort the list of sources. @param order OrderKeys - Sort order of the response, ascending or descending. @param opts ...RequestOption - Optional parameters for the API call @@ -4974,7 +4995,7 @@ Request can be constructed by NewApiListSourcesRequest with parameters below. @param itemsPerPage int32 - Number of items per page. @param page int32 - Page number of the paginated API response. @param type_ []SourceType - Source type. Some sources require authentication. - @param authenticationID []string - Authentication IDs of the sources to retrieve. 'none' returns sources that doesn't have an authentication resource. + @param authenticationID []string - Authentication IDs of the sources to retrieve. 'none' returns sources that doesn't have an authentication. @param sort SourceSortKeys - Property by which to sort the list of sources. @param order OrderKeys - Sort order of the response, ascending or descending. @return ListSourcesResponse @@ -5660,7 +5681,7 @@ func (r *ApiListTransformationsRequest) UnmarshalJSON(b []byte) error { type ApiListTransformationsRequest struct { itemsPerPage *int32 page *int32 - sort SortKeys + sort TransformationSortKeys order OrderKeys } @@ -5682,7 +5703,7 @@ func (r ApiListTransformationsRequest) WithPage(page int32) ApiListTransformatio } // WithSort adds the sort to the ApiListTransformationsRequest and returns the request for chaining. -func (r ApiListTransformationsRequest) WithSort(sort SortKeys) ApiListTransformationsRequest { +func (r ApiListTransformationsRequest) WithSort(sort TransformationSortKeys) ApiListTransformationsRequest { r.sort = sort return r } @@ -5706,7 +5727,7 @@ ListTransformations calls the API and returns the raw response from it. Request can be constructed by NewApiListTransformationsRequest with parameters below. @param itemsPerPage int32 - Number of items per page. @param page int32 - Page number of the paginated API response. - @param sort SortKeys - Property by which to sort the list. + @param sort TransformationSortKeys - Property by which to sort the list of transformations. @param order OrderKeys - Sort order of the response, ascending or descending. @param opts ...RequestOption - Optional parameters for the API call @return *http.Response - The raw response from the API @@ -5764,7 +5785,7 @@ Request can be constructed by NewApiListTransformationsRequest with parameters b @param itemsPerPage int32 - Number of items per page. @param page int32 - Page number of the paginated API response. - @param sort SortKeys - Property by which to sort the list. + @param sort TransformationSortKeys - Property by which to sort the list of transformations. @param order OrderKeys - Sort order of the response, ascending or descending. @return ListTransformationsResponse */ diff --git a/clients/algoliasearch-client-go/algolia/ingestion/model_authentication_sort_keys.go b/clients/algoliasearch-client-go/algolia/ingestion/model_authentication_sort_keys.go index 6a2d70c1881..d629672bfd3 100644 --- a/clients/algoliasearch-client-go/algolia/ingestion/model_authentication_sort_keys.go +++ b/clients/algoliasearch-client-go/algolia/ingestion/model_authentication_sort_keys.go @@ -6,13 +6,13 @@ import ( "fmt" ) -// AuthenticationSortKeys Property by which to sort the list of authentication resources. +// AuthenticationSortKeys Property by which to sort the list of authentication. type AuthenticationSortKeys string // List of authenticationSortKeys. const ( AUTHENTICATION_SORT_KEYS_NAME AuthenticationSortKeys = "name" - AUTHENTICATION_SORT_KEYS_AUTH_TYPE AuthenticationSortKeys = "auth_type" + AUTHENTICATION_SORT_KEYS_TYPE AuthenticationSortKeys = "type" AUTHENTICATION_SORT_KEYS_PLATFORM AuthenticationSortKeys = "platform" AUTHENTICATION_SORT_KEYS_UPDATED_AT AuthenticationSortKeys = "updatedAt" AUTHENTICATION_SORT_KEYS_CREATED_AT AuthenticationSortKeys = "createdAt" @@ -21,7 +21,7 @@ const ( // All allowed values of AuthenticationSortKeys enum. var AllowedAuthenticationSortKeysEnumValues = []AuthenticationSortKeys{ "name", - "auth_type", + "type", "platform", "updatedAt", "createdAt", diff --git a/clients/algoliasearch-client-go/algolia/ingestion/model_sort_keys.go b/clients/algoliasearch-client-go/algolia/ingestion/model_sort_keys.go deleted file mode 100644 index 87a7d7a02ec..00000000000 --- a/clients/algoliasearch-client-go/algolia/ingestion/model_sort_keys.go +++ /dev/null @@ -1,69 +0,0 @@ -// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -package ingestion - -import ( - "encoding/json" - "fmt" -) - -// SortKeys Property by which to sort the list. -type SortKeys string - -// List of sortKeys. -const ( - SORT_KEYS_NAME SortKeys = "name" - SORT_KEYS_TYPE SortKeys = "type" - SORT_KEYS_UPDATED_AT SortKeys = "updatedAt" - SORT_KEYS_CREATED_AT SortKeys = "createdAt" -) - -// All allowed values of SortKeys enum. -var AllowedSortKeysEnumValues = []SortKeys{ - "name", - "type", - "updatedAt", - "createdAt", -} - -func (v *SortKeys) UnmarshalJSON(src []byte) error { - var value string - err := json.Unmarshal(src, &value) - if err != nil { - return fmt.Errorf("failed to unmarshal value '%s' for enum 'SortKeys': %w", string(src), err) - } - enumTypeValue := SortKeys(value) - for _, existing := range AllowedSortKeysEnumValues { - if existing == enumTypeValue { - *v = enumTypeValue - return nil - } - } - - return fmt.Errorf("%+v is not a valid SortKeys", value) -} - -// NewSortKeysFromValue returns a pointer to a valid SortKeys -// for the value passed as argument, or an error if the value passed is not allowed by the enum. -func NewSortKeysFromValue(v string) (*SortKeys, error) { - ev := SortKeys(v) - if ev.IsValid() { - return &ev, nil - } else { - return nil, fmt.Errorf("invalid value '%v' for SortKeys: valid values are %v", v, AllowedSortKeysEnumValues) - } -} - -// IsValid return true if the value is valid for the enum, false otherwise. -func (v SortKeys) IsValid() bool { - for _, existing := range AllowedSortKeysEnumValues { - if existing == v { - return true - } - } - return false -} - -// Ptr returns reference to sortKeys value. -func (v SortKeys) Ptr() *SortKeys { - return &v -} diff --git a/clients/algoliasearch-client-go/algolia/ingestion/model_transformation_sort_keys.go b/clients/algoliasearch-client-go/algolia/ingestion/model_transformation_sort_keys.go new file mode 100644 index 00000000000..ece9684b691 --- /dev/null +++ b/clients/algoliasearch-client-go/algolia/ingestion/model_transformation_sort_keys.go @@ -0,0 +1,67 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. +package ingestion + +import ( + "encoding/json" + "fmt" +) + +// TransformationSortKeys Property by which to sort the list of transformations. +type TransformationSortKeys string + +// List of transformationSortKeys. +const ( + TRANSFORMATION_SORT_KEYS_NAME TransformationSortKeys = "name" + TRANSFORMATION_SORT_KEYS_UPDATED_AT TransformationSortKeys = "updatedAt" + TRANSFORMATION_SORT_KEYS_CREATED_AT TransformationSortKeys = "createdAt" +) + +// All allowed values of TransformationSortKeys enum. +var AllowedTransformationSortKeysEnumValues = []TransformationSortKeys{ + "name", + "updatedAt", + "createdAt", +} + +func (v *TransformationSortKeys) UnmarshalJSON(src []byte) error { + var value string + err := json.Unmarshal(src, &value) + if err != nil { + return fmt.Errorf("failed to unmarshal value '%s' for enum 'TransformationSortKeys': %w", string(src), err) + } + enumTypeValue := TransformationSortKeys(value) + for _, existing := range AllowedTransformationSortKeysEnumValues { + if existing == enumTypeValue { + *v = enumTypeValue + return nil + } + } + + return fmt.Errorf("%+v is not a valid TransformationSortKeys", value) +} + +// NewTransformationSortKeysFromValue returns a pointer to a valid TransformationSortKeys +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewTransformationSortKeysFromValue(v string) (*TransformationSortKeys, error) { + ev := TransformationSortKeys(v) + if ev.IsValid() { + return &ev, nil + } else { + return nil, fmt.Errorf("invalid value '%v' for TransformationSortKeys: valid values are %v", v, AllowedTransformationSortKeysEnumValues) + } +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v TransformationSortKeys) IsValid() bool { + for _, existing := range AllowedTransformationSortKeysEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to transformationSortKeys value. +func (v TransformationSortKeys) Ptr() *TransformationSortKeys { + return &v +} diff --git a/clients/algoliasearch-client-go/algolia/insights/client.go b/clients/algoliasearch-client-go/algolia/insights/client.go index a0e13fba797..c3f60fda698 100644 --- a/clients/algoliasearch-client-go/algolia/insights/client.go +++ b/clients/algoliasearch-client-go/algolia/insights/client.go @@ -218,14 +218,14 @@ func reportError(format string, a ...any) error { } // A wrapper for strict JSON decoding. -func newStrictDecoder(data []byte) *json.Decoder { +func newStrictDecoder(data []byte) *json.Decoder { dec := json.NewDecoder(bytes.NewBuffer(data)) dec.DisallowUnknownFields() return dec } // A wrapper for validating a struct, returns nil if value is not a struct. -func validateStruct(v any) error { +func validateStruct(v any) error { err := validator.New().Struct(v) validationErrors, ok := err.(validator.ValidationErrors) if ok && len(validationErrors) > 0 { diff --git a/clients/algoliasearch-client-go/algolia/monitoring/client.go b/clients/algoliasearch-client-go/algolia/monitoring/client.go index e6d58e36a56..41dbd57af28 100644 --- a/clients/algoliasearch-client-go/algolia/monitoring/client.go +++ b/clients/algoliasearch-client-go/algolia/monitoring/client.go @@ -211,14 +211,14 @@ func reportError(format string, a ...any) error { } // A wrapper for strict JSON decoding. -func newStrictDecoder(data []byte) *json.Decoder { +func newStrictDecoder(data []byte) *json.Decoder { dec := json.NewDecoder(bytes.NewBuffer(data)) dec.DisallowUnknownFields() return dec } // A wrapper for validating a struct, returns nil if value is not a struct. -func validateStruct(v any) error { +func validateStruct(v any) error { err := validator.New().Struct(v) validationErrors, ok := err.(validator.ValidationErrors) if ok && len(validationErrors) > 0 { diff --git a/clients/algoliasearch-client-go/algolia/personalization/client.go b/clients/algoliasearch-client-go/algolia/personalization/client.go index 128f0d7e246..a06dfb549ed 100644 --- a/clients/algoliasearch-client-go/algolia/personalization/client.go +++ b/clients/algoliasearch-client-go/algolia/personalization/client.go @@ -214,14 +214,14 @@ func reportError(format string, a ...any) error { } // A wrapper for strict JSON decoding. -func newStrictDecoder(data []byte) *json.Decoder { +func newStrictDecoder(data []byte) *json.Decoder { dec := json.NewDecoder(bytes.NewBuffer(data)) dec.DisallowUnknownFields() return dec } // A wrapper for validating a struct, returns nil if value is not a struct. -func validateStruct(v any) error { +func validateStruct(v any) error { err := validator.New().Struct(v) validationErrors, ok := err.(validator.ValidationErrors) if ok && len(validationErrors) > 0 { diff --git a/clients/algoliasearch-client-go/algolia/query-suggestions/client.go b/clients/algoliasearch-client-go/algolia/query-suggestions/client.go index 4ae31447efd..f2b83c524cf 100644 --- a/clients/algoliasearch-client-go/algolia/query-suggestions/client.go +++ b/clients/algoliasearch-client-go/algolia/query-suggestions/client.go @@ -214,14 +214,14 @@ func reportError(format string, a ...any) error { } // A wrapper for strict JSON decoding. -func newStrictDecoder(data []byte) *json.Decoder { +func newStrictDecoder(data []byte) *json.Decoder { dec := json.NewDecoder(bytes.NewBuffer(data)) dec.DisallowUnknownFields() return dec } // A wrapper for validating a struct, returns nil if value is not a struct. -func validateStruct(v any) error { +func validateStruct(v any) error { err := validator.New().Struct(v) validationErrors, ok := err.(validator.ValidationErrors) if ok && len(validationErrors) > 0 { diff --git a/clients/algoliasearch-client-go/algolia/recommend/client.go b/clients/algoliasearch-client-go/algolia/recommend/client.go index fc4e075885a..6c875911365 100644 --- a/clients/algoliasearch-client-go/algolia/recommend/client.go +++ b/clients/algoliasearch-client-go/algolia/recommend/client.go @@ -220,14 +220,14 @@ func reportError(format string, a ...any) error { } // A wrapper for strict JSON decoding. -func newStrictDecoder(data []byte) *json.Decoder { +func newStrictDecoder(data []byte) *json.Decoder { dec := json.NewDecoder(bytes.NewBuffer(data)) dec.DisallowUnknownFields() return dec } // A wrapper for validating a struct, returns nil if value is not a struct. -func validateStruct(v any) error { +func validateStruct(v any) error { err := validator.New().Struct(v) validationErrors, ok := err.(validator.ValidationErrors) if ok && len(validationErrors) > 0 { diff --git a/clients/algoliasearch-client-go/algolia/search/api_search.go b/clients/algoliasearch-client-go/algolia/search/api_search.go index 8b5682ff5b7..c93a58ffcc5 100644 --- a/clients/algoliasearch-client-go/algolia/search/api_search.go +++ b/clients/algoliasearch-client-go/algolia/search/api_search.go @@ -9390,7 +9390,7 @@ func (c *APIClient) WaitForTask( return time.Duration(min(200*count, 5000)) * time.Millisecond }), WithMaxRetries(50)}, opts...) - return CreateIterable( + return CreateIterable( func(*GetTaskResponse, error) (*GetTaskResponse, error) { return c.GetTask(c.NewApiGetTaskRequest(indexName, taskID), toRequestOptions(opts)...) }, @@ -9424,7 +9424,7 @@ func (c *APIClient) WaitForAppTask( return time.Duration(min(200*count, 5000)) * time.Millisecond }), WithMaxRetries(50)}, opts...) - return CreateIterable( + return CreateIterable( func(*GetTaskResponse, error) (*GetTaskResponse, error) { return c.GetAppTask(c.NewApiGetAppTaskRequest(taskID), toRequestOptions(opts)...) }, @@ -9557,7 +9557,7 @@ func (c *APIClient) WaitForApiKey( return time.Duration(min(200*count, 5000)) * time.Millisecond }), WithMaxRetries(50)}, opts...) - return CreateIterable( + return CreateIterable( func(*GetApiKeyResponse, error) (*GetApiKeyResponse, error) { return c.GetApiKey(c.NewApiGetApiKeyRequest(key), toRequestOptions(opts)...) }, @@ -9581,7 +9581,7 @@ func (c *APIClient) BrowseObjects( browseParams BrowseParamsObject, opts ...IterableOption, ) error { - _, err := CreateIterable( + _, err := CreateIterable( func(previousResponse *BrowseResponse, previousErr error) (*BrowseResponse, error) { if previousResponse != nil { browseParams.Cursor = previousResponse.Cursor @@ -9621,7 +9621,7 @@ func (c *APIClient) BrowseRules( hitsPerPage = *searchRulesParams.HitsPerPage } - _, err := CreateIterable( + _, err := CreateIterable( func(previousResponse *SearchRulesResponse, previousErr error) (*SearchRulesResponse, error) { searchRulesParams.HitsPerPage = &hitsPerPage @@ -9671,7 +9671,7 @@ func (c *APIClient) BrowseSynonyms( searchSynonymsParams.Page = utils.ToPtr(int32(0)) } - _, err := CreateIterable( + _, err := CreateIterable( func(previousResponse *SearchSynonymsResponse, previousErr error) (*SearchSynonymsResponse, error) { searchSynonymsParams.HitsPerPage = &hitsPerPage diff --git a/clients/algoliasearch-client-go/algolia/search/client.go b/clients/algoliasearch-client-go/algolia/search/client.go index d7f71153d93..9c9cec6d137 100644 --- a/clients/algoliasearch-client-go/algolia/search/client.go +++ b/clients/algoliasearch-client-go/algolia/search/client.go @@ -220,14 +220,14 @@ func reportError(format string, a ...any) error { } // A wrapper for strict JSON decoding. -func newStrictDecoder(data []byte) *json.Decoder { +func newStrictDecoder(data []byte) *json.Decoder { dec := json.NewDecoder(bytes.NewBuffer(data)) dec.DisallowUnknownFields() return dec } // A wrapper for validating a struct, returns nil if value is not a struct. -func validateStruct(v any) error { +func validateStruct(v any) error { err := validator.New().Struct(v) validationErrors, ok := err.(validator.ValidationErrors) if ok && len(validationErrors) > 0 { diff --git a/clients/algoliasearch-client-javascript/package.json b/clients/algoliasearch-client-javascript/package.json index bb6ae85a832..75df5388193 100644 --- a/clients/algoliasearch-client-javascript/package.json +++ b/clients/algoliasearch-client-javascript/package.json @@ -7,7 +7,7 @@ ], "scripts": { "build:all": "lerna run build --skip-nx-cache --include-dependencies", - "build:many": "lerna run build --skip-nx-cache --include-dependencies --scope ${0:-'{@algolia/*,algoliasearch}'}", + "build:many": "lerna run build --skip-nx-cache --include-dependencies --scope ${0:-'{@algolia/*,algoliasearch,requester-testing}'}", "clean": "lerna run clean --include-dependencies", "release:bump": "lerna version ${0:-patch} --no-changelog --no-git-tag-version --no-push --exact --force-publish --yes", "release:publish": "tsc --project scripts/tsconfig.json && node scripts/dist/scripts/publish.js", diff --git a/clients/algoliasearch-client-javascript/packages/algoliasearch/index.d.ts b/clients/algoliasearch-client-javascript/packages/algoliasearch/index.d.ts index 23eac31bdc3..e81a1cd3e76 100644 --- a/clients/algoliasearch-client-javascript/packages/algoliasearch/index.d.ts +++ b/clients/algoliasearch-client-javascript/packages/algoliasearch/index.d.ts @@ -1,2 +1 @@ -// eslint-disable-next-line import/no-unresolved export * from './dist/node'; diff --git a/clients/algoliasearch-client-javascript/packages/ingestion/model/authenticationSortKeys.ts b/clients/algoliasearch-client-javascript/packages/ingestion/model/authenticationSortKeys.ts index 38580803236..c85d530d682 100644 --- a/clients/algoliasearch-client-javascript/packages/ingestion/model/authenticationSortKeys.ts +++ b/clients/algoliasearch-client-javascript/packages/ingestion/model/authenticationSortKeys.ts @@ -1,6 +1,6 @@ // Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. /** - * Property by which to sort the list of authentication resources. + * Property by which to sort the list of authentications. */ -export type AuthenticationSortKeys = 'auth_type' | 'createdAt' | 'name' | 'platform' | 'updatedAt'; +export type AuthenticationSortKeys = 'createdAt' | 'name' | 'platform' | 'type' | 'updatedAt'; diff --git a/clients/algoliasearch-client-javascript/packages/ingestion/model/clientMethodProps.ts b/clients/algoliasearch-client-javascript/packages/ingestion/model/clientMethodProps.ts index 870c66c7157..612c1dd7036 100644 --- a/clients/algoliasearch-client-javascript/packages/ingestion/model/clientMethodProps.ts +++ b/clients/algoliasearch-client-javascript/packages/ingestion/model/clientMethodProps.ts @@ -17,7 +17,6 @@ import type { RunSortKeys } from './runSortKeys'; import type { RunSourcePayload } from './runSourcePayload'; import type { RunStatus } from './runStatus'; import type { RunType } from './runType'; -import type { SortKeys } from './sortKeys'; import type { SourceSortKeys } from './sourceSortKeys'; import type { SourceType } from './sourceType'; import type { SourceUpdate } from './sourceUpdate'; @@ -25,6 +24,7 @@ import type { TaskSortKeys } from './taskSortKeys'; import type { TaskUpdate } from './taskUpdate'; import type { TaskUpdateV1 } from './taskUpdateV1'; import type { TransformationCreate } from './transformationCreate'; +import type { TransformationSortKeys } from './transformationSortKeys'; import type { TransformationTry } from './transformationTry'; import type { TriggerType } from './triggerType'; @@ -293,11 +293,11 @@ export type ListAuthenticationsProps = { */ type?: AuthenticationType[]; /** - * Ecommerce platform for which to retrieve authentication resources. + * Ecommerce platform for which to retrieve authentications. */ platform?: PlatformWithNone[]; /** - * Property by which to sort the list of authentication resources. + * Property by which to sort the list of authentications. */ sort?: AuthenticationSortKeys; /** @@ -326,6 +326,10 @@ export type ListDestinationsProps = { * Authentication ID used by destinations. */ authenticationID?: string[]; + /** + * Get the list of destinations used by a transformation. + */ + transformationID?: string; /** * Property by which to sort the destinations. */ @@ -437,7 +441,7 @@ export type ListSourcesProps = { */ type?: SourceType[]; /** - * Authentication IDs of the sources to retrieve. \'none\' returns sources that doesn\'t have an authentication resource. + * Authentication IDs of the sources to retrieve. \'none\' returns sources that doesn\'t have an authentication. */ authenticationID?: string[]; /** @@ -547,9 +551,9 @@ export type ListTransformationsProps = { */ page?: number; /** - * Property by which to sort the list. + * Property by which to sort the list of transformations. */ - sort?: SortKeys; + sort?: TransformationSortKeys; /** * Sort order of the response, ascending or descending. */ diff --git a/clients/algoliasearch-client-javascript/packages/ingestion/model/index.ts b/clients/algoliasearch-client-javascript/packages/ingestion/model/index.ts index fb5ace55bed..ca766816ce7 100644 --- a/clients/algoliasearch-client-javascript/packages/ingestion/model/index.ts +++ b/clients/algoliasearch-client-javascript/packages/ingestion/model/index.ts @@ -91,7 +91,6 @@ export * from './scheduleTriggerType'; export * from './shopifyInput'; export * from './shopifyMarket'; export * from './shopifyMetafield'; -export * from './sortKeys'; export * from './source'; export * from './sourceBigCommerce'; export * from './sourceBigQuery'; @@ -137,6 +136,7 @@ export * from './transformationCreate'; export * from './transformationCreateResponse'; export * from './transformationError'; export * from './transformationSearch'; +export * from './transformationSortKeys'; export * from './transformationTry'; export * from './transformationTryResponse'; export * from './transformationUpdateResponse'; diff --git a/clients/algoliasearch-client-javascript/packages/ingestion/model/sortKeys.ts b/clients/algoliasearch-client-javascript/packages/ingestion/model/transformationSortKeys.ts similarity index 59% rename from clients/algoliasearch-client-javascript/packages/ingestion/model/sortKeys.ts rename to clients/algoliasearch-client-javascript/packages/ingestion/model/transformationSortKeys.ts index 82fd657a0dc..8b2dd367496 100644 --- a/clients/algoliasearch-client-javascript/packages/ingestion/model/sortKeys.ts +++ b/clients/algoliasearch-client-javascript/packages/ingestion/model/transformationSortKeys.ts @@ -1,6 +1,6 @@ // Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. /** - * Property by which to sort the list. + * Property by which to sort the list of transformations. */ -export type SortKeys = 'createdAt' | 'name' | 'type' | 'updatedAt'; +export type TransformationSortKeys = 'createdAt' | 'name' | 'updatedAt'; diff --git a/clients/algoliasearch-client-javascript/packages/ingestion/src/ingestionClient.ts b/clients/algoliasearch-client-javascript/packages/ingestion/src/ingestionClient.ts index 8ee72ca0d2a..1de1a80d4eb 100644 --- a/clients/algoliasearch-client-javascript/packages/ingestion/src/ingestionClient.ts +++ b/clients/algoliasearch-client-javascript/packages/ingestion/src/ingestionClient.ts @@ -1173,8 +1173,8 @@ export function createIngestionClient({ * @param listAuthentications.itemsPerPage - Number of items per page. * @param listAuthentications.page - Page number of the paginated API response. * @param listAuthentications.type - Type of authentication resource to retrieve. - * @param listAuthentications.platform - Ecommerce platform for which to retrieve authentication resources. - * @param listAuthentications.sort - Property by which to sort the list of authentication resources. + * @param listAuthentications.platform - Ecommerce platform for which to retrieve authentications. + * @param listAuthentications.sort - Property by which to sort the list of authentications. * @param listAuthentications.order - Sort order of the response, ascending or descending. * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions. */ @@ -1185,7 +1185,6 @@ export function createIngestionClient({ const requestPath = '/1/authentications'; const headers: Headers = {}; const queryParameters: QueryParameters = {}; - if (itemsPerPage !== undefined) { queryParameters.itemsPerPage = itemsPerPage.toString(); } @@ -1199,6 +1198,7 @@ export function createIngestionClient({ if (platform !== undefined) { queryParameters.platform = platform.toString(); } + if (sort !== undefined) { queryParameters.sort = sort.toString(); } @@ -1229,12 +1229,13 @@ export function createIngestionClient({ * @param listDestinations.page - Page number of the paginated API response. * @param listDestinations.type - Destination type. * @param listDestinations.authenticationID - Authentication ID used by destinations. + * @param listDestinations.transformationID - Get the list of destinations used by a transformation. * @param listDestinations.sort - Property by which to sort the destinations. * @param listDestinations.order - Sort order of the response, ascending or descending. * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions. */ listDestinations( - { itemsPerPage, page, type, authenticationID, sort, order }: ListDestinationsProps = {}, + { itemsPerPage, page, type, authenticationID, transformationID, sort, order }: ListDestinationsProps = {}, requestOptions: RequestOptions | undefined = undefined, ): Promise { const requestPath = '/1/destinations'; @@ -1249,9 +1250,13 @@ export function createIngestionClient({ if (type !== undefined) { queryParameters.type = type.toString(); } + if (authenticationID !== undefined) { queryParameters.authenticationID = authenticationID.toString(); } + if (transformationID !== undefined) { + queryParameters.transformationID = transformationID.toString(); + } if (sort !== undefined) { queryParameters.sort = sort.toString(); } @@ -1303,7 +1308,6 @@ export function createIngestionClient({ if (itemsPerPage !== undefined) { queryParameters.itemsPerPage = itemsPerPage.toString(); } - if (page !== undefined) { queryParameters.page = page.toString(); } @@ -1313,6 +1317,7 @@ export function createIngestionClient({ if (type !== undefined) { queryParameters.type = type.toString(); } + if (sort !== undefined) { queryParameters.sort = sort.toString(); } @@ -1369,7 +1374,6 @@ export function createIngestionClient({ if (page !== undefined) { queryParameters.page = page.toString(); } - if (status !== undefined) { queryParameters.status = status.toString(); } @@ -1382,7 +1386,6 @@ export function createIngestionClient({ if (sort !== undefined) { queryParameters.sort = sort.toString(); } - if (order !== undefined) { queryParameters.order = order.toString(); } @@ -1415,7 +1418,7 @@ export function createIngestionClient({ * @param listSources.itemsPerPage - Number of items per page. * @param listSources.page - Page number of the paginated API response. * @param listSources.type - Source type. Some sources require authentication. - * @param listSources.authenticationID - Authentication IDs of the sources to retrieve. \'none\' returns sources that doesn\'t have an authentication resource. + * @param listSources.authenticationID - Authentication IDs of the sources to retrieve. \'none\' returns sources that doesn\'t have an authentication. * @param listSources.sort - Property by which to sort the list of sources. * @param listSources.order - Sort order of the response, ascending or descending. * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions. @@ -1433,7 +1436,6 @@ export function createIngestionClient({ if (page !== undefined) { queryParameters.page = page.toString(); } - if (type !== undefined) { queryParameters.type = type.toString(); } @@ -1443,6 +1445,7 @@ export function createIngestionClient({ if (sort !== undefined) { queryParameters.sort = sort.toString(); } + if (order !== undefined) { queryParameters.order = order.toString(); } @@ -1493,22 +1496,24 @@ export function createIngestionClient({ if (action !== undefined) { queryParameters.action = action.toString(); } - if (enabled !== undefined) { queryParameters.enabled = enabled.toString(); } if (sourceID !== undefined) { queryParameters.sourceID = sourceID.toString(); } + if (destinationID !== undefined) { queryParameters.destinationID = destinationID.toString(); } + if (triggerType !== undefined) { queryParameters.triggerType = triggerType.toString(); } if (sort !== undefined) { queryParameters.sort = sort.toString(); } + if (order !== undefined) { queryParameters.order = order.toString(); } @@ -1550,17 +1555,16 @@ export function createIngestionClient({ const requestPath = '/1/tasks'; const headers: Headers = {}; const queryParameters: QueryParameters = {}; - if (itemsPerPage !== undefined) { queryParameters.itemsPerPage = itemsPerPage.toString(); } if (page !== undefined) { queryParameters.page = page.toString(); } - if (action !== undefined) { queryParameters.action = action.toString(); } + if (enabled !== undefined) { queryParameters.enabled = enabled.toString(); } @@ -1576,7 +1580,6 @@ export function createIngestionClient({ if (sort !== undefined) { queryParameters.sort = sort.toString(); } - if (order !== undefined) { queryParameters.order = order.toString(); } @@ -1602,7 +1605,7 @@ export function createIngestionClient({ * @param listTransformations - The listTransformations object. * @param listTransformations.itemsPerPage - Number of items per page. * @param listTransformations.page - Page number of the paginated API response. - * @param listTransformations.sort - Property by which to sort the list. + * @param listTransformations.sort - Property by which to sort the list of transformations. * @param listTransformations.order - Sort order of the response, ascending or descending. * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions. */ @@ -1613,7 +1616,6 @@ export function createIngestionClient({ const requestPath = '/1/transformations'; const headers: Headers = {}; const queryParameters: QueryParameters = {}; - if (itemsPerPage !== undefined) { queryParameters.itemsPerPage = itemsPerPage.toString(); } diff --git a/specs/bundled/ingestion.yml b/specs/bundled/ingestion.yml index dd81e8990e6..d8364330296 100644 --- a/specs/bundled/ingestion.yml +++ b/specs/bundled/ingestion.yml @@ -426,6 +426,7 @@ paths: - $ref: '#/components/parameters/page' - $ref: '#/components/parameters/destinationParameters_type' - $ref: '#/components/parameters/authenticationID' + - $ref: '#/components/parameters/transformationID' - $ref: '#/components/parameters/destinationParameters_sort' - $ref: '#/components/parameters/order' responses: @@ -1398,7 +1399,7 @@ paths: parameters: - $ref: '#/components/parameters/itemsPerPage' - $ref: '#/components/parameters/page' - - $ref: '#/components/parameters/parameters_sort' + - $ref: '#/components/parameters/transformationParameters_sort' - $ref: '#/components/parameters/order' responses: '200': @@ -1817,7 +1818,7 @@ components: platform: name: platform in: query - description: Ecommerce platform for which to retrieve authentication resources. + description: Ecommerce platform for which to retrieve authentications. required: false style: form explode: false @@ -1829,7 +1830,7 @@ components: sort: name: sort in: query - description: Property by which to sort the list of authentication resources. + description: Property by which to sort the list of authentications. required: false schema: $ref: '#/components/schemas/authenticationSortKeys' @@ -1870,6 +1871,15 @@ components: type: array items: $ref: '#/components/schemas/authenticationID' + transformationID: + name: transformationID + in: query + description: Get the list of destinations used by a transformation. + required: false + style: form + explode: false + schema: + $ref: '#/components/schemas/transformationID' destinationParameters_sort: name: sort in: query @@ -1902,7 +1912,7 @@ components: in: query description: | Authentication IDs of the sources to retrieve. - 'none' returns sources that doesn't have an authentication resource. + 'none' returns sources that doesn't have an authentication. required: false style: form explode: false @@ -1995,13 +2005,13 @@ components: description: Unique identifier of a task. schema: $ref: '#/components/schemas/taskID' - parameters_sort: + transformationParameters_sort: name: sort in: query - description: Property by which to sort the list. + description: Property by which to sort the list of transformations. required: false schema: - $ref: '#/components/schemas/sortKeys' + $ref: '#/components/schemas/transformationSortKeys' pathTransformationID: name: transformationID in: path @@ -2132,11 +2142,11 @@ components: - $ref: '#/components/schemas/platformNone' authenticationSortKeys: type: string - description: Property by which to sort the list of authentication resources. + description: Property by which to sort the list of authentications. default: createdAt enum: - name - - auth_type + - type - platform - updatedAt - createdAt @@ -2517,6 +2527,10 @@ components: enum: - search - insights + transformationID: + type: string + description: Universally unique identifier (UUID) of a transformation. + example: 6c02aeb1-775e-418e-870b-1faccd4b2c0f destinationSortKeys: type: string description: Property by which to sort the destinations. @@ -2574,10 +2588,6 @@ components: DestinationInput: oneOf: - $ref: '#/components/schemas/DestinationIndexName' - transformationID: - type: string - description: Universally unique identifier (UUID) of a transformation. - example: 6c02aeb1-775e-418e-870b-1faccd4b2c0f transformationIDs: type: array items: @@ -3864,13 +3874,12 @@ components: type: string description: Unique record identifier. example: test-record-123 - sortKeys: + transformationSortKeys: type: string - description: Property by which to sort the list. - default: desc + description: Property by which to sort the list of transformations. + default: createdAt enum: - name - - type - updatedAt - createdAt AuthenticationIDs: diff --git a/tests/output/javascript/src/benchmark/search.test.ts b/tests/output/javascript/src/benchmark/search.test.ts deleted file mode 100644 index f40508d702a..00000000000 --- a/tests/output/javascript/src/benchmark/search.test.ts +++ /dev/null @@ -1,20 +0,0 @@ -// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -/* eslint-disable @typescript-eslint/no-unused-vars */ -import { searchClient } from '@algolia/client-search'; -import { describe, test } from 'vitest'; - -describe('benchmark', () => { - test('benchmark the search method', async () => { - const client = searchClient('test-app-id', 'test-api-key', { - hosts: [{ url: 'localhost', port: 6682, accept: 'readWrite', protocol: 'http' }], - }); - - for (let i = 0; i < 2000; i++) { - const result = await client.search({ - requests: [ - { indexName: 'cts_e2e_benchmark_search_javascript', query: 'iphone 15 pro max 512gb', hitsPerPage: 50 }, - ], - }); - } - }, 15000); -}); diff --git a/tests/output/javascript/src/client/abtesting.test.ts b/tests/output/javascript/src/client/abtesting.test.ts deleted file mode 100644 index e7bfb53038a..00000000000 --- a/tests/output/javascript/src/client/abtesting.test.ts +++ /dev/null @@ -1,132 +0,0 @@ -// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -/* eslint-disable @typescript-eslint/no-unused-vars, require-await, no-lone-blocks */ -// @ts-nocheck Failing tests will have type errors, but we cannot suppress them even with @ts-expect-error because it doesn't work for a block of lines. - -import type { AbtestingClient } from '@algolia/client-abtesting'; -import { abtestingClient } from '@algolia/client-abtesting'; -import { nodeEchoRequester } from '@algolia/requester-testing'; -import type { EchoResponse } from '@algolia/requester-testing'; -import { describe, test, expect } from 'vitest'; - -const appId = 'test-app-id'; -const apiKey = 'test-api-key'; - -function createClient(): AbtestingClient { - return abtestingClient(appId, apiKey, 'us', { requester: nodeEchoRequester() }); -} - -describe('commonApi', () => { - test('calls api with correct user agent', async () => { - const client = createClient(); - - const result = (await client.customPost({ path: '1/test' })) as unknown as EchoResponse; - - expect(decodeURIComponent(result.algoliaAgent)).toMatch( - /^Algolia for JavaScript \(\d+\.\d+\.\d+(-?.*)?\)(; [a-zA-Z. ]+ (\(\d+((\.\d+)?\.\d+)?(-?.*)?\))?)*(; Abtesting (\(\d+\.\d+\.\d+(-?.*)?\)))(; [a-zA-Z. ]+ (\(\d+((\.\d+)?\.\d+)?(-?.*)?\))?)*$/, - ); - }, 15000); - - test('the user agent contains the latest version', async () => { - const client = createClient(); - - const result = (await client.customPost({ path: '1/test' })) as unknown as EchoResponse; - - expect(decodeURIComponent(result.algoliaAgent)).toMatch(/^Algolia for JavaScript \(5.6.0\).*/); - }, 15000); - - test('calls api with default read timeouts', async () => { - const client = createClient(); - - const result = (await client.customGet({ path: '1/test' })) as unknown as EchoResponse; - - expect(result).toEqual(expect.objectContaining({ connectTimeout: 2000, responseTimeout: 5000 })); - }, 15000); - - test('calls api with default write timeouts', async () => { - const client = createClient(); - - const result = (await client.customPost({ path: '1/test' })) as unknown as EchoResponse; - - expect(result).toEqual(expect.objectContaining({ connectTimeout: 2000, responseTimeout: 30000 })); - }, 15000); -}); - -describe('parameters', () => { - test('fallbacks to the alias when region is not given', async () => { - const client = abtestingClient('my-app-id', 'my-api-key', '', { requester: nodeEchoRequester() }); - - const result = (await client.getABTest({ id: 123 })) as unknown as EchoResponse; - - expect(result.host).toEqual('analytics.algolia.com'); - }, 15000); - - test('uses the correct region', async () => { - const client = abtestingClient('my-app-id', 'my-api-key', 'us', { requester: nodeEchoRequester() }); - - const result = (await client.getABTest({ id: 123 })) as unknown as EchoResponse; - - expect(result.host).toEqual('analytics.us.algolia.com'); - }, 15000); - - test('throws when incorrect region is given', async () => { - try { - const client = abtestingClient('my-app-id', 'my-api-key', 'not_a_region', { requester: nodeEchoRequester() }); - throw new Error('test is expected to throw error'); - } catch (e) { - expect((e as Error).message).toMatch('`region` must be one of the following: de, us'); - } - }, 15000); -}); - -describe('setClientApiKey', () => { - test('switch API key', async () => { - const client = abtestingClient('test-app-id', 'test-api-key', 'us', { - hosts: [{ url: 'localhost', port: 6683, accept: 'readWrite', protocol: 'http' }], - }); - - { - const result = await client.customGet({ path: 'check-api-key/1' }); - - expect(result).toEqual({ headerAPIKeyValue: 'test-api-key' }); - } - { - client.setClientApiKey({ apiKey: 'updated-api-key' }); - } - { - const result = await client.customGet({ path: 'check-api-key/2' }); - - expect(result).toEqual({ headerAPIKeyValue: 'updated-api-key' }); - } - }, 15000); -}); - -describe('init', () => { - test('sets authMode', async () => { - const qpClient = abtestingClient('foo', 'bar', 'us', { - authMode: 'WithinQueryParameters', - requester: nodeEchoRequester(), - }); - const headerClient = abtestingClient('foo', 'bar', 'us', { - authMode: 'WithinHeaders', - requester: nodeEchoRequester(), - }); - - const qpResult = (await qpClient.customGet({ - path: '1/foo', - })) as unknown as EchoResponse; - expect(qpResult.searchParams).toEqual({ - 'x-algolia-api-key': 'bar', - 'x-algolia-application-id': 'foo', - }); - - const headerResult = (await headerClient.customGet({ - path: '1/bar', - })) as unknown as EchoResponse; - expect(headerResult.headers).toEqual({ - accept: 'application/json', - 'content-type': 'text/plain', - 'x-algolia-api-key': 'bar', - 'x-algolia-application-id': 'foo', - }); - }); -}); diff --git a/tests/output/javascript/src/client/analytics.test.ts b/tests/output/javascript/src/client/analytics.test.ts deleted file mode 100644 index dc1519a790c..00000000000 --- a/tests/output/javascript/src/client/analytics.test.ts +++ /dev/null @@ -1,143 +0,0 @@ -// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -/* eslint-disable @typescript-eslint/no-unused-vars, require-await, no-lone-blocks */ -// @ts-nocheck Failing tests will have type errors, but we cannot suppress them even with @ts-expect-error because it doesn't work for a block of lines. - -import type { AnalyticsClient } from '@algolia/client-analytics'; -import { analyticsClient } from '@algolia/client-analytics'; -import { nodeEchoRequester } from '@algolia/requester-testing'; -import type { EchoResponse } from '@algolia/requester-testing'; -import { describe, test, expect } from 'vitest'; - -const appId = 'test-app-id'; -const apiKey = 'test-api-key'; - -function createClient(): AnalyticsClient { - return analyticsClient(appId, apiKey, 'us', { requester: nodeEchoRequester() }); -} - -describe('commonApi', () => { - test('calls api with correct user agent', async () => { - const client = createClient(); - - const result = (await client.customPost({ path: '1/test' })) as unknown as EchoResponse; - - expect(decodeURIComponent(result.algoliaAgent)).toMatch( - /^Algolia for JavaScript \(\d+\.\d+\.\d+(-?.*)?\)(; [a-zA-Z. ]+ (\(\d+((\.\d+)?\.\d+)?(-?.*)?\))?)*(; Analytics (\(\d+\.\d+\.\d+(-?.*)?\)))(; [a-zA-Z. ]+ (\(\d+((\.\d+)?\.\d+)?(-?.*)?\))?)*$/, - ); - }, 15000); - - test('the user agent contains the latest version', async () => { - const client = createClient(); - - const result = (await client.customPost({ path: '1/test' })) as unknown as EchoResponse; - - expect(decodeURIComponent(result.algoliaAgent)).toMatch(/^Algolia for JavaScript \(5.6.0\).*/); - }, 15000); - - test('calls api with default read timeouts', async () => { - const client = createClient(); - - const result = (await client.customGet({ path: '1/test' })) as unknown as EchoResponse; - - expect(result).toEqual(expect.objectContaining({ connectTimeout: 2000, responseTimeout: 5000 })); - }, 15000); - - test('calls api with default write timeouts', async () => { - const client = createClient(); - - const result = (await client.customPost({ path: '1/test' })) as unknown as EchoResponse; - - expect(result).toEqual(expect.objectContaining({ connectTimeout: 2000, responseTimeout: 30000 })); - }, 15000); -}); - -describe('parameters', () => { - test('fallbacks to the alias when region is not given', async () => { - const client = analyticsClient('my-app-id', 'my-api-key', '', { requester: nodeEchoRequester() }); - - const result = (await client.getAverageClickPosition({ index: 'my-index' })) as unknown as EchoResponse; - - expect(result.host).toEqual('analytics.algolia.com'); - }, 15000); - - test('uses the correct region', async () => { - const client = analyticsClient('my-app-id', 'my-api-key', 'de', { requester: nodeEchoRequester() }); - - const result = (await client.customPost({ path: 'test' })) as unknown as EchoResponse; - - expect(result.host).toEqual('analytics.de.algolia.com'); - }, 15000); - - test('throws when incorrect region is given', async () => { - try { - const client = analyticsClient('my-app-id', 'my-api-key', 'not_a_region', { requester: nodeEchoRequester() }); - throw new Error('test is expected to throw error'); - } catch (e) { - expect((e as Error).message).toMatch('`region` must be one of the following: de, us'); - } - }, 15000); - - test('getAverageClickPosition throws without index', async () => { - const client = createClient(); - - try { - const result = (await client.getClickPositions({})) as unknown as EchoResponse; - throw new Error('test is expected to throw error'); - } catch (e) { - expect((e as Error).message).toMatch('Parameter `index` is required when calling `getClickPositions`.'); - } - }, 15000); -}); - -describe('setClientApiKey', () => { - test('switch API key', async () => { - const client = analyticsClient('test-app-id', 'test-api-key', 'us', { - hosts: [{ url: 'localhost', port: 6683, accept: 'readWrite', protocol: 'http' }], - }); - - { - const result = await client.customGet({ path: 'check-api-key/1' }); - - expect(result).toEqual({ headerAPIKeyValue: 'test-api-key' }); - } - { - client.setClientApiKey({ apiKey: 'updated-api-key' }); - } - { - const result = await client.customGet({ path: 'check-api-key/2' }); - - expect(result).toEqual({ headerAPIKeyValue: 'updated-api-key' }); - } - }, 15000); -}); - -describe('init', () => { - test('sets authMode', async () => { - const qpClient = analyticsClient('foo', 'bar', 'us', { - authMode: 'WithinQueryParameters', - requester: nodeEchoRequester(), - }); - const headerClient = analyticsClient('foo', 'bar', 'us', { - authMode: 'WithinHeaders', - requester: nodeEchoRequester(), - }); - - const qpResult = (await qpClient.customGet({ - path: '1/foo', - })) as unknown as EchoResponse; - expect(qpResult.searchParams).toEqual({ - 'x-algolia-api-key': 'bar', - 'x-algolia-application-id': 'foo', - }); - - const headerResult = (await headerClient.customGet({ - path: '1/bar', - })) as unknown as EchoResponse; - expect(headerResult.headers).toEqual({ - accept: 'application/json', - 'content-type': 'text/plain', - 'x-algolia-api-key': 'bar', - 'x-algolia-application-id': 'foo', - }); - }); -}); diff --git a/tests/output/javascript/src/client/insights.test.ts b/tests/output/javascript/src/client/insights.test.ts deleted file mode 100644 index 5dc8c57fba5..00000000000 --- a/tests/output/javascript/src/client/insights.test.ts +++ /dev/null @@ -1,146 +0,0 @@ -// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -/* eslint-disable @typescript-eslint/no-unused-vars, require-await, no-lone-blocks */ -// @ts-nocheck Failing tests will have type errors, but we cannot suppress them even with @ts-expect-error because it doesn't work for a block of lines. - -import type { InsightsClient } from '@algolia/client-insights'; -import { insightsClient } from '@algolia/client-insights'; -import { nodeEchoRequester } from '@algolia/requester-testing'; -import type { EchoResponse } from '@algolia/requester-testing'; -import { describe, test, expect } from 'vitest'; - -const appId = 'test-app-id'; -const apiKey = 'test-api-key'; - -function createClient(): InsightsClient { - return insightsClient(appId, apiKey, 'us', { requester: nodeEchoRequester() }); -} - -describe('commonApi', () => { - test('calls api with correct user agent', async () => { - const client = createClient(); - - const result = (await client.customPost({ path: '1/test' })) as unknown as EchoResponse; - - expect(decodeURIComponent(result.algoliaAgent)).toMatch( - /^Algolia for JavaScript \(\d+\.\d+\.\d+(-?.*)?\)(; [a-zA-Z. ]+ (\(\d+((\.\d+)?\.\d+)?(-?.*)?\))?)*(; Insights (\(\d+\.\d+\.\d+(-?.*)?\)))(; [a-zA-Z. ]+ (\(\d+((\.\d+)?\.\d+)?(-?.*)?\))?)*$/, - ); - }, 15000); - - test('the user agent contains the latest version', async () => { - const client = createClient(); - - const result = (await client.customPost({ path: '1/test' })) as unknown as EchoResponse; - - expect(decodeURIComponent(result.algoliaAgent)).toMatch(/^Algolia for JavaScript \(5.6.0\).*/); - }, 15000); - - test('calls api with default read timeouts', async () => { - const client = createClient(); - - const result = (await client.customGet({ path: '1/test' })) as unknown as EchoResponse; - - expect(result).toEqual(expect.objectContaining({ connectTimeout: 2000, responseTimeout: 5000 })); - }, 15000); - - test('calls api with default write timeouts', async () => { - const client = createClient(); - - const result = (await client.customPost({ path: '1/test' })) as unknown as EchoResponse; - - expect(result).toEqual(expect.objectContaining({ connectTimeout: 2000, responseTimeout: 30000 })); - }, 15000); -}); - -describe('parameters', () => { - test('fallbacks to the alias when region is not given', async () => { - const client = insightsClient('my-app-id', 'my-api-key', '', { requester: nodeEchoRequester() }); - - const result = (await client.pushEvents({ - events: [ - { - eventType: 'click', - eventName: 'Product Clicked', - index: 'products', - userToken: 'user-123456', - authenticatedUserToken: 'user-123456', - timestamp: 1641290601962, - objectIDs: ['9780545139700', '9780439784542'], - queryID: '43b15df305339e827f0ac0bdc5ebcaa7', - positions: [7, 6], - }, - ], - })) as unknown as EchoResponse; - - expect(result.host).toEqual('insights.algolia.io'); - }, 15000); - - test('uses the correct region', async () => { - const client = insightsClient('my-app-id', 'my-api-key', 'us', { requester: nodeEchoRequester() }); - - const result = (await client.customDelete({ path: 'test' })) as unknown as EchoResponse; - - expect(result.host).toEqual('insights.us.algolia.io'); - }, 15000); - - test('throws when incorrect region is given', async () => { - try { - const client = insightsClient('my-app-id', 'my-api-key', 'not_a_region', { requester: nodeEchoRequester() }); - throw new Error('test is expected to throw error'); - } catch (e) { - expect((e as Error).message).toMatch('`region` must be one of the following: de, us'); - } - }, 15000); -}); - -describe('setClientApiKey', () => { - test('switch API key', async () => { - const client = insightsClient('test-app-id', 'test-api-key', 'us', { - hosts: [{ url: 'localhost', port: 6683, accept: 'readWrite', protocol: 'http' }], - }); - - { - const result = await client.customGet({ path: 'check-api-key/1' }); - - expect(result).toEqual({ headerAPIKeyValue: 'test-api-key' }); - } - { - client.setClientApiKey({ apiKey: 'updated-api-key' }); - } - { - const result = await client.customGet({ path: 'check-api-key/2' }); - - expect(result).toEqual({ headerAPIKeyValue: 'updated-api-key' }); - } - }, 15000); -}); - -describe('init', () => { - test('sets authMode', async () => { - const qpClient = insightsClient('foo', 'bar', 'us', { - authMode: 'WithinQueryParameters', - requester: nodeEchoRequester(), - }); - const headerClient = insightsClient('foo', 'bar', 'us', { - authMode: 'WithinHeaders', - requester: nodeEchoRequester(), - }); - - const qpResult = (await qpClient.customGet({ - path: '1/foo', - })) as unknown as EchoResponse; - expect(qpResult.searchParams).toEqual({ - 'x-algolia-api-key': 'bar', - 'x-algolia-application-id': 'foo', - }); - - const headerResult = (await headerClient.customGet({ - path: '1/bar', - })) as unknown as EchoResponse; - expect(headerResult.headers).toEqual({ - accept: 'application/json', - 'content-type': 'text/plain', - 'x-algolia-api-key': 'bar', - 'x-algolia-application-id': 'foo', - }); - }); -}); diff --git a/tests/output/javascript/src/client/monitoring.test.ts b/tests/output/javascript/src/client/monitoring.test.ts deleted file mode 100644 index 6abeea23f61..00000000000 --- a/tests/output/javascript/src/client/monitoring.test.ts +++ /dev/null @@ -1,115 +0,0 @@ -// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -/* eslint-disable no-lone-blocks */ -// @ts-nocheck Failing tests will have type errors, but we cannot suppress them even with @ts-expect-error because it doesn't work for a block of lines. - -import type { MonitoringClient } from '@algolia/monitoring'; -import { monitoringClient } from '@algolia/monitoring'; -import { nodeEchoRequester } from '@algolia/requester-testing'; -import type { EchoResponse } from '@algolia/requester-testing'; -import { describe, test, expect } from 'vitest'; - -const appId = 'test-app-id'; -const apiKey = 'test-api-key'; - -function createClient(): MonitoringClient { - return monitoringClient(appId, apiKey, { requester: nodeEchoRequester() }); -} - -describe('commonApi', () => { - test('calls api with correct user agent', async () => { - const client = createClient(); - - const result = (await client.customPost({ path: '1/test' })) as unknown as EchoResponse; - - expect(decodeURIComponent(result.algoliaAgent)).toMatch( - /^Algolia for JavaScript \(\d+\.\d+\.\d+(-?.*)?\)(; [a-zA-Z. ]+ (\(\d+((\.\d+)?\.\d+)?(-?.*)?\))?)*(; Monitoring (\(\d+\.\d+\.\d+(-?.*)?\)))(; [a-zA-Z. ]+ (\(\d+((\.\d+)?\.\d+)?(-?.*)?\))?)*$/, - ); - }, 15000); - - test('the user agent contains the latest version', async () => { - const client = createClient(); - - const result = (await client.customPost({ path: '1/test' })) as unknown as EchoResponse; - - expect(decodeURIComponent(result.algoliaAgent)).toMatch(/^Algolia for JavaScript \(1.6.0\).*/); - }, 15000); - - test('calls api with default read timeouts', async () => { - const client = createClient(); - - const result = (await client.customGet({ path: '1/test' })) as unknown as EchoResponse; - - expect(result).toEqual(expect.objectContaining({ connectTimeout: 2000, responseTimeout: 5000 })); - }, 15000); - - test('calls api with default write timeouts', async () => { - const client = createClient(); - - const result = (await client.customPost({ path: '1/test' })) as unknown as EchoResponse; - - expect(result).toEqual(expect.objectContaining({ connectTimeout: 2000, responseTimeout: 30000 })); - }, 15000); -}); - -describe('parameters', () => { - test('use the correct host', async () => { - const client = monitoringClient('my-app-id', 'my-api-key', { requester: nodeEchoRequester() }); - - const result = (await client.customDelete({ path: 'test' })) as unknown as EchoResponse; - - expect(result.host).toEqual('status.algolia.com'); - }, 15000); -}); - -describe('setClientApiKey', () => { - test('switch API key', async () => { - const client = monitoringClient('test-app-id', 'test-api-key', { - hosts: [{ url: 'localhost', port: 6683, accept: 'readWrite', protocol: 'http' }], - }); - - { - const result = await client.customGet({ path: 'check-api-key/1' }); - - expect(result).toEqual({ headerAPIKeyValue: 'test-api-key' }); - } - { - client.setClientApiKey({ apiKey: 'updated-api-key' }); - } - { - const result = await client.customGet({ path: 'check-api-key/2' }); - - expect(result).toEqual({ headerAPIKeyValue: 'updated-api-key' }); - } - }, 15000); -}); - -describe('init', () => { - test('sets authMode', async () => { - const qpClient = monitoringClient('foo', 'bar', { - authMode: 'WithinQueryParameters', - requester: nodeEchoRequester(), - }); - const headerClient = monitoringClient('foo', 'bar', { - authMode: 'WithinHeaders', - requester: nodeEchoRequester(), - }); - - const qpResult = (await qpClient.customGet({ - path: '1/foo', - })) as unknown as EchoResponse; - expect(qpResult.searchParams).toEqual({ - 'x-algolia-api-key': 'bar', - 'x-algolia-application-id': 'foo', - }); - - const headerResult = (await headerClient.customGet({ - path: '1/bar', - })) as unknown as EchoResponse; - expect(headerResult.headers).toEqual({ - accept: 'application/json', - 'content-type': 'text/plain', - 'x-algolia-api-key': 'bar', - 'x-algolia-application-id': 'foo', - }); - }); -}); diff --git a/tests/output/javascript/src/client/personalization.test.ts b/tests/output/javascript/src/client/personalization.test.ts deleted file mode 100644 index dd1d536c70c..00000000000 --- a/tests/output/javascript/src/client/personalization.test.ts +++ /dev/null @@ -1,131 +0,0 @@ -// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -/* eslint-disable @typescript-eslint/no-unused-vars, require-await, no-lone-blocks */ -// @ts-nocheck Failing tests will have type errors, but we cannot suppress them even with @ts-expect-error because it doesn't work for a block of lines. - -import type { PersonalizationClient } from '@algolia/client-personalization'; -import { personalizationClient } from '@algolia/client-personalization'; -import { nodeEchoRequester } from '@algolia/requester-testing'; -import type { EchoResponse } from '@algolia/requester-testing'; -import { describe, test, expect } from 'vitest'; - -const appId = 'test-app-id'; -const apiKey = 'test-api-key'; - -function createClient(): PersonalizationClient { - return personalizationClient(appId, apiKey, 'us', { requester: nodeEchoRequester() }); -} - -describe('commonApi', () => { - test('calls api with correct user agent', async () => { - const client = createClient(); - - const result = (await client.customPost({ path: '1/test' })) as unknown as EchoResponse; - - expect(decodeURIComponent(result.algoliaAgent)).toMatch( - /^Algolia for JavaScript \(\d+\.\d+\.\d+(-?.*)?\)(; [a-zA-Z. ]+ (\(\d+((\.\d+)?\.\d+)?(-?.*)?\))?)*(; Personalization (\(\d+\.\d+\.\d+(-?.*)?\)))(; [a-zA-Z. ]+ (\(\d+((\.\d+)?\.\d+)?(-?.*)?\))?)*$/, - ); - }, 15000); - - test('the user agent contains the latest version', async () => { - const client = createClient(); - - const result = (await client.customPost({ path: '1/test' })) as unknown as EchoResponse; - - expect(decodeURIComponent(result.algoliaAgent)).toMatch(/^Algolia for JavaScript \(5.6.0\).*/); - }, 15000); - - test('calls api with default read timeouts', async () => { - const client = createClient(); - - const result = (await client.customGet({ path: '1/test' })) as unknown as EchoResponse; - - expect(result).toEqual(expect.objectContaining({ connectTimeout: 2000, responseTimeout: 5000 })); - }, 15000); - - test('calls api with default write timeouts', async () => { - const client = createClient(); - - const result = (await client.customPost({ path: '1/test' })) as unknown as EchoResponse; - - expect(result).toEqual(expect.objectContaining({ connectTimeout: 2000, responseTimeout: 30000 })); - }, 15000); -}); - -describe('parameters', () => { - test('throws when region is not given', async () => { - try { - const client = personalizationClient('my-app-id', 'my-api-key', '', { requester: nodeEchoRequester() }); - throw new Error('test is expected to throw error'); - } catch (e) { - expect((e as Error).message).toMatch('`region` is required and must be one of the following: eu, us'); - } - }, 15000); - - test('throws when incorrect region is given', async () => { - try { - const client = personalizationClient('my-app-id', 'my-api-key', 'not_a_region', { - requester: nodeEchoRequester(), - }); - throw new Error('test is expected to throw error'); - } catch (e) { - expect((e as Error).message).toMatch('`region` is required and must be one of the following: eu, us'); - } - }, 15000); - - test('does not throw when region is given', async () => { - const client = personalizationClient('my-app-id', 'my-api-key', 'us', { requester: nodeEchoRequester() }); - }, 15000); -}); - -describe('setClientApiKey', () => { - test('switch API key', async () => { - const client = personalizationClient('test-app-id', 'test-api-key', 'us', { - hosts: [{ url: 'localhost', port: 6683, accept: 'readWrite', protocol: 'http' }], - }); - - { - const result = await client.customGet({ path: 'check-api-key/1' }); - - expect(result).toEqual({ headerAPIKeyValue: 'test-api-key' }); - } - { - client.setClientApiKey({ apiKey: 'updated-api-key' }); - } - { - const result = await client.customGet({ path: 'check-api-key/2' }); - - expect(result).toEqual({ headerAPIKeyValue: 'updated-api-key' }); - } - }, 15000); -}); - -describe('init', () => { - test('sets authMode', async () => { - const qpClient = personalizationClient('foo', 'bar', 'us', { - authMode: 'WithinQueryParameters', - requester: nodeEchoRequester(), - }); - const headerClient = personalizationClient('foo', 'bar', 'us', { - authMode: 'WithinHeaders', - requester: nodeEchoRequester(), - }); - - const qpResult = (await qpClient.customGet({ - path: '1/foo', - })) as unknown as EchoResponse; - expect(qpResult.searchParams).toEqual({ - 'x-algolia-api-key': 'bar', - 'x-algolia-application-id': 'foo', - }); - - const headerResult = (await headerClient.customGet({ - path: '1/bar', - })) as unknown as EchoResponse; - expect(headerResult.headers).toEqual({ - accept: 'application/json', - 'content-type': 'text/plain', - 'x-algolia-api-key': 'bar', - 'x-algolia-application-id': 'foo', - }); - }); -}); diff --git a/tests/output/javascript/src/client/querySuggestions.test.ts b/tests/output/javascript/src/client/querySuggestions.test.ts deleted file mode 100644 index a69216e2740..00000000000 --- a/tests/output/javascript/src/client/querySuggestions.test.ts +++ /dev/null @@ -1,131 +0,0 @@ -// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -/* eslint-disable @typescript-eslint/no-unused-vars, require-await, no-lone-blocks */ -// @ts-nocheck Failing tests will have type errors, but we cannot suppress them even with @ts-expect-error because it doesn't work for a block of lines. - -import type { QuerySuggestionsClient } from '@algolia/client-query-suggestions'; -import { querySuggestionsClient } from '@algolia/client-query-suggestions'; -import { nodeEchoRequester } from '@algolia/requester-testing'; -import type { EchoResponse } from '@algolia/requester-testing'; -import { describe, test, expect } from 'vitest'; - -const appId = 'test-app-id'; -const apiKey = 'test-api-key'; - -function createClient(): QuerySuggestionsClient { - return querySuggestionsClient(appId, apiKey, 'us', { requester: nodeEchoRequester() }); -} - -describe('commonApi', () => { - test('calls api with correct user agent', async () => { - const client = createClient(); - - const result = (await client.customPost({ path: '1/test' })) as unknown as EchoResponse; - - expect(decodeURIComponent(result.algoliaAgent)).toMatch( - /^Algolia for JavaScript \(\d+\.\d+\.\d+(-?.*)?\)(; [a-zA-Z. ]+ (\(\d+((\.\d+)?\.\d+)?(-?.*)?\))?)*(; QuerySuggestions (\(\d+\.\d+\.\d+(-?.*)?\)))(; [a-zA-Z. ]+ (\(\d+((\.\d+)?\.\d+)?(-?.*)?\))?)*$/, - ); - }, 15000); - - test('the user agent contains the latest version', async () => { - const client = createClient(); - - const result = (await client.customPost({ path: '1/test' })) as unknown as EchoResponse; - - expect(decodeURIComponent(result.algoliaAgent)).toMatch(/^Algolia for JavaScript \(5.6.0\).*/); - }, 15000); - - test('calls api with default read timeouts', async () => { - const client = createClient(); - - const result = (await client.customGet({ path: '1/test' })) as unknown as EchoResponse; - - expect(result).toEqual(expect.objectContaining({ connectTimeout: 2000, responseTimeout: 5000 })); - }, 15000); - - test('calls api with default write timeouts', async () => { - const client = createClient(); - - const result = (await client.customPost({ path: '1/test' })) as unknown as EchoResponse; - - expect(result).toEqual(expect.objectContaining({ connectTimeout: 2000, responseTimeout: 30000 })); - }, 15000); -}); - -describe('parameters', () => { - test('throws when region is not given', async () => { - try { - const client = querySuggestionsClient('my-app-id', 'my-api-key', '', { requester: nodeEchoRequester() }); - throw new Error('test is expected to throw error'); - } catch (e) { - expect((e as Error).message).toMatch('`region` is required and must be one of the following: eu, us'); - } - }, 15000); - - test('throws when incorrect region is given', async () => { - try { - const client = querySuggestionsClient('my-app-id', 'my-api-key', 'not_a_region', { - requester: nodeEchoRequester(), - }); - throw new Error('test is expected to throw error'); - } catch (e) { - expect((e as Error).message).toMatch('`region` is required and must be one of the following: eu, us'); - } - }, 15000); - - test('does not throw when region is given', async () => { - const client = querySuggestionsClient('my-app-id', 'my-api-key', 'us', { requester: nodeEchoRequester() }); - }, 15000); -}); - -describe('setClientApiKey', () => { - test('switch API key', async () => { - const client = querySuggestionsClient('test-app-id', 'test-api-key', 'us', { - hosts: [{ url: 'localhost', port: 6683, accept: 'readWrite', protocol: 'http' }], - }); - - { - const result = await client.customGet({ path: 'check-api-key/1' }); - - expect(result).toEqual({ headerAPIKeyValue: 'test-api-key' }); - } - { - client.setClientApiKey({ apiKey: 'updated-api-key' }); - } - { - const result = await client.customGet({ path: 'check-api-key/2' }); - - expect(result).toEqual({ headerAPIKeyValue: 'updated-api-key' }); - } - }, 15000); -}); - -describe('init', () => { - test('sets authMode', async () => { - const qpClient = querySuggestionsClient('foo', 'bar', 'us', { - authMode: 'WithinQueryParameters', - requester: nodeEchoRequester(), - }); - const headerClient = querySuggestionsClient('foo', 'bar', 'us', { - authMode: 'WithinHeaders', - requester: nodeEchoRequester(), - }); - - const qpResult = (await qpClient.customGet({ - path: '1/foo', - })) as unknown as EchoResponse; - expect(qpResult.searchParams).toEqual({ - 'x-algolia-api-key': 'bar', - 'x-algolia-application-id': 'foo', - }); - - const headerResult = (await headerClient.customGet({ - path: '1/bar', - })) as unknown as EchoResponse; - expect(headerResult.headers).toEqual({ - accept: 'application/json', - 'content-type': 'text/plain', - 'x-algolia-api-key': 'bar', - 'x-algolia-application-id': 'foo', - }); - }); -}); diff --git a/tests/output/javascript/src/client/recommend.test.ts b/tests/output/javascript/src/client/recommend.test.ts deleted file mode 100644 index d3ffea739e5..00000000000 --- a/tests/output/javascript/src/client/recommend.test.ts +++ /dev/null @@ -1,123 +0,0 @@ -// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -/* eslint-disable no-lone-blocks */ -// @ts-nocheck Failing tests will have type errors, but we cannot suppress them even with @ts-expect-error because it doesn't work for a block of lines. - -import type { RecommendClient } from '@algolia/recommend'; -import { recommendClient } from '@algolia/recommend'; -import { nodeEchoRequester } from '@algolia/requester-testing'; -import type { EchoResponse } from '@algolia/requester-testing'; -import { describe, test, expect } from 'vitest'; - -const appId = 'test-app-id'; -const apiKey = 'test-api-key'; - -function createClient(): RecommendClient { - return recommendClient(appId, apiKey, { requester: nodeEchoRequester() }); -} - -describe('api', () => { - test('calls api with correct read host', async () => { - const client = recommendClient('test-app-id', 'test-api-key', { requester: nodeEchoRequester() }); - - const result = (await client.customGet({ path: 'test' })) as unknown as EchoResponse; - - expect(result.host).toEqual('test-app-id-dsn.algolia.net'); - }, 15000); - - test('calls api with correct write host', async () => { - const client = recommendClient('test-app-id', 'test-api-key', { requester: nodeEchoRequester() }); - - const result = (await client.customPost({ path: 'test' })) as unknown as EchoResponse; - - expect(result.host).toEqual('test-app-id.algolia.net'); - }, 15000); -}); - -describe('commonApi', () => { - test('calls api with correct user agent', async () => { - const client = createClient(); - - const result = (await client.customPost({ path: '1/test' })) as unknown as EchoResponse; - - expect(decodeURIComponent(result.algoliaAgent)).toMatch( - /^Algolia for JavaScript \(\d+\.\d+\.\d+(-?.*)?\)(; [a-zA-Z. ]+ (\(\d+((\.\d+)?\.\d+)?(-?.*)?\))?)*(; Recommend (\(\d+\.\d+\.\d+(-?.*)?\)))(; [a-zA-Z. ]+ (\(\d+((\.\d+)?\.\d+)?(-?.*)?\))?)*$/, - ); - }, 15000); - - test('the user agent contains the latest version', async () => { - const client = createClient(); - - const result = (await client.customPost({ path: '1/test' })) as unknown as EchoResponse; - - expect(decodeURIComponent(result.algoliaAgent)).toMatch(/^Algolia for JavaScript \(5.6.0\).*/); - }, 15000); - - test('calls api with default read timeouts', async () => { - const client = createClient(); - - const result = (await client.customGet({ path: '1/test' })) as unknown as EchoResponse; - - expect(result).toEqual(expect.objectContaining({ connectTimeout: 2000, responseTimeout: 5000 })); - }, 15000); - - test('calls api with default write timeouts', async () => { - const client = createClient(); - - const result = (await client.customPost({ path: '1/test' })) as unknown as EchoResponse; - - expect(result).toEqual(expect.objectContaining({ connectTimeout: 2000, responseTimeout: 30000 })); - }, 15000); -}); - -describe('setClientApiKey', () => { - test('switch API key', async () => { - const client = recommendClient('test-app-id', 'test-api-key', { - hosts: [{ url: 'localhost', port: 6683, accept: 'readWrite', protocol: 'http' }], - }); - - { - const result = await client.customGet({ path: 'check-api-key/1' }); - - expect(result).toEqual({ headerAPIKeyValue: 'test-api-key' }); - } - { - client.setClientApiKey({ apiKey: 'updated-api-key' }); - } - { - const result = await client.customGet({ path: 'check-api-key/2' }); - - expect(result).toEqual({ headerAPIKeyValue: 'updated-api-key' }); - } - }, 15000); -}); - -describe('init', () => { - test('sets authMode', async () => { - const qpClient = recommendClient('foo', 'bar', { - authMode: 'WithinQueryParameters', - requester: nodeEchoRequester(), - }); - const headerClient = recommendClient('foo', 'bar', { - authMode: 'WithinHeaders', - requester: nodeEchoRequester(), - }); - - const qpResult = (await qpClient.customGet({ - path: '1/foo', - })) as unknown as EchoResponse; - expect(qpResult.searchParams).toEqual({ - 'x-algolia-api-key': 'bar', - 'x-algolia-application-id': 'foo', - }); - - const headerResult = (await headerClient.customGet({ - path: '1/bar', - })) as unknown as EchoResponse; - expect(headerResult.headers).toEqual({ - accept: 'application/json', - 'content-type': 'text/plain', - 'x-algolia-api-key': 'bar', - 'x-algolia-application-id': 'foo', - }); - }); -}); diff --git a/tests/output/javascript/src/client/search.test.ts b/tests/output/javascript/src/client/search.test.ts deleted file mode 100644 index e852814f760..00000000000 --- a/tests/output/javascript/src/client/search.test.ts +++ /dev/null @@ -1,544 +0,0 @@ -// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -/* eslint-disable @typescript-eslint/no-unused-vars, require-await, no-lone-blocks */ -// @ts-nocheck Failing tests will have type errors, but we cannot suppress them even with @ts-expect-error because it doesn't work for a block of lines. - -import type { SearchClient } from '@algolia/client-search'; -import { searchClient } from '@algolia/client-search'; -import { nodeEchoRequester } from '@algolia/requester-testing'; -import type { EchoResponse } from '@algolia/requester-testing'; -import { describe, test, expect } from 'vitest'; - -const appId = 'test-app-id'; -const apiKey = 'test-api-key'; - -function createClient(): SearchClient { - return searchClient(appId, apiKey, { requester: nodeEchoRequester() }); -} - -describe('api', () => { - test('calls api with correct read host', async () => { - const client = searchClient('test-app-id', 'test-api-key', { requester: nodeEchoRequester() }); - - const result = (await client.customGet({ path: 'test' })) as unknown as EchoResponse; - - expect(result.host).toEqual('test-app-id-dsn.algolia.net'); - }, 15000); - - test('read transporter with POST method', async () => { - const client = searchClient('test-app-id', 'test-api-key', { requester: nodeEchoRequester() }); - - const result = (await client.searchSingleIndex({ indexName: 'indexName' })) as unknown as EchoResponse; - - expect(result.host).toEqual('test-app-id-dsn.algolia.net'); - }, 15000); - - test('calls api with correct write host', async () => { - const client = searchClient('test-app-id', 'test-api-key', { requester: nodeEchoRequester() }); - - const result = (await client.customPost({ path: 'test' })) as unknown as EchoResponse; - - expect(result.host).toEqual('test-app-id.algolia.net'); - }, 15000); - - test('tests the retry strategy', async () => { - const client = searchClient('test-app-id', 'test-api-key', { - hosts: [ - { url: 'localhost', port: 6676, accept: 'readWrite', protocol: 'http' }, - { url: 'localhost', port: 6677, accept: 'readWrite', protocol: 'http' }, - { url: 'localhost', port: 6678, accept: 'readWrite', protocol: 'http' }, - ], - }); - - const result = await client.customGet({ path: '1/test/retry/javascript' }); - - expect(result).toEqual({ message: 'ok test server response' }); - }, 15000); - - test('tests the retry strategy error', async () => { - const client = searchClient('test-app-id', 'test-api-key', { - hosts: [{ url: 'localhost', port: 6676, accept: 'readWrite', protocol: 'http' }], - }); - - try { - const result = await client.customGet({ path: '1/test/hang/javascript' }); - throw new Error('test is expected to throw error'); - } catch (e) { - expect((e as Error).message).toMatch( - 'Unreachable hosts - your application id may be incorrect. If the error persists, please reach out to the Algolia Support team: https://alg.li/support.', - ); - } - }, 15000); -}); - -describe('commonApi', () => { - test('calls api with correct user agent', async () => { - const client = createClient(); - - const result = (await client.customPost({ path: '1/test' })) as unknown as EchoResponse; - - expect(decodeURIComponent(result.algoliaAgent)).toMatch( - /^Algolia for JavaScript \(\d+\.\d+\.\d+(-?.*)?\)(; [a-zA-Z. ]+ (\(\d+((\.\d+)?\.\d+)?(-?.*)?\))?)*(; Search (\(\d+\.\d+\.\d+(-?.*)?\)))(; [a-zA-Z. ]+ (\(\d+((\.\d+)?\.\d+)?(-?.*)?\))?)*$/, - ); - }, 15000); - - test('the user agent contains the latest version', async () => { - const client = createClient(); - - const result = (await client.customPost({ path: '1/test' })) as unknown as EchoResponse; - - expect(decodeURIComponent(result.algoliaAgent)).toMatch(/^Algolia for JavaScript \(5.6.0\).*/); - }, 15000); - - test('calls api with default read timeouts', async () => { - const client = createClient(); - - const result = (await client.customGet({ path: '1/test' })) as unknown as EchoResponse; - - expect(result).toEqual(expect.objectContaining({ connectTimeout: 2000, responseTimeout: 5000 })); - }, 15000); - - test('calls api with default write timeouts', async () => { - const client = createClient(); - - const result = (await client.customPost({ path: '1/test' })) as unknown as EchoResponse; - - expect(result).toEqual(expect.objectContaining({ connectTimeout: 2000, responseTimeout: 30000 })); - }, 15000); -}); - -describe('deleteObjects', () => { - test('call deleteObjects without error', async () => { - const client = searchClient('test-app-id', 'test-api-key', { - hosts: [{ url: 'localhost', port: 6680, accept: 'readWrite', protocol: 'http' }], - }); - - { - const result = await client.deleteObjects({ - indexName: 'cts_e2e_deleteObjects_javascript', - objectIDs: ['1', '2'], - }); - - expect(result).toEqual([{ taskID: 666, objectIDs: ['1', '2'] }]); - } - }, 15000); -}); - -describe('generateSecuredApiKey', () => { - test('generate secured api key basic', async () => { - const client = createClient(); - - { - const result = client.generateSecuredApiKey({ - parentApiKey: '2640659426d5107b6e47d75db9cbaef8', - restrictions: { validUntil: 2524604400, restrictIndices: ['Movies'] }, - }); - - expect(result).toEqual( - 'NjFhZmE0OGEyMTI3OThiODc0OTlkOGM0YjcxYzljY2M2NmU2NDE5ZWY0NDZjMWJhNjA2NzBkMjAwOTI2YWQyZnJlc3RyaWN0SW5kaWNlcz1Nb3ZpZXMmdmFsaWRVbnRpbD0yNTI0NjA0NDAw', - ); - } - }, 15000); - - test('generate secured api key with searchParams', async () => { - const client = createClient(); - - { - const result = client.generateSecuredApiKey({ - parentApiKey: '2640659426d5107b6e47d75db9cbaef8', - restrictions: { - validUntil: 2524604400, - restrictIndices: ['Movies', 'cts_e2e_settings'], - restrictSources: '192.168.1.0/24', - filters: 'category:Book OR category:Ebook AND _tags:published', - userToken: 'user123', - searchParams: { - query: 'batman', - typoTolerance: 'strict', - aroundRadius: 'all', - mode: 'neuralSearch', - hitsPerPage: 10, - optionalWords: ['one', 'two'], - }, - }, - }); - - expect(result).toEqual( - 'MzAxMDUwYjYyODMxODQ3ZWM1ZDYzNTkxZmNjNDg2OGZjMjAzYjQyOTZhMGQ1NDJhMDFiNGMzYTYzODRhNmMxZWFyb3VuZFJhZGl1cz1hbGwmZmlsdGVycz1jYXRlZ29yeSUzQUJvb2slMjBPUiUyMGNhdGVnb3J5JTNBRWJvb2slMjBBTkQlMjBfdGFncyUzQXB1Ymxpc2hlZCZoaXRzUGVyUGFnZT0xMCZtb2RlPW5ldXJhbFNlYXJjaCZvcHRpb25hbFdvcmRzPW9uZSUyQ3R3byZxdWVyeT1iYXRtYW4mcmVzdHJpY3RJbmRpY2VzPU1vdmllcyUyQ2N0c19lMmVfc2V0dGluZ3MmcmVzdHJpY3RTb3VyY2VzPTE5Mi4xNjguMS4wJTJGMjQmdHlwb1RvbGVyYW5jZT1zdHJpY3QmdXNlclRva2VuPXVzZXIxMjMmdmFsaWRVbnRpbD0yNTI0NjA0NDAw', - ); - } - }, 15000); -}); - -describe('indexExists', () => { - test('indexExists', async () => { - const client = searchClient('test-app-id', 'test-api-key', { - hosts: [{ url: 'localhost', port: 6681, accept: 'readWrite', protocol: 'http' }], - }); - - { - const result = await client.indexExists({ indexName: 'indexExistsYES' }); - - expect(result).toEqual(true); - } - }, 15000); - - test('indexNotExists', async () => { - const client = searchClient('test-app-id', 'test-api-key', { - hosts: [{ url: 'localhost', port: 6681, accept: 'readWrite', protocol: 'http' }], - }); - - { - const result = await client.indexExists({ indexName: 'indexExistsNO' }); - - expect(result).toEqual(false); - } - }, 15000); - - test('indexExistsWithError', async () => { - const client = searchClient('test-app-id', 'test-api-key', { - hosts: [{ url: 'localhost', port: 6681, accept: 'readWrite', protocol: 'http' }], - }); - - try { - const result = await client.indexExists({ indexName: 'indexExistsERROR' }); - throw new Error('test is expected to throw error'); - } catch (e) { - expect((e as Error).message).toMatch('Invalid API key'); - } - }, 15000); -}); - -describe('parameters', () => { - test('client throws with invalid parameters', async () => { - try { - const client = searchClient('', '', { requester: nodeEchoRequester() }); - throw new Error('test is expected to throw error'); - } catch (e) { - expect((e as Error).message).toMatch('`appId` is missing.'); - } - try { - const client = searchClient('', 'my-api-key', { requester: nodeEchoRequester() }); - throw new Error('test is expected to throw error'); - } catch (e) { - expect((e as Error).message).toMatch('`appId` is missing.'); - } - try { - const client = searchClient('my-app-id', '', { requester: nodeEchoRequester() }); - throw new Error('test is expected to throw error'); - } catch (e) { - expect((e as Error).message).toMatch('`apiKey` is missing.'); - } - }, 15000); - - test('`addApiKey` throws with invalid parameters', async () => { - const client = createClient(); - - try { - const result = (await client.addApiKey(null)) as unknown as EchoResponse; - throw new Error('test is expected to throw error'); - } catch (e) { - expect((e as Error).message).toMatch('Parameter `apiKey` is required when calling `addApiKey`.'); - } - }, 15000); - - test('`addOrUpdateObject` throws with invalid parameters', async () => { - const client = createClient(); - - try { - const result = (await client.addOrUpdateObject({ - objectID: 'my-object-id', - body: {}, - })) as unknown as EchoResponse; - throw new Error('test is expected to throw error'); - } catch (e) { - expect((e as Error).message).toMatch('Parameter `indexName` is required when calling `addOrUpdateObject`.'); - } - try { - const result = (await client.addOrUpdateObject({ - indexName: 'my-index-name', - body: {}, - })) as unknown as EchoResponse; - throw new Error('test is expected to throw error'); - } catch (e) { - expect((e as Error).message).toMatch('Parameter `objectID` is required when calling `addOrUpdateObject`.'); - } - try { - const result = (await client.addOrUpdateObject({ - indexName: 'my-index-name', - objectID: 'my-object-id', - })) as unknown as EchoResponse; - throw new Error('test is expected to throw error'); - } catch (e) { - expect((e as Error).message).toMatch('Parameter `body` is required when calling `addOrUpdateObject`.'); - } - }, 15000); -}); - -describe('partialUpdateObjects', () => { - test('call partialUpdateObjects with createIfNotExists=true', async () => { - const client = searchClient('test-app-id', 'test-api-key', { - hosts: [{ url: 'localhost', port: 6680, accept: 'readWrite', protocol: 'http' }], - }); - - { - const result = await client.partialUpdateObjects({ - indexName: 'cts_e2e_partialUpdateObjects_javascript', - objects: [ - { objectID: '1', name: 'Adam' }, - { objectID: '2', name: 'Benoit' }, - ], - createIfNotExists: true, - }); - - expect(result).toEqual([{ taskID: 444, objectIDs: ['1', '2'] }]); - } - }, 15000); - - test('call partialUpdateObjects with createIfNotExists=false', async () => { - const client = searchClient('test-app-id', 'test-api-key', { - hosts: [{ url: 'localhost', port: 6680, accept: 'readWrite', protocol: 'http' }], - }); - - { - const result = await client.partialUpdateObjects({ - indexName: 'cts_e2e_partialUpdateObjects_javascript', - objects: [ - { objectID: '3', name: 'Cyril' }, - { objectID: '4', name: 'David' }, - ], - createIfNotExists: false, - }); - - expect(result).toEqual([{ taskID: 555, objectIDs: ['3', '4'] }]); - } - }, 15000); -}); - -describe('replaceAllObjects', () => { - test('call replaceAllObjects without error', async () => { - const client = searchClient('test-app-id', 'test-api-key', { - hosts: [{ url: 'localhost', port: 6679, accept: 'readWrite', protocol: 'http' }], - }); - - { - const result = await client.replaceAllObjects({ - indexName: 'cts_e2e_replace_all_objects_javascript', - objects: [ - { objectID: '1', name: 'Adam' }, - { objectID: '2', name: 'Benoit' }, - { objectID: '3', name: 'Cyril' }, - { objectID: '4', name: 'David' }, - { objectID: '5', name: 'Eva' }, - { objectID: '6', name: 'Fiona' }, - { objectID: '7', name: 'Gael' }, - { objectID: '8', name: 'Hugo' }, - { objectID: '9', name: 'Igor' }, - { objectID: '10', name: 'Julia' }, - ], - batchSize: 3, - }); - - expect(result).toEqual({ - copyOperationResponse: { taskID: 125, updatedAt: '2021-01-01T00:00:00.000Z' }, - batchResponses: [ - { taskID: 127, objectIDs: ['1', '2', '3'] }, - { taskID: 130, objectIDs: ['4', '5', '6'] }, - { taskID: 133, objectIDs: ['7', '8', '9'] }, - { taskID: 134, objectIDs: ['10'] }, - ], - moveOperationResponse: { taskID: 777, updatedAt: '2021-01-01T00:00:00.000Z' }, - }); - } - }, 15000); -}); - -describe('saveObjects', () => { - test('call saveObjects without error', async () => { - const client = searchClient('test-app-id', 'test-api-key', { - hosts: [{ url: 'localhost', port: 6680, accept: 'readWrite', protocol: 'http' }], - }); - - { - const result = await client.saveObjects({ - indexName: 'cts_e2e_saveObjects_javascript', - objects: [ - { objectID: '1', name: 'Adam' }, - { objectID: '2', name: 'Benoit' }, - ], - }); - - expect(result).toEqual([{ taskID: 333, objectIDs: ['1', '2'] }]); - } - }, 15000); - - test('saveObjects should report errors', async () => { - const client = searchClient('test-app-id', 'wrong-api-key', { - hosts: [{ url: 'localhost', port: 6680, accept: 'readWrite', protocol: 'http' }], - }); - - try { - const result = await client.saveObjects({ - indexName: 'cts_e2e_saveObjects_javascript', - objects: [ - { objectID: '1', name: 'Adam' }, - { objectID: '2', name: 'Benoit' }, - ], - }); - throw new Error('test is expected to throw error'); - } catch (e) { - expect((e as Error).message).toMatch('Invalid Application-ID or API key'); - } - }, 15000); -}); - -describe('setClientApiKey', () => { - test('switch API key', async () => { - const client = searchClient('test-app-id', 'test-api-key', { - hosts: [{ url: 'localhost', port: 6683, accept: 'readWrite', protocol: 'http' }], - }); - - { - const result = await client.customGet({ path: 'check-api-key/1' }); - - expect(result).toEqual({ headerAPIKeyValue: 'test-api-key' }); - } - { - client.setClientApiKey({ apiKey: 'updated-api-key' }); - } - { - const result = await client.customGet({ path: 'check-api-key/2' }); - - expect(result).toEqual({ headerAPIKeyValue: 'updated-api-key' }); - } - }, 15000); -}); - -describe('waitForApiKey', () => { - test('wait for api key helper - add', async () => { - const client = searchClient('test-app-id', 'test-api-key', { - hosts: [{ url: 'localhost', port: 6681, accept: 'readWrite', protocol: 'http' }], - }); - - { - const result = await client.waitForApiKey({ key: 'api-key-add-operation-test-javascript', operation: 'add' }); - - expect(result).toEqual({ - value: 'api-key-add-operation-test-javascript', - description: 'my new api key', - acl: ['search', 'addObject'], - validity: 300, - maxQueriesPerIPPerHour: 100, - maxHitsPerQuery: 20, - createdAt: 1720094400, - }); - } - }, 15000); - - test('wait for api key - update', async () => { - const client = searchClient('test-app-id', 'test-api-key', { - hosts: [{ url: 'localhost', port: 6681, accept: 'readWrite', protocol: 'http' }], - }); - - { - const result = await client.waitForApiKey({ - key: 'api-key-update-operation-test-javascript', - operation: 'update', - apiKey: { - description: 'my updated api key', - acl: ['search', 'addObject', 'deleteObject'], - indexes: ['Movies', 'Books'], - referers: ['*google.com', '*algolia.com'], - validity: 305, - maxQueriesPerIPPerHour: 95, - maxHitsPerQuery: 20, - }, - }); - - expect(result).toEqual({ - value: 'api-key-update-operation-test-javascript', - description: 'my updated api key', - acl: ['search', 'addObject', 'deleteObject'], - indexes: ['Movies', 'Books'], - referers: ['*google.com', '*algolia.com'], - validity: 305, - maxQueriesPerIPPerHour: 95, - maxHitsPerQuery: 20, - createdAt: 1720094400, - }); - } - }, 15000); - - test('wait for api key - delete', async () => { - const client = searchClient('test-app-id', 'test-api-key', { - hosts: [{ url: 'localhost', port: 6681, accept: 'readWrite', protocol: 'http' }], - }); - - { - const result = await client.waitForApiKey({ - key: 'api-key-delete-operation-test-javascript', - operation: 'delete', - }); - - expect(result).toEqual(); - } - }, 15000); -}); - -describe('waitForAppTask', () => { - test('wait for an application-level task', async () => { - const client = searchClient('test-app-id', 'test-api-key', { - hosts: [{ url: 'localhost', port: 6681, accept: 'readWrite', protocol: 'http' }], - }); - - { - const result = await client.waitForAppTask({ taskID: 123 }); - - expect(result).toEqual({ status: 'published' }); - } - }, 15000); -}); - -describe('waitForTask', () => { - test('wait for task', async () => { - const client = searchClient('test-app-id', 'test-api-key', { - hosts: [{ url: 'localhost', port: 6681, accept: 'readWrite', protocol: 'http' }], - }); - - { - const result = await client.waitForTask({ indexName: 'wait-task-javascript', taskID: 123 }); - - expect(result).toEqual({ status: 'published' }); - } - }, 15000); -}); - -describe('init', () => { - test('sets authMode', async () => { - const qpClient = searchClient('foo', 'bar', { - authMode: 'WithinQueryParameters', - requester: nodeEchoRequester(), - }); - const headerClient = searchClient('foo', 'bar', { - authMode: 'WithinHeaders', - requester: nodeEchoRequester(), - }); - - const qpResult = (await qpClient.customGet({ - path: '1/foo', - })) as unknown as EchoResponse; - expect(qpResult.searchParams).toEqual({ - 'x-algolia-api-key': 'bar', - 'x-algolia-application-id': 'foo', - }); - - const headerResult = (await headerClient.customGet({ - path: '1/bar', - })) as unknown as EchoResponse; - expect(headerResult.headers).toEqual({ - accept: 'application/json', - 'content-type': 'text/plain', - 'x-algolia-api-key': 'bar', - 'x-algolia-application-id': 'foo', - }); - }); -}); diff --git a/tests/output/javascript/src/e2e/abtesting.test.ts b/tests/output/javascript/src/e2e/abtesting.test.ts deleted file mode 100644 index 9b260c25df8..00000000000 --- a/tests/output/javascript/src/e2e/abtesting.test.ts +++ /dev/null @@ -1,60 +0,0 @@ -// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -import { abtestingClient } from '@algolia/client-abtesting'; -import * as dotenv from 'dotenv'; -import { describe, test, expect } from 'vitest'; - -import { union } from '../helpers'; - -dotenv.config({ path: '../../.env' }); - -if (!process.env.ALGOLIA_APPLICATION_ID) { - throw new Error('please provide an `ALGOLIA_APPLICATION_ID` env var for e2e tests'); -} - -if (!process.env.ALGOLIA_ADMIN_KEY) { - throw new Error('please provide an `ALGOLIA_ADMIN_KEY` env var for e2e tests'); -} - -const client = abtestingClient(process.env.ALGOLIA_APPLICATION_ID, process.env.ALGOLIA_ADMIN_KEY, 'us'); - -describe('listABTests', () => { - test('listABTests with parameters', async () => { - const resp = await client.listABTests({ offset: 0, limit: 21, indexPrefix: 'cts_e2e ab', indexSuffix: 't' }); - - const expectedBody = { - abtests: [ - { - abTestID: 85635, - createdAt: '2024-05-13T10:12:27.739233Z', - endAt: '2124-05-13T00:00:00Z', - name: 'cts_e2e_abtest', - status: 'active', - variants: [ - { - addToCartCount: 0, - clickCount: 0, - conversionCount: 0, - description: 'this abtest is used for api client automation tests and will expire in 2124', - index: 'cts_e2e_search_facet', - purchaseCount: 0, - trafficPercentage: 25, - }, - { - addToCartCount: 0, - clickCount: 0, - conversionCount: 0, - description: '', - index: 'cts_e2e abtest', - purchaseCount: 0, - trafficPercentage: 75, - }, - ], - }, - ], - count: 1, - total: 1, - }; - - expect(expectedBody).toEqual(union(expectedBody, resp)); - }); -}); diff --git a/tests/output/javascript/src/e2e/algoliasearch.test.ts b/tests/output/javascript/src/e2e/algoliasearch.test.ts deleted file mode 100644 index 6d81bc672ab..00000000000 --- a/tests/output/javascript/src/e2e/algoliasearch.test.ts +++ /dev/null @@ -1,192 +0,0 @@ -// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -import { liteClient } from 'algoliasearch/lite'; -import * as dotenv from 'dotenv'; -import { describe, test, expect } from 'vitest'; - -import { union } from '../helpers'; - -dotenv.config({ path: '../../.env' }); - -if (!process.env.ALGOLIA_APPLICATION_ID) { - throw new Error('please provide an `ALGOLIA_APPLICATION_ID` env var for e2e tests'); -} - -if (!process.env.ALGOLIA_ADMIN_KEY) { - throw new Error('please provide an `ALGOLIA_ADMIN_KEY` env var for e2e tests'); -} - -const client = liteClient(process.env.ALGOLIA_APPLICATION_ID, process.env.ALGOLIA_ADMIN_KEY); - -describe('search', () => { - test('search for a single hits request with minimal parameters', async () => { - const resp = await client.search({ requests: [{ indexName: 'cts_e2e_search_empty_index' }] }); - - const expectedBody = { - results: [ - { - hits: [], - page: 0, - nbHits: 0, - nbPages: 0, - hitsPerPage: 20, - exhaustiveNbHits: true, - exhaustiveTypo: true, - exhaustive: { nbHits: true, typo: true }, - query: '', - params: '', - index: 'cts_e2e_search_empty_index', - renderingContent: {}, - }, - ], - }; - - expect(expectedBody).toEqual(union(expectedBody, resp)); - }); - - test('search with highlight and snippet results', async () => { - const resp = await client.search({ - requests: [ - { - indexName: 'cts_e2e_highlight_snippet_results', - query: 'vim', - attributesToSnippet: ['*:20'], - attributesToHighlight: ['*'], - attributesToRetrieve: ['*'], - }, - ], - }); - - const expectedBody = { - results: [ - { - hits: [ - { - editor: { name: 'vim', type: 'beforeneovim' }, - names: ['vim', ':q'], - _snippetResult: { - editor: { - name: { value: 'vim', matchLevel: 'full' }, - type: { value: 'beforeneovim', matchLevel: 'none' }, - }, - names: [ - { value: 'vim', matchLevel: 'full' }, - { value: ':q', matchLevel: 'none' }, - ], - }, - _highlightResult: { - editor: { - name: { value: 'vim', matchLevel: 'full', fullyHighlighted: true, matchedWords: ['vim'] }, - type: { value: 'beforeneovim', matchLevel: 'none', matchedWords: [] }, - }, - names: [ - { value: 'vim', matchLevel: 'full', fullyHighlighted: true, matchedWords: ['vim'] }, - { value: ':q', matchLevel: 'none', matchedWords: [] }, - ], - }, - }, - ], - nbHits: 1, - page: 0, - nbPages: 1, - hitsPerPage: 20, - exhaustiveNbHits: true, - exhaustiveTypo: true, - exhaustive: { nbHits: true, typo: true }, - query: 'vim', - index: 'cts_e2e_highlight_snippet_results', - renderingContent: {}, - }, - ], - }; - - expect(expectedBody).toEqual(union(expectedBody, resp)); - }); - - test('search for a single facet request with minimal parameters', async () => { - const resp = await client.search({ - requests: [{ indexName: 'cts_e2e_search_facet', type: 'facet', facet: 'editor' }], - strategy: 'stopIfEnoughMatches', - }); - - const expectedBody = { - results: [ - { - exhaustiveFacetsCount: true, - facetHits: [ - { count: 1, highlighted: 'goland', value: 'goland' }, - { count: 1, highlighted: 'neovim', value: 'neovim' }, - { count: 1, highlighted: 'visual studio', value: 'visual studio' }, - { count: 1, highlighted: 'vscode', value: 'vscode' }, - ], - }, - ], - }; - - expect(expectedBody).toEqual(union(expectedBody, resp)); - }); - - test('search filters end to end', async () => { - const resp = await client.search({ - requests: [ - { indexName: 'cts_e2e_search_facet', filters: "editor:'visual studio' OR editor:neovim" }, - { indexName: 'cts_e2e_search_facet', facetFilters: ["editor:'visual studio'", 'editor:neovim'] }, - { indexName: 'cts_e2e_search_facet', facetFilters: ["editor:'visual studio'", ['editor:neovim']] }, - { - indexName: 'cts_e2e_search_facet', - facetFilters: ["editor:'visual studio'", ['editor:neovim', ['editor:goland']]], - }, - ], - }); - - const expectedBody = { - results: [ - { - hitsPerPage: 20, - index: 'cts_e2e_search_facet', - nbHits: 2, - nbPages: 1, - page: 0, - hits: [ - { editor: 'visual studio', _highlightResult: { editor: { value: 'visual studio', matchLevel: 'none' } } }, - { editor: 'neovim', _highlightResult: { editor: { value: 'neovim', matchLevel: 'none' } } }, - ], - query: '', - params: 'filters=editor%3A%27visual+studio%27+OR+editor%3Aneovim', - }, - { - hitsPerPage: 20, - index: 'cts_e2e_search_facet', - nbHits: 0, - nbPages: 0, - page: 0, - hits: [], - query: '', - params: 'facetFilters=%5B%22editor%3A%27visual+studio%27%22%2C%22editor%3Aneovim%22%5D', - }, - { - hitsPerPage: 20, - index: 'cts_e2e_search_facet', - nbHits: 0, - nbPages: 0, - page: 0, - hits: [], - query: '', - params: 'facetFilters=%5B%22editor%3A%27visual+studio%27%22%2C%5B%22editor%3Aneovim%22%5D%5D', - }, - { - hitsPerPage: 20, - index: 'cts_e2e_search_facet', - nbHits: 0, - nbPages: 0, - page: 0, - hits: [], - query: '', - params: - 'facetFilters=%5B%22editor%3A%27visual+studio%27%22%2C%5B%22editor%3Aneovim%22%2C%5B%22editor%3Agoland%22%5D%5D%5D', - }, - ], - }; - - expect(expectedBody).toEqual(union(expectedBody, resp)); - }); -}); diff --git a/tests/output/javascript/src/e2e/insights.test.ts b/tests/output/javascript/src/e2e/insights.test.ts deleted file mode 100644 index 1d9ed0416fb..00000000000 --- a/tests/output/javascript/src/e2e/insights.test.ts +++ /dev/null @@ -1,50 +0,0 @@ -// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -import { insightsClient } from '@algolia/client-insights'; -import * as dotenv from 'dotenv'; -import { describe, test, expect } from 'vitest'; - -import { union } from '../helpers'; - -dotenv.config({ path: '../../.env' }); - -if (!process.env.ALGOLIA_APPLICATION_ID) { - throw new Error('please provide an `ALGOLIA_APPLICATION_ID` env var for e2e tests'); -} - -if (!process.env.ALGOLIA_ADMIN_KEY) { - throw new Error('please provide an `ALGOLIA_ADMIN_KEY` env var for e2e tests'); -} - -const client = insightsClient(process.env.ALGOLIA_APPLICATION_ID, process.env.ALGOLIA_ADMIN_KEY, 'us'); - -describe('pushEvents', () => { - test('Many events type', async () => { - const resp = await client.pushEvents({ - events: [ - { - eventType: 'conversion', - eventName: 'Product Purchased', - index: 'products', - userToken: 'user-123456', - authenticatedUserToken: 'user-123456', - timestamp: 1727049600000, - objectIDs: ['9780545139700', '9780439784542'], - queryID: '43b15df305339e827f0ac0bdc5ebcaa7', - }, - { - eventType: 'view', - eventName: 'Product Detail Page Viewed', - index: 'products', - userToken: 'user-123456', - authenticatedUserToken: 'user-123456', - timestamp: 1727049600000, - objectIDs: ['9780545139700', '9780439784542'], - }, - ], - }); - - const expectedBody = { message: 'OK', status: 200 }; - - expect(expectedBody).toEqual(union(expectedBody, resp)); - }); -}); diff --git a/tests/output/javascript/src/e2e/querySuggestions.test.ts b/tests/output/javascript/src/e2e/querySuggestions.test.ts deleted file mode 100644 index 406891fba4b..00000000000 --- a/tests/output/javascript/src/e2e/querySuggestions.test.ts +++ /dev/null @@ -1,45 +0,0 @@ -// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -import { querySuggestionsClient } from '@algolia/client-query-suggestions'; -import * as dotenv from 'dotenv'; -import { describe, test, expect } from 'vitest'; - -import { union } from '../helpers'; - -dotenv.config({ path: '../../.env' }); - -if (!process.env.ALGOLIA_APPLICATION_ID) { - throw new Error('please provide an `ALGOLIA_APPLICATION_ID` env var for e2e tests'); -} - -if (!process.env.ALGOLIA_ADMIN_KEY) { - throw new Error('please provide an `ALGOLIA_ADMIN_KEY` env var for e2e tests'); -} - -const client = querySuggestionsClient(process.env.ALGOLIA_APPLICATION_ID, process.env.ALGOLIA_ADMIN_KEY, 'us'); - -describe('getConfig', () => { - test('Retrieve QS config e2e', async () => { - const resp = await client.getConfig({ indexName: 'cts_e2e_browse_query_suggestions' }); - - const expectedBody = { - appID: 'T8JK9S7I7X', - allowSpecialCharacters: true, - enablePersonalization: false, - exclude: ['^cocaines$'], - indexName: 'cts_e2e_browse_query_suggestions', - languages: [], - sourceIndices: [ - { - facets: [{ amount: 1, attribute: 'title' }], - generate: [['year']], - indexName: 'cts_e2e_browse', - minHits: 5, - minLetters: 4, - replicas: false, - }, - ], - }; - - expect(expectedBody).toEqual(union(expectedBody, resp)); - }); -}); diff --git a/tests/output/javascript/src/e2e/search.test.ts b/tests/output/javascript/src/e2e/search.test.ts deleted file mode 100644 index 5a37a99059c..00000000000 --- a/tests/output/javascript/src/e2e/search.test.ts +++ /dev/null @@ -1,344 +0,0 @@ -// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -import { searchClient } from '@algolia/client-search'; -import * as dotenv from 'dotenv'; -import { describe, test, expect } from 'vitest'; - -import { union } from '../helpers'; - -dotenv.config({ path: '../../.env' }); - -if (!process.env.ALGOLIA_APPLICATION_ID) { - throw new Error('please provide an `ALGOLIA_APPLICATION_ID` env var for e2e tests'); -} - -if (!process.env.ALGOLIA_ADMIN_KEY) { - throw new Error('please provide an `ALGOLIA_ADMIN_KEY` env var for e2e tests'); -} - -const client = searchClient(process.env.ALGOLIA_APPLICATION_ID, process.env.ALGOLIA_ADMIN_KEY); - -describe('browse', () => { - test('browse with minimal parameters', async () => { - const resp = await client.browse({ indexName: 'cts_e2e_browse' }); - - const expectedBody = { page: 0, nbHits: 33191, nbPages: 34, hitsPerPage: 1000, query: '', params: '' }; - - expect(expectedBody).toEqual(union(expectedBody, resp)); - }); -}); - -describe('getRule', () => { - test('getRule', async () => { - const resp = await client.getRule({ indexName: 'cts_e2e_browse', objectID: 'qr-1725004648916' }); - - const expectedBody = { - description: 'test_rule', - enabled: true, - objectID: 'qr-1725004648916', - conditions: [{ alternatives: true, anchoring: 'contains', pattern: 'zorro' }], - consequence: { - params: { ignorePlurals: 'true' }, - filterPromotes: true, - promote: [{ objectIDs: ['Æon Flux'], position: 0 }], - }, - }; - - expect(expectedBody).toEqual(union(expectedBody, resp)); - }); -}); - -describe('getSettings', () => { - test('getSettings', async () => { - const resp = await client.getSettings({ indexName: 'cts_e2e_settings' }); - - const expectedBody = { - minWordSizefor1Typo: 4, - minWordSizefor2Typos: 8, - hitsPerPage: 100, - maxValuesPerFacet: 100, - paginationLimitedTo: 10, - exactOnSingleWordQuery: 'attribute', - ranking: ['typo', 'geo', 'words', 'filters', 'proximity', 'attribute', 'exact', 'custom'], - separatorsToIndex: '', - removeWordsIfNoResults: 'none', - queryType: 'prefixLast', - highlightPreTag: '', - highlightPostTag: '', - alternativesAsExact: ['ignorePlurals', 'singleWordSynonym'], - }; - - expect(expectedBody).toEqual(union(expectedBody, resp)); - }); -}); - -describe('search', () => { - test('search for a single hits request with minimal parameters', async () => { - const resp = await client.search({ requests: [{ indexName: 'cts_e2e_search_empty_index' }] }); - - const expectedBody = { - results: [ - { - hits: [], - page: 0, - nbHits: 0, - nbPages: 0, - hitsPerPage: 20, - exhaustiveNbHits: true, - exhaustiveTypo: true, - exhaustive: { nbHits: true, typo: true }, - query: '', - params: '', - index: 'cts_e2e_search_empty_index', - renderingContent: {}, - }, - ], - }; - - expect(expectedBody).toEqual(union(expectedBody, resp)); - }); - - test('search with highlight and snippet results', async () => { - const resp = await client.search({ - requests: [ - { - indexName: 'cts_e2e_highlight_snippet_results', - query: 'vim', - attributesToSnippet: ['*:20'], - attributesToHighlight: ['*'], - attributesToRetrieve: ['*'], - }, - ], - }); - - const expectedBody = { - results: [ - { - hits: [ - { - editor: { name: 'vim', type: 'beforeneovim' }, - names: ['vim', ':q'], - _snippetResult: { - editor: { - name: { value: 'vim', matchLevel: 'full' }, - type: { value: 'beforeneovim', matchLevel: 'none' }, - }, - names: [ - { value: 'vim', matchLevel: 'full' }, - { value: ':q', matchLevel: 'none' }, - ], - }, - _highlightResult: { - editor: { - name: { value: 'vim', matchLevel: 'full', fullyHighlighted: true, matchedWords: ['vim'] }, - type: { value: 'beforeneovim', matchLevel: 'none', matchedWords: [] }, - }, - names: [ - { value: 'vim', matchLevel: 'full', fullyHighlighted: true, matchedWords: ['vim'] }, - { value: ':q', matchLevel: 'none', matchedWords: [] }, - ], - }, - }, - ], - nbHits: 1, - page: 0, - nbPages: 1, - hitsPerPage: 20, - exhaustiveNbHits: true, - exhaustiveTypo: true, - exhaustive: { nbHits: true, typo: true }, - query: 'vim', - index: 'cts_e2e_highlight_snippet_results', - renderingContent: {}, - }, - ], - }; - - expect(expectedBody).toEqual(union(expectedBody, resp)); - }); - - test('search for a single facet request with minimal parameters', async () => { - const resp = await client.search({ - requests: [{ indexName: 'cts_e2e_search_facet', type: 'facet', facet: 'editor' }], - strategy: 'stopIfEnoughMatches', - }); - - const expectedBody = { - results: [ - { - exhaustiveFacetsCount: true, - facetHits: [ - { count: 1, highlighted: 'goland', value: 'goland' }, - { count: 1, highlighted: 'neovim', value: 'neovim' }, - { count: 1, highlighted: 'visual studio', value: 'visual studio' }, - { count: 1, highlighted: 'vscode', value: 'vscode' }, - ], - }, - ], - }; - - expect(expectedBody).toEqual(union(expectedBody, resp)); - }); - - test('search filters end to end', async () => { - const resp = await client.search({ - requests: [ - { indexName: 'cts_e2e_search_facet', filters: "editor:'visual studio' OR editor:neovim" }, - { indexName: 'cts_e2e_search_facet', facetFilters: ["editor:'visual studio'", 'editor:neovim'] }, - { indexName: 'cts_e2e_search_facet', facetFilters: ["editor:'visual studio'", ['editor:neovim']] }, - { - indexName: 'cts_e2e_search_facet', - facetFilters: ["editor:'visual studio'", ['editor:neovim', ['editor:goland']]], - }, - ], - }); - - const expectedBody = { - results: [ - { - hitsPerPage: 20, - index: 'cts_e2e_search_facet', - nbHits: 2, - nbPages: 1, - page: 0, - hits: [ - { editor: 'visual studio', _highlightResult: { editor: { value: 'visual studio', matchLevel: 'none' } } }, - { editor: 'neovim', _highlightResult: { editor: { value: 'neovim', matchLevel: 'none' } } }, - ], - query: '', - params: 'filters=editor%3A%27visual+studio%27+OR+editor%3Aneovim', - }, - { - hitsPerPage: 20, - index: 'cts_e2e_search_facet', - nbHits: 0, - nbPages: 0, - page: 0, - hits: [], - query: '', - params: 'facetFilters=%5B%22editor%3A%27visual+studio%27%22%2C%22editor%3Aneovim%22%5D', - }, - { - hitsPerPage: 20, - index: 'cts_e2e_search_facet', - nbHits: 0, - nbPages: 0, - page: 0, - hits: [], - query: '', - params: 'facetFilters=%5B%22editor%3A%27visual+studio%27%22%2C%5B%22editor%3Aneovim%22%5D%5D', - }, - { - hitsPerPage: 20, - index: 'cts_e2e_search_facet', - nbHits: 0, - nbPages: 0, - page: 0, - hits: [], - query: '', - params: - 'facetFilters=%5B%22editor%3A%27visual+studio%27%22%2C%5B%22editor%3Aneovim%22%2C%5B%22editor%3Agoland%22%5D%5D%5D', - }, - ], - }; - - expect(expectedBody).toEqual(union(expectedBody, resp)); - }); -}); - -describe('searchDictionaryEntries', () => { - test('get searchDictionaryEntries results with minimal parameters', async () => { - const resp = await client.searchDictionaryEntries({ - dictionaryName: 'stopwords', - searchDictionaryEntriesParams: { query: 'about' }, - }); - - const expectedBody = { - hits: [{ objectID: '86ef58032f47d976ca7130a896086783', language: 'en', word: 'about' }], - page: 0, - nbHits: 1, - nbPages: 1, - }; - - expect(expectedBody).toEqual(union(expectedBody, resp)); - }); -}); - -describe('searchRules', () => { - test('searchRules', async () => { - const resp = await client.searchRules({ indexName: 'cts_e2e_browse', searchRulesParams: { query: 'zorro' } }); - - const expectedBody = { - hits: [ - { - conditions: [{ alternatives: true, anchoring: 'contains', pattern: 'zorro' }], - consequence: { - params: { ignorePlurals: 'true' }, - filterPromotes: true, - promote: [{ objectIDs: ['Æon Flux'], position: 0 }], - }, - description: 'test_rule', - enabled: true, - objectID: 'qr-1725004648916', - }, - ], - nbHits: 1, - nbPages: 1, - page: 0, - }; - - expect(expectedBody).toEqual(union(expectedBody, resp)); - }); -}); - -describe('searchSingleIndex', () => { - test('search with special characters in indexName', async () => { - await client.searchSingleIndex({ indexName: 'cts_e2e_space in index' }); - }); - - test('single search retrieve snippets', async () => { - const resp = await client.searchSingleIndex({ - indexName: 'cts_e2e_browse', - searchParams: { - query: 'batman mask of the phantasm', - attributesToRetrieve: ['*'], - attributesToSnippet: ['*:20'], - }, - }); - - const expectedBody = { - nbHits: 1, - hits: [ - { - _snippetResult: { - genres: [ - { value: 'Animated', matchLevel: 'none' }, - { value: 'Superhero', matchLevel: 'none' }, - { value: 'Romance', matchLevel: 'none' }, - ], - year: { value: '1993', matchLevel: 'none' }, - }, - _highlightResult: { - genres: [ - { value: 'Animated', matchLevel: 'none', matchedWords: [] }, - { value: 'Superhero', matchLevel: 'none', matchedWords: [] }, - { value: 'Romance', matchLevel: 'none', matchedWords: [] }, - ], - year: { value: '1993', matchLevel: 'none', matchedWords: [] }, - }, - }, - ], - }; - - expect(expectedBody).toEqual(union(expectedBody, resp)); - }); -}); - -describe('setSettings', () => { - test('setSettings with minimal parameters', async () => { - await client.setSettings({ - indexName: 'cts_e2e_settings', - indexSettings: { paginationLimitedTo: 10 }, - forwardToReplicas: true, - }); - }); -}); diff --git a/tests/output/javascript/src/requests/abtesting.test.ts b/tests/output/javascript/src/requests/abtesting.test.ts deleted file mode 100644 index 996345b2366..00000000000 --- a/tests/output/javascript/src/requests/abtesting.test.ts +++ /dev/null @@ -1,362 +0,0 @@ -// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. - -import { abtestingClient } from '@algolia/client-abtesting'; -import { nodeEchoRequester } from '@algolia/requester-testing'; -import type { EchoResponse } from '@algolia/requester-testing'; -import { describe, test, expect } from 'vitest'; - -const appId = process.env.ALGOLIA_APPLICATION_ID || 'test_app_id'; -const apiKey = process.env.ALGOLIA_SEARCH_KEY || 'test_api_key'; - -const client = abtestingClient(appId, apiKey, 'us', { requester: nodeEchoRequester() }); - -describe('addABTests', () => { - test('addABTests with minimal parameters', async () => { - const req = (await client.addABTests({ - endAt: '2022-12-31T00:00:00.000Z', - name: 'myABTest', - variants: [ - { index: 'AB_TEST_1', trafficPercentage: 30 }, - { index: 'AB_TEST_2', trafficPercentage: 50 }, - ], - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/abtests'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - endAt: '2022-12-31T00:00:00.000Z', - name: 'myABTest', - variants: [ - { index: 'AB_TEST_1', trafficPercentage: 30 }, - { index: 'AB_TEST_2', trafficPercentage: 50 }, - ], - }); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('customDelete', () => { - test('allow del method for a custom path with minimal parameters', async () => { - const req = (await client.customDelete({ path: 'test/minimal' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/minimal'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('allow del method for a custom path with all parameters', async () => { - const req = (await client.customDelete({ - path: 'test/all', - parameters: { query: 'parameters' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/all'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ query: 'parameters' }); - }); -}); - -describe('customGet', () => { - test('allow get method for a custom path with minimal parameters', async () => { - const req = (await client.customGet({ path: 'test/minimal' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/minimal'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('allow get method for a custom path with all parameters', async () => { - const req = (await client.customGet({ - path: 'test/all', - parameters: { query: 'parameters with space' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/all'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ query: 'parameters%20with%20space' }); - }); - - test('requestOptions should be escaped too', async () => { - const req = (await client.customGet( - { path: 'test/all', parameters: { query: 'to be overriden' } }, - { - queryParameters: { query: 'parameters with space', 'and an array': ['array', 'with spaces'] }, - headers: { 'x-header-1': 'spaces are left alone' }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/all'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ - query: 'parameters%20with%20space', - 'and%20an%20array': 'array%2Cwith%20spaces', - }); - expect(req.headers).toEqual(expect.objectContaining({ 'x-header-1': 'spaces are left alone' })); - }); -}); - -describe('customPost', () => { - test('allow post method for a custom path with minimal parameters', async () => { - const req = (await client.customPost({ path: 'test/minimal' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/minimal'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({}); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('allow post method for a custom path with all parameters', async () => { - const req = (await client.customPost({ - path: 'test/all', - parameters: { query: 'parameters' }, - body: { body: 'parameters' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/all'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ body: 'parameters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters' }); - }); - - test('requestOptions can override default query parameters', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { query: 'myQueryParameter' }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'myQueryParameter' }); - }); - - test('requestOptions merges query parameters with default ones', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { query2: 'myQueryParameter' }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', query2: 'myQueryParameter' }); - }); - - test('requestOptions can override default headers', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - headers: { 'x-algolia-api-key': 'ALGOLIA_API_KEY' }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters' }); - expect(req.headers).toEqual(expect.objectContaining({ 'x-algolia-api-key': 'ALGOLIA_API_KEY' })); - }); - - test('requestOptions merges headers with default ones', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - headers: { 'x-algolia-api-key': 'ALGOLIA_API_KEY' }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters' }); - expect(req.headers).toEqual(expect.objectContaining({ 'x-algolia-api-key': 'ALGOLIA_API_KEY' })); - }); - - test('requestOptions queryParameters accepts booleans', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { isItWorking: true }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', isItWorking: 'true' }); - }); - - test('requestOptions queryParameters accepts integers', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { myParam: 2 }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', myParam: '2' }); - }); - - test('requestOptions queryParameters accepts list of string', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { myParam: ['b and c', 'd'] }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', myParam: 'b%20and%20c%2Cd' }); - }); - - test('requestOptions queryParameters accepts list of booleans', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { myParam: [true, true, false] }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', myParam: 'true%2Ctrue%2Cfalse' }); - }); - - test('requestOptions queryParameters accepts list of integers', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { myParam: [1, 2] }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', myParam: '1%2C2' }); - }); -}); - -describe('customPut', () => { - test('allow put method for a custom path with minimal parameters', async () => { - const req = (await client.customPut({ path: 'test/minimal' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/minimal'); - expect(req.method).toEqual('PUT'); - expect(req.data).toEqual({}); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('allow put method for a custom path with all parameters', async () => { - const req = (await client.customPut({ - path: 'test/all', - parameters: { query: 'parameters' }, - body: { body: 'parameters' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/all'); - expect(req.method).toEqual('PUT'); - expect(req.data).toEqual({ body: 'parameters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters' }); - }); -}); - -describe('deleteABTest', () => { - test('deleteABTest', async () => { - const req = (await client.deleteABTest({ id: 42 })) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/abtests/42'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('getABTest', () => { - test('getABTest', async () => { - const req = (await client.getABTest({ id: 42 })) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/abtests/42'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('listABTests', () => { - test('listABTests with minimal parameters', async () => { - const req = (await client.listABTests()) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/abtests'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('listABTests with parameters', async () => { - const req = (await client.listABTests({ - offset: 0, - limit: 21, - indexPrefix: 'cts_e2e ab', - indexSuffix: 't', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/abtests'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ offset: '0', limit: '21', indexPrefix: 'cts_e2e%20ab', indexSuffix: 't' }); - }); -}); - -describe('scheduleABTest', () => { - test('scheduleABTest with minimal parameters', async () => { - const req = (await client.scheduleABTest({ - endAt: '2022-12-31T00:00:00.000Z', - scheduledAt: '2022-11-31T00:00:00.000Z', - name: 'myABTest', - variants: [ - { index: 'AB_TEST_1', trafficPercentage: 30 }, - { index: 'AB_TEST_2', trafficPercentage: 50 }, - ], - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/abtests/schedule'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - endAt: '2022-12-31T00:00:00.000Z', - scheduledAt: '2022-11-31T00:00:00.000Z', - name: 'myABTest', - variants: [ - { index: 'AB_TEST_1', trafficPercentage: 30 }, - { index: 'AB_TEST_2', trafficPercentage: 50 }, - ], - }); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('stopABTest', () => { - test('stopABTest', async () => { - const req = (await client.stopABTest({ id: 42 })) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/abtests/42/stop'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); diff --git a/tests/output/javascript/src/requests/algoliasearch.test.ts b/tests/output/javascript/src/requests/algoliasearch.test.ts deleted file mode 100644 index f6d5d83b0f6..00000000000 --- a/tests/output/javascript/src/requests/algoliasearch.test.ts +++ /dev/null @@ -1,855 +0,0 @@ -// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -import { nodeEchoRequester } from '@algolia/requester-testing'; -import type { EchoResponse } from '@algolia/requester-testing'; -import { liteClient } from 'algoliasearch/lite'; -import { describe, test, expect } from 'vitest'; - -const appId = process.env.ALGOLIA_APPLICATION_ID || 'test_app_id'; -const apiKey = process.env.ALGOLIA_SEARCH_KEY || 'test_api_key'; - -const client = liteClient(appId, apiKey, { requester: nodeEchoRequester() }); - -describe('customPost', () => { - test('allow post method for a custom path with minimal parameters', async () => { - const req = (await client.customPost({ path: 'test/minimal' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/minimal'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({}); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('allow post method for a custom path with all parameters', async () => { - const req = (await client.customPost({ - path: 'test/all', - parameters: { query: 'parameters' }, - body: { body: 'parameters' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/all'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ body: 'parameters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters' }); - }); - - test('requestOptions can override default query parameters', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { query: 'myQueryParameter' }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'myQueryParameter' }); - }); - - test('requestOptions merges query parameters with default ones', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { query2: 'myQueryParameter' }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', query2: 'myQueryParameter' }); - }); - - test('requestOptions can override default headers', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - headers: { 'x-algolia-api-key': 'ALGOLIA_API_KEY' }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters' }); - expect(req.headers).toEqual(expect.objectContaining({ 'x-algolia-api-key': 'ALGOLIA_API_KEY' })); - }); - - test('requestOptions merges headers with default ones', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - headers: { 'x-algolia-api-key': 'ALGOLIA_API_KEY' }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters' }); - expect(req.headers).toEqual(expect.objectContaining({ 'x-algolia-api-key': 'ALGOLIA_API_KEY' })); - }); - - test('requestOptions queryParameters accepts booleans', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { isItWorking: true }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', isItWorking: 'true' }); - }); - - test('requestOptions queryParameters accepts integers', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { myParam: 2 }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', myParam: '2' }); - }); - - test('requestOptions queryParameters accepts list of string', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { myParam: ['b and c', 'd'] }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', myParam: 'b%20and%20c%2Cd' }); - }); - - test('requestOptions queryParameters accepts list of booleans', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { myParam: [true, true, false] }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', myParam: 'true%2Ctrue%2Cfalse' }); - }); - - test('requestOptions queryParameters accepts list of integers', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { myParam: [1, 2] }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', myParam: '1%2C2' }); - }); -}); - -describe('getRecommendations', () => { - test('get recommendations for recommend model with minimal parameters', async () => { - const req = (await client.getRecommendations({ - requests: [{ indexName: 'indexName', objectID: 'objectID', model: 'related-products', threshold: 42.1 }], - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/*/recommendations'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [{ indexName: 'indexName', objectID: 'objectID', model: 'related-products', threshold: 42.1 }], - }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('get recommendations for recommend model with all parameters', async () => { - const req = (await client.getRecommendations({ - requests: [ - { - indexName: 'indexName', - objectID: 'objectID', - model: 'related-products', - threshold: 42.1, - maxRecommendations: 10, - queryParameters: { query: 'myQuery', facetFilters: ['query'] }, - fallbackParameters: { query: 'myQuery', facetFilters: ['fallback'] }, - }, - ], - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/*/recommendations'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [ - { - indexName: 'indexName', - objectID: 'objectID', - model: 'related-products', - threshold: 42.1, - maxRecommendations: 10, - queryParameters: { query: 'myQuery', facetFilters: ['query'] }, - fallbackParameters: { query: 'myQuery', facetFilters: ['fallback'] }, - }, - ], - }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('get recommendations for trending model with minimal parameters', async () => { - const req = (await client.getRecommendations({ - requests: [ - { indexName: 'indexName', model: 'trending-items', threshold: 42.1, facetName: 'facet', facetValue: 'value' }, - ], - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/*/recommendations'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [ - { indexName: 'indexName', model: 'trending-items', threshold: 42.1, facetName: 'facet', facetValue: 'value' }, - ], - }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('get recommendations for trending model with all parameters', async () => { - const req = (await client.getRecommendations({ - requests: [ - { - indexName: 'indexName', - model: 'trending-items', - threshold: 42.1, - maxRecommendations: 10, - facetName: 'myFacetName', - facetValue: 'myFacetValue', - queryParameters: { query: 'myQuery', facetFilters: ['query'] }, - fallbackParameters: { query: 'myQuery', facetFilters: ['fallback'] }, - }, - ], - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/*/recommendations'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [ - { - indexName: 'indexName', - model: 'trending-items', - threshold: 42.1, - maxRecommendations: 10, - facetName: 'myFacetName', - facetValue: 'myFacetValue', - queryParameters: { query: 'myQuery', facetFilters: ['query'] }, - fallbackParameters: { query: 'myQuery', facetFilters: ['fallback'] }, - }, - ], - }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('get multiple recommendations with minimal parameters', async () => { - const req = (await client.getRecommendations({ - requests: [ - { indexName: 'indexName1', objectID: 'objectID1', model: 'related-products', threshold: 21.7 }, - { indexName: 'indexName2', objectID: 'objectID2', model: 'related-products', threshold: 21.7 }, - ], - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/*/recommendations'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [ - { indexName: 'indexName1', objectID: 'objectID1', model: 'related-products', threshold: 21.7 }, - { indexName: 'indexName2', objectID: 'objectID2', model: 'related-products', threshold: 21.7 }, - ], - }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('get multiple recommendations with all parameters', async () => { - const req = (await client.getRecommendations({ - requests: [ - { - indexName: 'indexName1', - objectID: 'objectID1', - model: 'related-products', - threshold: 21.7, - maxRecommendations: 10, - queryParameters: { query: 'myQuery', facetFilters: ['query1'] }, - fallbackParameters: { query: 'myQuery', facetFilters: ['fallback1'] }, - }, - { - indexName: 'indexName2', - objectID: 'objectID2', - model: 'related-products', - threshold: 21.7, - maxRecommendations: 10, - queryParameters: { query: 'myQuery', facetFilters: ['query2'] }, - fallbackParameters: { query: 'myQuery', facetFilters: ['fallback2'] }, - }, - ], - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/*/recommendations'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [ - { - indexName: 'indexName1', - objectID: 'objectID1', - model: 'related-products', - threshold: 21.7, - maxRecommendations: 10, - queryParameters: { query: 'myQuery', facetFilters: ['query1'] }, - fallbackParameters: { query: 'myQuery', facetFilters: ['fallback1'] }, - }, - { - indexName: 'indexName2', - objectID: 'objectID2', - model: 'related-products', - threshold: 21.7, - maxRecommendations: 10, - queryParameters: { query: 'myQuery', facetFilters: ['query2'] }, - fallbackParameters: { query: 'myQuery', facetFilters: ['fallback2'] }, - }, - ], - }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('get frequently bought together recommendations', async () => { - const req = (await client.getRecommendations({ - requests: [{ indexName: 'indexName1', objectID: 'objectID1', model: 'bought-together', threshold: 42.7 }], - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/*/recommendations'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [{ indexName: 'indexName1', objectID: 'objectID1', model: 'bought-together', threshold: 42.7 }], - }); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('search', () => { - test('withHitsPerPage', async () => { - const req = (await client.search({ - requests: [{ indexName: '', query: '', hitsPerPage: 50 }], - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/*/queries'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [{ indexName: '', query: '', hitsPerPage: 50 }], - }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('filterOnly', async () => { - const req = (await client.search({ - requests: [{ indexName: '', query: '', filters: 'actor:Scarlett Johansson' }], - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/*/queries'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [{ indexName: '', query: '', filters: 'actor:Scarlett Johansson' }], - }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('filterOr', async () => { - const req = (await client.search({ - requests: [ - { - indexName: '', - query: '', - filters: 'actor:Tom Cruise OR actor:Scarlett Johansson', - }, - ], - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/*/queries'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [ - { - indexName: '', - query: '', - filters: 'actor:Tom Cruise OR actor:Scarlett Johansson', - }, - ], - }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('filterNot', async () => { - const req = (await client.search({ - requests: [{ indexName: '', query: '', filters: 'NOT actor:Nicolas Cage' }], - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/*/queries'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [{ indexName: '', query: '', filters: 'NOT actor:Nicolas Cage' }], - }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('search for a single hits request with minimal parameters', async () => { - const req = (await client.search({ - requests: [{ indexName: 'cts_e2e_search_empty_index' }], - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/*/queries'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ requests: [{ indexName: 'cts_e2e_search_empty_index' }] }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('search with highlight and snippet results', async () => { - const req = (await client.search({ - requests: [ - { - indexName: 'cts_e2e_highlight_snippet_results', - query: 'vim', - attributesToSnippet: ['*:20'], - attributesToHighlight: ['*'], - attributesToRetrieve: ['*'], - }, - ], - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/*/queries'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [ - { - indexName: 'cts_e2e_highlight_snippet_results', - query: 'vim', - attributesToSnippet: ['*:20'], - attributesToHighlight: ['*'], - attributesToRetrieve: ['*'], - }, - ], - }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('retrieveFacets', async () => { - const req = (await client.search({ - requests: [{ indexName: '', query: '', facets: ['author', 'genre'] }], - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/*/queries'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [{ indexName: '', query: '', facets: ['author', 'genre'] }], - }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('retrieveFacetsWildcard', async () => { - const req = (await client.search({ - requests: [{ indexName: '', query: '', facets: ['*'] }], - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/*/queries'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ requests: [{ indexName: '', query: '', facets: ['*'] }] }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('search for a single facet request with minimal parameters', async () => { - const req = (await client.search({ - requests: [{ indexName: 'cts_e2e_search_facet', type: 'facet', facet: 'editor' }], - strategy: 'stopIfEnoughMatches', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/*/queries'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [{ indexName: 'cts_e2e_search_facet', type: 'facet', facet: 'editor' }], - strategy: 'stopIfEnoughMatches', - }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('search for a single hits request with all parameters', async () => { - const req = (await client.search({ - requests: [{ indexName: 'theIndexName', query: 'myQuery', hitsPerPage: 50, type: 'default' }], - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/*/queries'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [{ indexName: 'theIndexName', query: 'myQuery', hitsPerPage: 50, type: 'default' }], - }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('search for a single facet request with all parameters', async () => { - const req = (await client.search({ - requests: [ - { - indexName: 'theIndexName', - type: 'facet', - facet: 'theFacet', - facetQuery: 'theFacetQuery', - query: 'theQuery', - maxFacetHits: 50, - }, - ], - strategy: 'stopIfEnoughMatches', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/*/queries'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [ - { - indexName: 'theIndexName', - type: 'facet', - facet: 'theFacet', - facetQuery: 'theFacetQuery', - query: 'theQuery', - maxFacetHits: 50, - }, - ], - strategy: 'stopIfEnoughMatches', - }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('search for multiple mixed requests in multiple indices with minimal parameters', async () => { - const req = (await client.search({ - requests: [ - { indexName: 'theIndexName' }, - { indexName: 'theIndexName2', type: 'facet', facet: 'theFacet' }, - { indexName: 'theIndexName', type: 'default' }, - ], - strategy: 'stopIfEnoughMatches', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/*/queries'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [ - { indexName: 'theIndexName' }, - { indexName: 'theIndexName2', type: 'facet', facet: 'theFacet' }, - { indexName: 'theIndexName', type: 'default' }, - ], - strategy: 'stopIfEnoughMatches', - }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('search for multiple mixed requests in multiple indices with all parameters', async () => { - const req = (await client.search({ - requests: [ - { - indexName: 'theIndexName', - type: 'facet', - facet: 'theFacet', - facetQuery: 'theFacetQuery', - query: 'theQuery', - maxFacetHits: 50, - }, - { indexName: 'theIndexName', query: 'myQuery', hitsPerPage: 50, type: 'default' }, - ], - strategy: 'stopIfEnoughMatches', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/*/queries'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [ - { - indexName: 'theIndexName', - type: 'facet', - facet: 'theFacet', - facetQuery: 'theFacetQuery', - query: 'theQuery', - maxFacetHits: 50, - }, - { indexName: 'theIndexName', query: 'myQuery', hitsPerPage: 50, type: 'default' }, - ], - strategy: 'stopIfEnoughMatches', - }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('search filters accept all of the possible shapes', async () => { - const req = (await client.search({ - requests: [ - { - indexName: 'theIndexName', - facetFilters: 'mySearch:filters', - reRankingApplyFilter: 'mySearch:filters', - tagFilters: 'mySearch:filters', - numericFilters: 'mySearch:filters', - optionalFilters: 'mySearch:filters', - }, - { - indexName: 'theIndexName', - facetFilters: ['mySearch:filters', ['mySearch:filters', ['mySearch:filters']]], - reRankingApplyFilter: ['mySearch:filters', ['mySearch:filters']], - tagFilters: ['mySearch:filters', ['mySearch:filters']], - numericFilters: ['mySearch:filters', ['mySearch:filters']], - optionalFilters: ['mySearch:filters', ['mySearch:filters']], - }, - ], - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/*/queries'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [ - { - indexName: 'theIndexName', - facetFilters: 'mySearch:filters', - reRankingApplyFilter: 'mySearch:filters', - tagFilters: 'mySearch:filters', - numericFilters: 'mySearch:filters', - optionalFilters: 'mySearch:filters', - }, - { - indexName: 'theIndexName', - facetFilters: ['mySearch:filters', ['mySearch:filters', ['mySearch:filters']]], - reRankingApplyFilter: ['mySearch:filters', ['mySearch:filters']], - tagFilters: ['mySearch:filters', ['mySearch:filters']], - numericFilters: ['mySearch:filters', ['mySearch:filters']], - optionalFilters: ['mySearch:filters', ['mySearch:filters']], - }, - ], - }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('search filters end to end', async () => { - const req = (await client.search({ - requests: [ - { indexName: 'cts_e2e_search_facet', filters: "editor:'visual studio' OR editor:neovim" }, - { indexName: 'cts_e2e_search_facet', facetFilters: ["editor:'visual studio'", 'editor:neovim'] }, - { indexName: 'cts_e2e_search_facet', facetFilters: ["editor:'visual studio'", ['editor:neovim']] }, - { - indexName: 'cts_e2e_search_facet', - facetFilters: ["editor:'visual studio'", ['editor:neovim', ['editor:goland']]], - }, - ], - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/*/queries'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [ - { indexName: 'cts_e2e_search_facet', filters: "editor:'visual studio' OR editor:neovim" }, - { indexName: 'cts_e2e_search_facet', facetFilters: ["editor:'visual studio'", 'editor:neovim'] }, - { indexName: 'cts_e2e_search_facet', facetFilters: ["editor:'visual studio'", ['editor:neovim']] }, - { - indexName: 'cts_e2e_search_facet', - facetFilters: ["editor:'visual studio'", ['editor:neovim', ['editor:goland']]], - }, - ], - }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('search with all search parameters', async () => { - const req = (await client.search({ - requests: [ - { - advancedSyntax: true, - advancedSyntaxFeatures: ['exactPhrase'], - allowTyposOnNumericTokens: true, - alternativesAsExact: ['multiWordsSynonym'], - analytics: true, - analyticsTags: [''], - aroundLatLng: '', - aroundLatLngViaIP: true, - aroundPrecision: 0, - aroundRadius: 'all', - attributeCriteriaComputedByMinProximity: true, - attributesToHighlight: [''], - attributesToRetrieve: [''], - attributesToSnippet: [''], - clickAnalytics: true, - customRanking: [''], - decompoundQuery: true, - disableExactOnAttributes: [''], - disableTypoToleranceOnAttributes: [''], - distinct: 0, - enableABTest: true, - enablePersonalization: true, - enableReRanking: true, - enableRules: true, - exactOnSingleWordQuery: 'attribute', - facetFilters: [''], - facetingAfterDistinct: true, - facets: [''], - filters: '', - getRankingInfo: true, - highlightPostTag: '', - highlightPreTag: '', - hitsPerPage: 1, - ignorePlurals: false, - indexName: 'theIndexName', - insideBoundingBox: [ - [47.3165, 4.9665, 47.3424, 5.0201], - [40.9234, 2.1185, 38.643, 1.9916], - ], - insidePolygon: [ - [47.3165, 4.9665, 47.3424, 5.0201, 47.32, 4.9], - [40.9234, 2.1185, 38.643, 1.9916, 39.2587, 2.0104], - ], - keepDiacriticsOnCharacters: '', - length: 1, - maxValuesPerFacet: 0, - minProximity: 1, - minWordSizefor1Typo: 0, - minWordSizefor2Typos: 0, - minimumAroundRadius: 1, - naturalLanguages: ['fr'], - numericFilters: [''], - offset: 0, - optionalFilters: [''], - optionalWords: [''], - page: 0, - percentileComputation: true, - personalizationImpact: 0, - query: '', - queryLanguages: ['fr'], - queryType: 'prefixAll', - ranking: [''], - reRankingApplyFilter: [''], - relevancyStrictness: 0, - removeStopWords: true, - removeWordsIfNoResults: 'allOptional', - renderingContent: { - facetOrdering: { facets: { order: ['a', 'b'] }, values: { a: { order: ['b'], sortRemainingBy: 'count' } } }, - }, - replaceSynonymsInHighlight: true, - responseFields: [''], - restrictHighlightAndSnippetArrays: true, - restrictSearchableAttributes: [''], - ruleContexts: [''], - similarQuery: '', - snippetEllipsisText: '', - sortFacetValuesBy: '', - sumOrFiltersScores: true, - synonyms: true, - tagFilters: [''], - type: 'default', - typoTolerance: 'min', - userToken: '', - }, - ], - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/*/queries'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [ - { - advancedSyntax: true, - advancedSyntaxFeatures: ['exactPhrase'], - allowTyposOnNumericTokens: true, - alternativesAsExact: ['multiWordsSynonym'], - analytics: true, - analyticsTags: [''], - aroundLatLng: '', - aroundLatLngViaIP: true, - aroundPrecision: 0, - aroundRadius: 'all', - attributeCriteriaComputedByMinProximity: true, - attributesToHighlight: [''], - attributesToRetrieve: [''], - attributesToSnippet: [''], - clickAnalytics: true, - customRanking: [''], - decompoundQuery: true, - disableExactOnAttributes: [''], - disableTypoToleranceOnAttributes: [''], - distinct: 0, - enableABTest: true, - enablePersonalization: true, - enableReRanking: true, - enableRules: true, - exactOnSingleWordQuery: 'attribute', - facetFilters: [''], - facetingAfterDistinct: true, - facets: [''], - filters: '', - getRankingInfo: true, - highlightPostTag: '', - highlightPreTag: '', - hitsPerPage: 1, - ignorePlurals: false, - indexName: 'theIndexName', - insideBoundingBox: [ - [47.3165, 4.9665, 47.3424, 5.0201], - [40.9234, 2.1185, 38.643, 1.9916], - ], - insidePolygon: [ - [47.3165, 4.9665, 47.3424, 5.0201, 47.32, 4.9], - [40.9234, 2.1185, 38.643, 1.9916, 39.2587, 2.0104], - ], - keepDiacriticsOnCharacters: '', - length: 1, - maxValuesPerFacet: 0, - minProximity: 1, - minWordSizefor1Typo: 0, - minWordSizefor2Typos: 0, - minimumAroundRadius: 1, - naturalLanguages: ['fr'], - numericFilters: [''], - offset: 0, - optionalFilters: [''], - optionalWords: [''], - page: 0, - percentileComputation: true, - personalizationImpact: 0, - query: '', - queryLanguages: ['fr'], - queryType: 'prefixAll', - ranking: [''], - reRankingApplyFilter: [''], - relevancyStrictness: 0, - removeStopWords: true, - removeWordsIfNoResults: 'allOptional', - renderingContent: { - facetOrdering: { facets: { order: ['a', 'b'] }, values: { a: { order: ['b'], sortRemainingBy: 'count' } } }, - }, - replaceSynonymsInHighlight: true, - responseFields: [''], - restrictHighlightAndSnippetArrays: true, - restrictSearchableAttributes: [''], - ruleContexts: [''], - similarQuery: '', - snippetEllipsisText: '', - sortFacetValuesBy: '', - sumOrFiltersScores: true, - synonyms: true, - tagFilters: [''], - type: 'default', - typoTolerance: 'min', - userToken: '', - }, - ], - }); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); diff --git a/tests/output/javascript/src/requests/analytics.test.ts b/tests/output/javascript/src/requests/analytics.test.ts deleted file mode 100644 index f68b9134d40..00000000000 --- a/tests/output/javascript/src/requests/analytics.test.ts +++ /dev/null @@ -1,927 +0,0 @@ -// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. - -import { analyticsClient } from '@algolia/client-analytics'; -import { nodeEchoRequester } from '@algolia/requester-testing'; -import type { EchoResponse } from '@algolia/requester-testing'; -import { describe, test, expect } from 'vitest'; - -const appId = process.env.ALGOLIA_APPLICATION_ID || 'test_app_id'; -const apiKey = process.env.ALGOLIA_SEARCH_KEY || 'test_api_key'; - -const client = analyticsClient(appId, apiKey, 'us', { requester: nodeEchoRequester() }); - -describe('customDelete', () => { - test('allow del method for a custom path with minimal parameters', async () => { - const req = (await client.customDelete({ path: 'test/minimal' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/minimal'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('allow del method for a custom path with all parameters', async () => { - const req = (await client.customDelete({ - path: 'test/all', - parameters: { query: 'parameters' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/all'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ query: 'parameters' }); - }); -}); - -describe('customGet', () => { - test('allow get method for a custom path with minimal parameters', async () => { - const req = (await client.customGet({ path: 'test/minimal' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/minimal'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('allow get method for a custom path with all parameters', async () => { - const req = (await client.customGet({ - path: 'test/all', - parameters: { query: 'parameters with space' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/all'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ query: 'parameters%20with%20space' }); - }); - - test('requestOptions should be escaped too', async () => { - const req = (await client.customGet( - { path: 'test/all', parameters: { query: 'to be overriden' } }, - { - queryParameters: { query: 'parameters with space', 'and an array': ['array', 'with spaces'] }, - headers: { 'x-header-1': 'spaces are left alone' }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/all'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ - query: 'parameters%20with%20space', - 'and%20an%20array': 'array%2Cwith%20spaces', - }); - expect(req.headers).toEqual(expect.objectContaining({ 'x-header-1': 'spaces are left alone' })); - }); -}); - -describe('customPost', () => { - test('allow post method for a custom path with minimal parameters', async () => { - const req = (await client.customPost({ path: 'test/minimal' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/minimal'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({}); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('allow post method for a custom path with all parameters', async () => { - const req = (await client.customPost({ - path: 'test/all', - parameters: { query: 'parameters' }, - body: { body: 'parameters' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/all'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ body: 'parameters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters' }); - }); - - test('requestOptions can override default query parameters', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { query: 'myQueryParameter' }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'myQueryParameter' }); - }); - - test('requestOptions merges query parameters with default ones', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { query2: 'myQueryParameter' }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', query2: 'myQueryParameter' }); - }); - - test('requestOptions can override default headers', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - headers: { 'x-algolia-api-key': 'ALGOLIA_API_KEY' }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters' }); - expect(req.headers).toEqual(expect.objectContaining({ 'x-algolia-api-key': 'ALGOLIA_API_KEY' })); - }); - - test('requestOptions merges headers with default ones', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - headers: { 'x-algolia-api-key': 'ALGOLIA_API_KEY' }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters' }); - expect(req.headers).toEqual(expect.objectContaining({ 'x-algolia-api-key': 'ALGOLIA_API_KEY' })); - }); - - test('requestOptions queryParameters accepts booleans', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { isItWorking: true }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', isItWorking: 'true' }); - }); - - test('requestOptions queryParameters accepts integers', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { myParam: 2 }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', myParam: '2' }); - }); - - test('requestOptions queryParameters accepts list of string', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { myParam: ['b and c', 'd'] }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', myParam: 'b%20and%20c%2Cd' }); - }); - - test('requestOptions queryParameters accepts list of booleans', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { myParam: [true, true, false] }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', myParam: 'true%2Ctrue%2Cfalse' }); - }); - - test('requestOptions queryParameters accepts list of integers', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { myParam: [1, 2] }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', myParam: '1%2C2' }); - }); -}); - -describe('customPut', () => { - test('allow put method for a custom path with minimal parameters', async () => { - const req = (await client.customPut({ path: 'test/minimal' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/minimal'); - expect(req.method).toEqual('PUT'); - expect(req.data).toEqual({}); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('allow put method for a custom path with all parameters', async () => { - const req = (await client.customPut({ - path: 'test/all', - parameters: { query: 'parameters' }, - body: { body: 'parameters' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/all'); - expect(req.method).toEqual('PUT'); - expect(req.data).toEqual({ body: 'parameters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters' }); - }); -}); - -describe('getAddToCartRate', () => { - test('get getAddToCartRate with minimal parameters', async () => { - const req = (await client.getAddToCartRate({ index: 'index' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/conversions/addToCartRate'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ index: 'index' }); - }); - - test('get getAddToCartRate with all parameters', async () => { - const req = (await client.getAddToCartRate({ - index: 'index', - startDate: '1999-09-19', - endDate: '2001-01-01', - tags: 'tag', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/conversions/addToCartRate'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ - index: 'index', - startDate: '1999-09-19', - endDate: '2001-01-01', - tags: 'tag', - }); - }); -}); - -describe('getAverageClickPosition', () => { - test('get getAverageClickPosition with minimal parameters', async () => { - const req = (await client.getAverageClickPosition({ index: 'index' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/clicks/averageClickPosition'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ index: 'index' }); - }); - - test('get getAverageClickPosition with all parameters', async () => { - const req = (await client.getAverageClickPosition({ - index: 'index', - startDate: '1999-09-19', - endDate: '2001-01-01', - tags: 'tag', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/clicks/averageClickPosition'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ - index: 'index', - startDate: '1999-09-19', - endDate: '2001-01-01', - tags: 'tag', - }); - }); -}); - -describe('getClickPositions', () => { - test('get getClickPositions with minimal parameters', async () => { - const req = (await client.getClickPositions({ index: 'index' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/clicks/positions'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ index: 'index' }); - }); - - test('get getClickPositions with all parameters', async () => { - const req = (await client.getClickPositions({ - index: 'index', - startDate: '1999-09-19', - endDate: '2001-01-01', - tags: 'tag', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/clicks/positions'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ - index: 'index', - startDate: '1999-09-19', - endDate: '2001-01-01', - tags: 'tag', - }); - }); -}); - -describe('getClickThroughRate', () => { - test('get getClickThroughRate with minimal parameters', async () => { - const req = (await client.getClickThroughRate({ index: 'index' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/clicks/clickThroughRate'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ index: 'index' }); - }); - - test('get getClickThroughRate with all parameters', async () => { - const req = (await client.getClickThroughRate({ - index: 'index', - startDate: '1999-09-19', - endDate: '2001-01-01', - tags: 'tag', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/clicks/clickThroughRate'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ - index: 'index', - startDate: '1999-09-19', - endDate: '2001-01-01', - tags: 'tag', - }); - }); -}); - -describe('getConversionRate', () => { - test('get getConversationRate with minimal parameters', async () => { - const req = (await client.getConversionRate({ index: 'index' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/conversions/conversionRate'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ index: 'index' }); - }); - - test('get getConversationRate with all parameters', async () => { - const req = (await client.getConversionRate({ - index: 'index', - startDate: '1999-09-19', - endDate: '2001-01-01', - tags: 'tag', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/conversions/conversionRate'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ - index: 'index', - startDate: '1999-09-19', - endDate: '2001-01-01', - tags: 'tag', - }); - }); -}); - -describe('getNoClickRate', () => { - test('get getNoClickRate with minimal parameters', async () => { - const req = (await client.getNoClickRate({ index: 'index' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/searches/noClickRate'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ index: 'index' }); - }); - - test('get getNoClickRate with all parameters', async () => { - const req = (await client.getNoClickRate({ - index: 'index', - startDate: '1999-09-19', - endDate: '2001-01-01', - tags: 'tag', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/searches/noClickRate'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ - index: 'index', - startDate: '1999-09-19', - endDate: '2001-01-01', - tags: 'tag', - }); - }); -}); - -describe('getNoResultsRate', () => { - test('get getNoResultsRate with minimal parameters', async () => { - const req = (await client.getNoResultsRate({ index: 'index' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/searches/noResultRate'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ index: 'index' }); - }); - - test('get getNoResultsRate with all parameters', async () => { - const req = (await client.getNoResultsRate({ - index: 'index', - startDate: '1999-09-19', - endDate: '2001-01-01', - tags: 'tag', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/searches/noResultRate'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ - index: 'index', - startDate: '1999-09-19', - endDate: '2001-01-01', - tags: 'tag', - }); - }); -}); - -describe('getPurchaseRate', () => { - test('get getPurchaseRate with minimal parameters', async () => { - const req = (await client.getPurchaseRate({ index: 'index' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/conversions/purchaseRate'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ index: 'index' }); - }); - - test('get getPurchaseRate with all parameters', async () => { - const req = (await client.getPurchaseRate({ - index: 'index', - startDate: '1999-09-19', - endDate: '2001-01-01', - tags: 'tag', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/conversions/purchaseRate'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ - index: 'index', - startDate: '1999-09-19', - endDate: '2001-01-01', - tags: 'tag', - }); - }); -}); - -describe('getRevenue', () => { - test('get getRevenue with minimal parameters', async () => { - const req = (await client.getRevenue({ index: 'index' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/conversions/revenue'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ index: 'index' }); - }); - - test('get getRevenue with all parameters', async () => { - const req = (await client.getRevenue({ - index: 'index', - startDate: '1999-09-19', - endDate: '2001-01-01', - tags: 'tag', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/conversions/revenue'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ - index: 'index', - startDate: '1999-09-19', - endDate: '2001-01-01', - tags: 'tag', - }); - }); -}); - -describe('getSearchesCount', () => { - test('get getSearchesCount with minimal parameters', async () => { - const req = (await client.getSearchesCount({ index: 'index' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/searches/count'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ index: 'index' }); - }); - - test('get getSearchesCount with all parameters', async () => { - const req = (await client.getSearchesCount({ - index: 'index', - startDate: '1999-09-19', - endDate: '2001-01-01', - tags: 'tag', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/searches/count'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ - index: 'index', - startDate: '1999-09-19', - endDate: '2001-01-01', - tags: 'tag', - }); - }); -}); - -describe('getSearchesNoClicks', () => { - test('get getSearchesNoClicks with minimal parameters', async () => { - const req = (await client.getSearchesNoClicks({ index: 'index' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/searches/noClicks'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ index: 'index' }); - }); - - test('get getSearchesNoClicks with all parameters', async () => { - const req = (await client.getSearchesNoClicks({ - index: 'index', - startDate: '1999-09-19', - endDate: '2001-01-01', - limit: 21, - offset: 42, - tags: 'tag', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/searches/noClicks'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ - index: 'index', - startDate: '1999-09-19', - endDate: '2001-01-01', - limit: '21', - offset: '42', - tags: 'tag', - }); - }); -}); - -describe('getSearchesNoResults', () => { - test('get getSearchesNoResults with minimal parameters', async () => { - const req = (await client.getSearchesNoResults({ index: 'index' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/searches/noResults'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ index: 'index' }); - }); - - test('get getSearchesNoResults with all parameters', async () => { - const req = (await client.getSearchesNoResults({ - index: 'index', - startDate: '1999-09-19', - endDate: '2001-01-01', - limit: 21, - offset: 42, - tags: 'tag', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/searches/noResults'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ - index: 'index', - startDate: '1999-09-19', - endDate: '2001-01-01', - limit: '21', - offset: '42', - tags: 'tag', - }); - }); -}); - -describe('getStatus', () => { - test('get getStatus with minimal parameters', async () => { - const req = (await client.getStatus({ index: 'index' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/status'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ index: 'index' }); - }); -}); - -describe('getTopCountries', () => { - test('get getTopCountries with minimal parameters', async () => { - const req = (await client.getTopCountries({ index: 'index' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/countries'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ index: 'index' }); - }); - - test('get getTopCountries with all parameters', async () => { - const req = (await client.getTopCountries({ - index: 'index', - startDate: '1999-09-19', - endDate: '2001-01-01', - limit: 21, - offset: 42, - tags: 'tag', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/countries'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ - index: 'index', - startDate: '1999-09-19', - endDate: '2001-01-01', - limit: '21', - offset: '42', - tags: 'tag', - }); - }); -}); - -describe('getTopFilterAttributes', () => { - test('get getTopFilterAttributes with minimal parameters', async () => { - const req = (await client.getTopFilterAttributes({ index: 'index' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/filters'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ index: 'index' }); - }); - - test('get getTopFilterAttributes with all parameters', async () => { - const req = (await client.getTopFilterAttributes({ - index: 'index', - search: 'mySearch', - startDate: '1999-09-19', - endDate: '2001-01-01', - limit: 21, - offset: 42, - tags: 'tag', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/filters'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ - index: 'index', - search: 'mySearch', - startDate: '1999-09-19', - endDate: '2001-01-01', - limit: '21', - offset: '42', - tags: 'tag', - }); - }); -}); - -describe('getTopFilterForAttribute', () => { - test('get getTopFilterForAttribute with minimal parameters', async () => { - const req = (await client.getTopFilterForAttribute({ - attribute: 'myAttribute', - index: 'index', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/filters/myAttribute'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ index: 'index' }); - }); - - test('get getTopFilterForAttribute with minimal parameters and multiple attributes', async () => { - const req = (await client.getTopFilterForAttribute({ - attribute: 'myAttribute1,myAttribute2', - index: 'index', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/filters/myAttribute1%2CmyAttribute2'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ index: 'index' }); - }); - - test('get getTopFilterForAttribute with all parameters', async () => { - const req = (await client.getTopFilterForAttribute({ - attribute: 'myAttribute', - index: 'index', - search: 'mySearch', - startDate: '1999-09-19', - endDate: '2001-01-01', - limit: 21, - offset: 42, - tags: 'tag', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/filters/myAttribute'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ - index: 'index', - search: 'mySearch', - startDate: '1999-09-19', - endDate: '2001-01-01', - limit: '21', - offset: '42', - tags: 'tag', - }); - }); - - test('get getTopFilterForAttribute with all parameters and multiple attributes', async () => { - const req = (await client.getTopFilterForAttribute({ - attribute: 'myAttribute1,myAttribute2', - index: 'index', - search: 'mySearch', - startDate: '1999-09-19', - endDate: '2001-01-01', - limit: 21, - offset: 42, - tags: 'tag', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/filters/myAttribute1%2CmyAttribute2'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ - index: 'index', - search: 'mySearch', - startDate: '1999-09-19', - endDate: '2001-01-01', - limit: '21', - offset: '42', - tags: 'tag', - }); - }); -}); - -describe('getTopFiltersNoResults', () => { - test('get getTopFiltersNoResults with minimal parameters', async () => { - const req = (await client.getTopFiltersNoResults({ index: 'index' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/filters/noResults'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ index: 'index' }); - }); - - test('get getTopFiltersNoResults with all parameters', async () => { - const req = (await client.getTopFiltersNoResults({ - index: 'index', - search: 'mySearch', - startDate: '1999-09-19', - endDate: '2001-01-01', - limit: 21, - offset: 42, - tags: 'tag', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/filters/noResults'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ - index: 'index', - search: 'mySearch', - startDate: '1999-09-19', - endDate: '2001-01-01', - limit: '21', - offset: '42', - tags: 'tag', - }); - }); -}); - -describe('getTopHits', () => { - test('get getTopHits with minimal parameters', async () => { - const req = (await client.getTopHits({ index: 'index' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/hits'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ index: 'index' }); - }); - - test('get getTopHits with all parameters', async () => { - const req = (await client.getTopHits({ - index: 'index', - search: 'mySearch', - clickAnalytics: true, - revenueAnalytics: true, - startDate: '1999-09-19', - endDate: '2001-01-01', - limit: 21, - offset: 42, - tags: 'tag', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/hits'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ - index: 'index', - search: 'mySearch', - clickAnalytics: 'true', - revenueAnalytics: 'true', - startDate: '1999-09-19', - endDate: '2001-01-01', - limit: '21', - offset: '42', - tags: 'tag', - }); - }); -}); - -describe('getTopSearches', () => { - test('get getTopSearches with minimal parameters', async () => { - const req = (await client.getTopSearches({ index: 'index' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/searches'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ index: 'index' }); - }); - - test('get getTopSearches with all parameters', async () => { - const req = (await client.getTopSearches({ - index: 'index', - clickAnalytics: true, - revenueAnalytics: true, - startDate: '1999-09-19', - endDate: '2001-01-01', - orderBy: 'searchCount', - direction: 'asc', - limit: 21, - offset: 42, - tags: 'tag', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/searches'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ - index: 'index', - clickAnalytics: 'true', - revenueAnalytics: 'true', - startDate: '1999-09-19', - endDate: '2001-01-01', - orderBy: 'searchCount', - direction: 'asc', - limit: '21', - offset: '42', - tags: 'tag', - }); - }); -}); - -describe('getUsersCount', () => { - test('get getUsersCount with minimal parameters', async () => { - const req = (await client.getUsersCount({ index: 'index' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/users/count'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ index: 'index' }); - }); - - test('get getUsersCount with all parameters', async () => { - const req = (await client.getUsersCount({ - index: 'index', - startDate: '1999-09-19', - endDate: '2001-01-01', - tags: 'tag', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/users/count'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ - index: 'index', - startDate: '1999-09-19', - endDate: '2001-01-01', - tags: 'tag', - }); - }); -}); diff --git a/tests/output/javascript/src/requests/insights.test.ts b/tests/output/javascript/src/requests/insights.test.ts deleted file mode 100644 index 0d7b1b94edd..00000000000 --- a/tests/output/javascript/src/requests/insights.test.ts +++ /dev/null @@ -1,469 +0,0 @@ -// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -import { insightsClient } from '@algolia/client-insights'; -import { nodeEchoRequester } from '@algolia/requester-testing'; -import type { EchoResponse } from '@algolia/requester-testing'; -import { describe, test, expect } from 'vitest'; - -const appId = process.env.ALGOLIA_APPLICATION_ID || 'test_app_id'; -const apiKey = process.env.ALGOLIA_SEARCH_KEY || 'test_api_key'; - -const client = insightsClient(appId, apiKey, 'us', { requester: nodeEchoRequester() }); - -describe('customDelete', () => { - test('allow del method for a custom path with minimal parameters', async () => { - const req = (await client.customDelete({ path: 'test/minimal' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/minimal'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('allow del method for a custom path with all parameters', async () => { - const req = (await client.customDelete({ - path: 'test/all', - parameters: { query: 'parameters' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/all'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ query: 'parameters' }); - }); -}); - -describe('customGet', () => { - test('allow get method for a custom path with minimal parameters', async () => { - const req = (await client.customGet({ path: 'test/minimal' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/minimal'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('allow get method for a custom path with all parameters', async () => { - const req = (await client.customGet({ - path: 'test/all', - parameters: { query: 'parameters with space' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/all'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ query: 'parameters%20with%20space' }); - }); - - test('requestOptions should be escaped too', async () => { - const req = (await client.customGet( - { path: 'test/all', parameters: { query: 'to be overriden' } }, - { - queryParameters: { query: 'parameters with space', 'and an array': ['array', 'with spaces'] }, - headers: { 'x-header-1': 'spaces are left alone' }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/all'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ - query: 'parameters%20with%20space', - 'and%20an%20array': 'array%2Cwith%20spaces', - }); - expect(req.headers).toEqual(expect.objectContaining({ 'x-header-1': 'spaces are left alone' })); - }); -}); - -describe('customPost', () => { - test('allow post method for a custom path with minimal parameters', async () => { - const req = (await client.customPost({ path: 'test/minimal' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/minimal'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({}); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('allow post method for a custom path with all parameters', async () => { - const req = (await client.customPost({ - path: 'test/all', - parameters: { query: 'parameters' }, - body: { body: 'parameters' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/all'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ body: 'parameters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters' }); - }); - - test('requestOptions can override default query parameters', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { query: 'myQueryParameter' }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'myQueryParameter' }); - }); - - test('requestOptions merges query parameters with default ones', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { query2: 'myQueryParameter' }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', query2: 'myQueryParameter' }); - }); - - test('requestOptions can override default headers', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - headers: { 'x-algolia-api-key': 'ALGOLIA_API_KEY' }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters' }); - expect(req.headers).toEqual(expect.objectContaining({ 'x-algolia-api-key': 'ALGOLIA_API_KEY' })); - }); - - test('requestOptions merges headers with default ones', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - headers: { 'x-algolia-api-key': 'ALGOLIA_API_KEY' }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters' }); - expect(req.headers).toEqual(expect.objectContaining({ 'x-algolia-api-key': 'ALGOLIA_API_KEY' })); - }); - - test('requestOptions queryParameters accepts booleans', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { isItWorking: true }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', isItWorking: 'true' }); - }); - - test('requestOptions queryParameters accepts integers', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { myParam: 2 }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', myParam: '2' }); - }); - - test('requestOptions queryParameters accepts list of string', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { myParam: ['b and c', 'd'] }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', myParam: 'b%20and%20c%2Cd' }); - }); - - test('requestOptions queryParameters accepts list of booleans', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { myParam: [true, true, false] }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', myParam: 'true%2Ctrue%2Cfalse' }); - }); - - test('requestOptions queryParameters accepts list of integers', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { myParam: [1, 2] }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', myParam: '1%2C2' }); - }); -}); - -describe('customPut', () => { - test('allow put method for a custom path with minimal parameters', async () => { - const req = (await client.customPut({ path: 'test/minimal' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/minimal'); - expect(req.method).toEqual('PUT'); - expect(req.data).toEqual({}); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('allow put method for a custom path with all parameters', async () => { - const req = (await client.customPut({ - path: 'test/all', - parameters: { query: 'parameters' }, - body: { body: 'parameters' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/all'); - expect(req.method).toEqual('PUT'); - expect(req.data).toEqual({ body: 'parameters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters' }); - }); -}); - -describe('deleteUserToken', () => { - test('deleteUserToken', async () => { - const req = (await client.deleteUserToken({ userToken: 'test-user-1' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/usertokens/test-user-1'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('pushEvents', () => { - test('pushEvents', async () => { - const req = (await client.pushEvents({ - events: [ - { - eventType: 'click', - eventName: 'Product Clicked', - index: 'products', - userToken: 'user-123456', - authenticatedUserToken: 'user-123456', - timestamp: 1641290601962, - objectIDs: ['9780545139700', '9780439784542'], - queryID: '43b15df305339e827f0ac0bdc5ebcaa7', - positions: [7, 6], - }, - ], - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/events'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - events: [ - { - eventType: 'click', - eventName: 'Product Clicked', - index: 'products', - userToken: 'user-123456', - authenticatedUserToken: 'user-123456', - timestamp: 1641290601962, - objectIDs: ['9780545139700', '9780439784542'], - queryID: '43b15df305339e827f0ac0bdc5ebcaa7', - positions: [7, 6], - }, - ], - }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('Many events type', async () => { - const req = (await client.pushEvents({ - events: [ - { - eventType: 'conversion', - eventName: 'Product Purchased', - index: 'products', - userToken: 'user-123456', - authenticatedUserToken: 'user-123456', - timestamp: 1727049600000, - objectIDs: ['9780545139700', '9780439784542'], - queryID: '43b15df305339e827f0ac0bdc5ebcaa7', - }, - { - eventType: 'view', - eventName: 'Product Detail Page Viewed', - index: 'products', - userToken: 'user-123456', - authenticatedUserToken: 'user-123456', - timestamp: 1727049600000, - objectIDs: ['9780545139700', '9780439784542'], - }, - ], - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/events'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - events: [ - { - eventType: 'conversion', - eventName: 'Product Purchased', - index: 'products', - userToken: 'user-123456', - authenticatedUserToken: 'user-123456', - timestamp: 1727049600000, - objectIDs: ['9780545139700', '9780439784542'], - queryID: '43b15df305339e827f0ac0bdc5ebcaa7', - }, - { - eventType: 'view', - eventName: 'Product Detail Page Viewed', - index: 'products', - userToken: 'user-123456', - authenticatedUserToken: 'user-123456', - timestamp: 1727049600000, - objectIDs: ['9780545139700', '9780439784542'], - }, - ], - }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('ConvertedObjectIDsAfterSearch', async () => { - const req = (await client.pushEvents({ - events: [ - { - eventType: 'conversion', - eventName: 'Product Purchased', - index: 'products', - userToken: 'user-123456', - authenticatedUserToken: 'user-123456', - timestamp: 1641290601962, - objectIDs: ['9780545139700', '9780439784542'], - queryID: '43b15df305339e827f0ac0bdc5ebcaa7', - }, - ], - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/events'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - events: [ - { - eventType: 'conversion', - eventName: 'Product Purchased', - index: 'products', - userToken: 'user-123456', - authenticatedUserToken: 'user-123456', - timestamp: 1641290601962, - objectIDs: ['9780545139700', '9780439784542'], - queryID: '43b15df305339e827f0ac0bdc5ebcaa7', - }, - ], - }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('ViewedObjectIDs', async () => { - const req = (await client.pushEvents({ - events: [ - { - eventType: 'view', - eventName: 'Product Detail Page Viewed', - index: 'products', - userToken: 'user-123456', - authenticatedUserToken: 'user-123456', - timestamp: 1641290601962, - objectIDs: ['9780545139700', '9780439784542'], - }, - ], - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/events'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - events: [ - { - eventType: 'view', - eventName: 'Product Detail Page Viewed', - index: 'products', - userToken: 'user-123456', - authenticatedUserToken: 'user-123456', - timestamp: 1641290601962, - objectIDs: ['9780545139700', '9780439784542'], - }, - ], - }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('AddedToCartObjectIDs', async () => { - const req = (await client.pushEvents({ - events: [ - { - eventType: 'conversion', - eventSubtype: 'addToCart', - eventName: 'Product Added To Cart', - index: 'products', - queryID: '43b15df305339e827f0ac0bdc5ebcaa7', - userToken: 'user-123456', - authenticatedUserToken: 'user-123456', - timestamp: 1641290601962, - objectIDs: ['9780545139700', '9780439784542'], - objectData: [ - { price: 19.99, quantity: 10, discount: 2.5 }, - { price: '8$', quantity: 7, discount: '30%' }, - ], - currency: 'USD', - }, - ], - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/events'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - events: [ - { - eventType: 'conversion', - eventSubtype: 'addToCart', - eventName: 'Product Added To Cart', - index: 'products', - queryID: '43b15df305339e827f0ac0bdc5ebcaa7', - userToken: 'user-123456', - authenticatedUserToken: 'user-123456', - timestamp: 1641290601962, - objectIDs: ['9780545139700', '9780439784542'], - objectData: [ - { price: 19.99, quantity: 10, discount: 2.5 }, - { price: '8$', quantity: 7, discount: '30%' }, - ], - currency: 'USD', - }, - ], - }); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); diff --git a/tests/output/javascript/src/requests/monitoring.test.ts b/tests/output/javascript/src/requests/monitoring.test.ts deleted file mode 100644 index 5efa3b4b4a0..00000000000 --- a/tests/output/javascript/src/requests/monitoring.test.ts +++ /dev/null @@ -1,350 +0,0 @@ -// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -import { monitoringClient } from '@algolia/monitoring'; -import { nodeEchoRequester } from '@algolia/requester-testing'; -import type { EchoResponse } from '@algolia/requester-testing'; -import { describe, test, expect } from 'vitest'; - -const appId = process.env.ALGOLIA_APPLICATION_ID || 'test_app_id'; -const apiKey = process.env.ALGOLIA_SEARCH_KEY || 'test_api_key'; - -const client = monitoringClient(appId, apiKey, { requester: nodeEchoRequester() }); - -describe('customDelete', () => { - test('allow del method for a custom path with minimal parameters', async () => { - const req = (await client.customDelete({ path: 'test/minimal' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/minimal'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('allow del method for a custom path with all parameters', async () => { - const req = (await client.customDelete({ - path: 'test/all', - parameters: { query: 'parameters' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/all'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ query: 'parameters' }); - }); -}); - -describe('customGet', () => { - test('allow get method for a custom path with minimal parameters', async () => { - const req = (await client.customGet({ path: 'test/minimal' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/minimal'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('allow get method for a custom path with all parameters', async () => { - const req = (await client.customGet({ - path: 'test/all', - parameters: { query: 'parameters with space' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/all'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ query: 'parameters%20with%20space' }); - }); - - test('requestOptions should be escaped too', async () => { - const req = (await client.customGet( - { path: 'test/all', parameters: { query: 'to be overriden' } }, - { - queryParameters: { query: 'parameters with space', 'and an array': ['array', 'with spaces'] }, - headers: { 'x-header-1': 'spaces are left alone' }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/all'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ - query: 'parameters%20with%20space', - 'and%20an%20array': 'array%2Cwith%20spaces', - }); - expect(req.headers).toEqual(expect.objectContaining({ 'x-header-1': 'spaces are left alone' })); - }); -}); - -describe('customPost', () => { - test('allow post method for a custom path with minimal parameters', async () => { - const req = (await client.customPost({ path: 'test/minimal' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/minimal'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({}); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('allow post method for a custom path with all parameters', async () => { - const req = (await client.customPost({ - path: 'test/all', - parameters: { query: 'parameters' }, - body: { body: 'parameters' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/all'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ body: 'parameters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters' }); - }); - - test('requestOptions can override default query parameters', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { query: 'myQueryParameter' }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'myQueryParameter' }); - }); - - test('requestOptions merges query parameters with default ones', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { query2: 'myQueryParameter' }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', query2: 'myQueryParameter' }); - }); - - test('requestOptions can override default headers', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - headers: { 'x-algolia-api-key': 'ALGOLIA_API_KEY' }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters' }); - expect(req.headers).toEqual(expect.objectContaining({ 'x-algolia-api-key': 'ALGOLIA_API_KEY' })); - }); - - test('requestOptions merges headers with default ones', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - headers: { 'x-algolia-api-key': 'ALGOLIA_API_KEY' }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters' }); - expect(req.headers).toEqual(expect.objectContaining({ 'x-algolia-api-key': 'ALGOLIA_API_KEY' })); - }); - - test('requestOptions queryParameters accepts booleans', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { isItWorking: true }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', isItWorking: 'true' }); - }); - - test('requestOptions queryParameters accepts integers', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { myParam: 2 }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', myParam: '2' }); - }); - - test('requestOptions queryParameters accepts list of string', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { myParam: ['b and c', 'd'] }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', myParam: 'b%20and%20c%2Cd' }); - }); - - test('requestOptions queryParameters accepts list of booleans', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { myParam: [true, true, false] }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', myParam: 'true%2Ctrue%2Cfalse' }); - }); - - test('requestOptions queryParameters accepts list of integers', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { myParam: [1, 2] }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', myParam: '1%2C2' }); - }); -}); - -describe('customPut', () => { - test('allow put method for a custom path with minimal parameters', async () => { - const req = (await client.customPut({ path: 'test/minimal' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/minimal'); - expect(req.method).toEqual('PUT'); - expect(req.data).toEqual({}); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('allow put method for a custom path with all parameters', async () => { - const req = (await client.customPut({ - path: 'test/all', - parameters: { query: 'parameters' }, - body: { body: 'parameters' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/all'); - expect(req.method).toEqual('PUT'); - expect(req.data).toEqual({ body: 'parameters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters' }); - }); -}); - -describe('getClusterIncidents', () => { - test('getClusterIncidents', async () => { - const req = (await client.getClusterIncidents({ clusters: 'c1-de' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/incidents/c1-de'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('getClusterStatus', () => { - test('getClusterStatus', async () => { - const req = (await client.getClusterStatus({ clusters: 'c1-de' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/status/c1-de'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('getIncidents', () => { - test('getIncidents', async () => { - const req = (await client.getIncidents()) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/incidents'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('getIndexingTime', () => { - test('getIndexingTime', async () => { - const req = (await client.getIndexingTime({ clusters: 'c1-de' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexing/c1-de'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('getLatency', () => { - test('getLatency', async () => { - const req = (await client.getLatency({ clusters: 'c1-de' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/latency/c1-de'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('getMetrics', () => { - test('getMetrics', async () => { - const req = (await client.getMetrics({ metric: 'avg_build_time', period: 'minute' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/infrastructure/avg_build_time/period/minute'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('getReachability', () => { - test('getReachability', async () => { - const req = (await client.getReachability({ clusters: 'c1-de' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/reachability/c1-de/probes'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('getServers', () => { - test('getInventory', async () => { - const req = (await client.getServers()) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/inventory/servers'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('getStatus', () => { - test('getStatus', async () => { - const req = (await client.getStatus()) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/status'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); diff --git a/tests/output/javascript/src/requests/personalization.test.ts b/tests/output/javascript/src/requests/personalization.test.ts deleted file mode 100644 index e1389e19e88..00000000000 --- a/tests/output/javascript/src/requests/personalization.test.ts +++ /dev/null @@ -1,303 +0,0 @@ -// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -import { personalizationClient } from '@algolia/client-personalization'; -import { nodeEchoRequester } from '@algolia/requester-testing'; -import type { EchoResponse } from '@algolia/requester-testing'; -import { describe, test, expect } from 'vitest'; - -const appId = process.env.ALGOLIA_APPLICATION_ID || 'test_app_id'; -const apiKey = process.env.ALGOLIA_SEARCH_KEY || 'test_api_key'; - -const client = personalizationClient(appId, apiKey, 'us', { requester: nodeEchoRequester() }); - -describe('customDelete', () => { - test('allow del method for a custom path with minimal parameters', async () => { - const req = (await client.customDelete({ path: 'test/minimal' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/minimal'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('allow del method for a custom path with all parameters', async () => { - const req = (await client.customDelete({ - path: 'test/all', - parameters: { query: 'parameters' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/all'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ query: 'parameters' }); - }); -}); - -describe('customGet', () => { - test('allow get method for a custom path with minimal parameters', async () => { - const req = (await client.customGet({ path: 'test/minimal' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/minimal'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('allow get method for a custom path with all parameters', async () => { - const req = (await client.customGet({ - path: 'test/all', - parameters: { query: 'parameters with space' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/all'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ query: 'parameters%20with%20space' }); - }); - - test('requestOptions should be escaped too', async () => { - const req = (await client.customGet( - { path: 'test/all', parameters: { query: 'to be overriden' } }, - { - queryParameters: { query: 'parameters with space', 'and an array': ['array', 'with spaces'] }, - headers: { 'x-header-1': 'spaces are left alone' }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/all'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ - query: 'parameters%20with%20space', - 'and%20an%20array': 'array%2Cwith%20spaces', - }); - expect(req.headers).toEqual(expect.objectContaining({ 'x-header-1': 'spaces are left alone' })); - }); -}); - -describe('customPost', () => { - test('allow post method for a custom path with minimal parameters', async () => { - const req = (await client.customPost({ path: 'test/minimal' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/minimal'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({}); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('allow post method for a custom path with all parameters', async () => { - const req = (await client.customPost({ - path: 'test/all', - parameters: { query: 'parameters' }, - body: { body: 'parameters' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/all'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ body: 'parameters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters' }); - }); - - test('requestOptions can override default query parameters', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { query: 'myQueryParameter' }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'myQueryParameter' }); - }); - - test('requestOptions merges query parameters with default ones', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { query2: 'myQueryParameter' }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', query2: 'myQueryParameter' }); - }); - - test('requestOptions can override default headers', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - headers: { 'x-algolia-api-key': 'ALGOLIA_API_KEY' }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters' }); - expect(req.headers).toEqual(expect.objectContaining({ 'x-algolia-api-key': 'ALGOLIA_API_KEY' })); - }); - - test('requestOptions merges headers with default ones', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - headers: { 'x-algolia-api-key': 'ALGOLIA_API_KEY' }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters' }); - expect(req.headers).toEqual(expect.objectContaining({ 'x-algolia-api-key': 'ALGOLIA_API_KEY' })); - }); - - test('requestOptions queryParameters accepts booleans', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { isItWorking: true }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', isItWorking: 'true' }); - }); - - test('requestOptions queryParameters accepts integers', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { myParam: 2 }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', myParam: '2' }); - }); - - test('requestOptions queryParameters accepts list of string', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { myParam: ['b and c', 'd'] }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', myParam: 'b%20and%20c%2Cd' }); - }); - - test('requestOptions queryParameters accepts list of booleans', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { myParam: [true, true, false] }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', myParam: 'true%2Ctrue%2Cfalse' }); - }); - - test('requestOptions queryParameters accepts list of integers', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { myParam: [1, 2] }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', myParam: '1%2C2' }); - }); -}); - -describe('customPut', () => { - test('allow put method for a custom path with minimal parameters', async () => { - const req = (await client.customPut({ path: 'test/minimal' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/minimal'); - expect(req.method).toEqual('PUT'); - expect(req.data).toEqual({}); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('allow put method for a custom path with all parameters', async () => { - const req = (await client.customPut({ - path: 'test/all', - parameters: { query: 'parameters' }, - body: { body: 'parameters' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/all'); - expect(req.method).toEqual('PUT'); - expect(req.data).toEqual({ body: 'parameters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters' }); - }); -}); - -describe('deleteUserProfile', () => { - test('delete deleteUserProfile', async () => { - const req = (await client.deleteUserProfile({ userToken: 'UserToken' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/profiles/UserToken'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('getPersonalizationStrategy', () => { - test('get getPersonalizationStrategy', async () => { - const req = (await client.getPersonalizationStrategy()) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/strategies/personalization'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('getUserTokenProfile', () => { - test('get getUserTokenProfile', async () => { - const req = (await client.getUserTokenProfile({ userToken: 'UserToken' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/profiles/personalization/UserToken'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('setPersonalizationStrategy', () => { - test('set setPersonalizationStrategy', async () => { - const req = (await client.setPersonalizationStrategy({ - eventScoring: [{ score: 42, eventName: 'Algolia', eventType: 'click' }], - facetScoring: [{ score: 42, facetName: 'Event' }], - personalizationImpact: 42, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/strategies/personalization'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - eventScoring: [{ score: 42, eventName: 'Algolia', eventType: 'click' }], - facetScoring: [{ score: 42, facetName: 'Event' }], - personalizationImpact: 42, - }); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); diff --git a/tests/output/javascript/src/requests/querySuggestions.test.ts b/tests/output/javascript/src/requests/querySuggestions.test.ts deleted file mode 100644 index ff0fb7ef7d7..00000000000 --- a/tests/output/javascript/src/requests/querySuggestions.test.ts +++ /dev/null @@ -1,357 +0,0 @@ -// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -import { querySuggestionsClient } from '@algolia/client-query-suggestions'; -import { nodeEchoRequester } from '@algolia/requester-testing'; -import type { EchoResponse } from '@algolia/requester-testing'; -import { describe, test, expect } from 'vitest'; - -const appId = process.env.ALGOLIA_APPLICATION_ID || 'test_app_id'; -const apiKey = process.env.ALGOLIA_SEARCH_KEY || 'test_api_key'; - -const client = querySuggestionsClient(appId, apiKey, 'us', { requester: nodeEchoRequester() }); - -describe('createConfig', () => { - test('createConfig', async () => { - const req = (await client.createConfig({ - indexName: 'theIndexName', - sourceIndices: [ - { indexName: 'testIndex', facets: [{ attribute: 'test' }], generate: [['facetA', 'facetB'], ['facetC']] }, - ], - languages: ['french'], - exclude: ['test'], - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/configs'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - indexName: 'theIndexName', - sourceIndices: [ - { indexName: 'testIndex', facets: [{ attribute: 'test' }], generate: [['facetA', 'facetB'], ['facetC']] }, - ], - languages: ['french'], - exclude: ['test'], - }); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('customDelete', () => { - test('allow del method for a custom path with minimal parameters', async () => { - const req = (await client.customDelete({ path: 'test/minimal' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/minimal'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('allow del method for a custom path with all parameters', async () => { - const req = (await client.customDelete({ - path: 'test/all', - parameters: { query: 'parameters' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/all'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ query: 'parameters' }); - }); -}); - -describe('customGet', () => { - test('allow get method for a custom path with minimal parameters', async () => { - const req = (await client.customGet({ path: 'test/minimal' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/minimal'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('allow get method for a custom path with all parameters', async () => { - const req = (await client.customGet({ - path: 'test/all', - parameters: { query: 'parameters with space' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/all'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ query: 'parameters%20with%20space' }); - }); - - test('requestOptions should be escaped too', async () => { - const req = (await client.customGet( - { path: 'test/all', parameters: { query: 'to be overriden' } }, - { - queryParameters: { query: 'parameters with space', 'and an array': ['array', 'with spaces'] }, - headers: { 'x-header-1': 'spaces are left alone' }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/all'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ - query: 'parameters%20with%20space', - 'and%20an%20array': 'array%2Cwith%20spaces', - }); - expect(req.headers).toEqual(expect.objectContaining({ 'x-header-1': 'spaces are left alone' })); - }); -}); - -describe('customPost', () => { - test('allow post method for a custom path with minimal parameters', async () => { - const req = (await client.customPost({ path: 'test/minimal' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/minimal'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({}); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('allow post method for a custom path with all parameters', async () => { - const req = (await client.customPost({ - path: 'test/all', - parameters: { query: 'parameters' }, - body: { body: 'parameters' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/all'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ body: 'parameters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters' }); - }); - - test('requestOptions can override default query parameters', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { query: 'myQueryParameter' }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'myQueryParameter' }); - }); - - test('requestOptions merges query parameters with default ones', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { query2: 'myQueryParameter' }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', query2: 'myQueryParameter' }); - }); - - test('requestOptions can override default headers', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - headers: { 'x-algolia-api-key': 'ALGOLIA_API_KEY' }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters' }); - expect(req.headers).toEqual(expect.objectContaining({ 'x-algolia-api-key': 'ALGOLIA_API_KEY' })); - }); - - test('requestOptions merges headers with default ones', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - headers: { 'x-algolia-api-key': 'ALGOLIA_API_KEY' }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters' }); - expect(req.headers).toEqual(expect.objectContaining({ 'x-algolia-api-key': 'ALGOLIA_API_KEY' })); - }); - - test('requestOptions queryParameters accepts booleans', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { isItWorking: true }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', isItWorking: 'true' }); - }); - - test('requestOptions queryParameters accepts integers', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { myParam: 2 }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', myParam: '2' }); - }); - - test('requestOptions queryParameters accepts list of string', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { myParam: ['b and c', 'd'] }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', myParam: 'b%20and%20c%2Cd' }); - }); - - test('requestOptions queryParameters accepts list of booleans', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { myParam: [true, true, false] }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', myParam: 'true%2Ctrue%2Cfalse' }); - }); - - test('requestOptions queryParameters accepts list of integers', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { myParam: [1, 2] }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', myParam: '1%2C2' }); - }); -}); - -describe('customPut', () => { - test('allow put method for a custom path with minimal parameters', async () => { - const req = (await client.customPut({ path: 'test/minimal' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/minimal'); - expect(req.method).toEqual('PUT'); - expect(req.data).toEqual({}); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('allow put method for a custom path with all parameters', async () => { - const req = (await client.customPut({ - path: 'test/all', - parameters: { query: 'parameters' }, - body: { body: 'parameters' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/all'); - expect(req.method).toEqual('PUT'); - expect(req.data).toEqual({ body: 'parameters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters' }); - }); -}); - -describe('deleteConfig', () => { - test('deleteConfig', async () => { - const req = (await client.deleteConfig({ indexName: 'theIndexName' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/configs/theIndexName'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('getAllConfigs', () => { - test('getAllConfigs', async () => { - const req = (await client.getAllConfigs()) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/configs'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('getConfig', () => { - test('Retrieve QS config e2e', async () => { - const req = (await client.getConfig({ indexName: 'cts_e2e_browse_query_suggestions' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/configs/cts_e2e_browse_query_suggestions'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('getConfigStatus', () => { - test('getConfigStatus', async () => { - const req = (await client.getConfigStatus({ indexName: 'theIndexName' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/configs/theIndexName/status'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('getLogFile', () => { - test('getLogFile', async () => { - const req = (await client.getLogFile({ indexName: 'theIndexName' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/logs/theIndexName'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('updateConfig', () => { - test('updateConfig', async () => { - const req = (await client.updateConfig({ - indexName: 'theIndexName', - configuration: { - sourceIndices: [ - { indexName: 'testIndex', facets: [{ attribute: 'test' }], generate: [['facetA', 'facetB'], ['facetC']] }, - ], - languages: ['french'], - exclude: ['test'], - }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/configs/theIndexName'); - expect(req.method).toEqual('PUT'); - expect(req.data).toEqual({ - sourceIndices: [ - { indexName: 'testIndex', facets: [{ attribute: 'test' }], generate: [['facetA', 'facetB'], ['facetC']] }, - ], - languages: ['french'], - exclude: ['test'], - }); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); diff --git a/tests/output/javascript/src/requests/recommend.test.ts b/tests/output/javascript/src/requests/recommend.test.ts deleted file mode 100644 index a686ba35a3f..00000000000 --- a/tests/output/javascript/src/requests/recommend.test.ts +++ /dev/null @@ -1,493 +0,0 @@ -// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -import { recommendClient } from '@algolia/recommend'; -import { nodeEchoRequester } from '@algolia/requester-testing'; -import type { EchoResponse } from '@algolia/requester-testing'; -import { describe, test, expect } from 'vitest'; - -const appId = process.env.ALGOLIA_APPLICATION_ID || 'test_app_id'; -const apiKey = process.env.ALGOLIA_SEARCH_KEY || 'test_api_key'; - -const client = recommendClient(appId, apiKey, { requester: nodeEchoRequester() }); - -describe('customDelete', () => { - test('allow del method for a custom path with minimal parameters', async () => { - const req = (await client.customDelete({ path: 'test/minimal' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/minimal'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('allow del method for a custom path with all parameters', async () => { - const req = (await client.customDelete({ - path: 'test/all', - parameters: { query: 'parameters' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/all'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ query: 'parameters' }); - }); -}); - -describe('customGet', () => { - test('allow get method for a custom path with minimal parameters', async () => { - const req = (await client.customGet({ path: 'test/minimal' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/minimal'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('allow get method for a custom path with all parameters', async () => { - const req = (await client.customGet({ - path: 'test/all', - parameters: { query: 'parameters with space' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/all'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ query: 'parameters%20with%20space' }); - }); - - test('requestOptions should be escaped too', async () => { - const req = (await client.customGet( - { path: 'test/all', parameters: { query: 'to be overriden' } }, - { - queryParameters: { query: 'parameters with space', 'and an array': ['array', 'with spaces'] }, - headers: { 'x-header-1': 'spaces are left alone' }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/all'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ - query: 'parameters%20with%20space', - 'and%20an%20array': 'array%2Cwith%20spaces', - }); - expect(req.headers).toEqual(expect.objectContaining({ 'x-header-1': 'spaces are left alone' })); - }); -}); - -describe('customPost', () => { - test('allow post method for a custom path with minimal parameters', async () => { - const req = (await client.customPost({ path: 'test/minimal' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/minimal'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({}); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('allow post method for a custom path with all parameters', async () => { - const req = (await client.customPost({ - path: 'test/all', - parameters: { query: 'parameters' }, - body: { body: 'parameters' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/all'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ body: 'parameters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters' }); - }); - - test('requestOptions can override default query parameters', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { query: 'myQueryParameter' }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'myQueryParameter' }); - }); - - test('requestOptions merges query parameters with default ones', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { query2: 'myQueryParameter' }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', query2: 'myQueryParameter' }); - }); - - test('requestOptions can override default headers', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - headers: { 'x-algolia-api-key': 'ALGOLIA_API_KEY' }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters' }); - expect(req.headers).toEqual(expect.objectContaining({ 'x-algolia-api-key': 'ALGOLIA_API_KEY' })); - }); - - test('requestOptions merges headers with default ones', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - headers: { 'x-algolia-api-key': 'ALGOLIA_API_KEY' }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters' }); - expect(req.headers).toEqual(expect.objectContaining({ 'x-algolia-api-key': 'ALGOLIA_API_KEY' })); - }); - - test('requestOptions queryParameters accepts booleans', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { isItWorking: true }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', isItWorking: 'true' }); - }); - - test('requestOptions queryParameters accepts integers', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { myParam: 2 }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', myParam: '2' }); - }); - - test('requestOptions queryParameters accepts list of string', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { myParam: ['b and c', 'd'] }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', myParam: 'b%20and%20c%2Cd' }); - }); - - test('requestOptions queryParameters accepts list of booleans', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { myParam: [true, true, false] }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', myParam: 'true%2Ctrue%2Cfalse' }); - }); - - test('requestOptions queryParameters accepts list of integers', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { myParam: [1, 2] }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', myParam: '1%2C2' }); - }); -}); - -describe('customPut', () => { - test('allow put method for a custom path with minimal parameters', async () => { - const req = (await client.customPut({ path: 'test/minimal' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/minimal'); - expect(req.method).toEqual('PUT'); - expect(req.data).toEqual({}); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('allow put method for a custom path with all parameters', async () => { - const req = (await client.customPut({ - path: 'test/all', - parameters: { query: 'parameters' }, - body: { body: 'parameters' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/all'); - expect(req.method).toEqual('PUT'); - expect(req.data).toEqual({ body: 'parameters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters' }); - }); -}); - -describe('deleteRecommendRule', () => { - test('deleteRecommendRule', async () => { - const req = (await client.deleteRecommendRule({ - indexName: 'indexName', - model: 'related-products', - objectID: 'objectID', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/indexName/related-products/recommend/rules/objectID'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('getRecommendRule', () => { - test('getRecommendRule', async () => { - const req = (await client.getRecommendRule({ - indexName: 'indexName', - model: 'related-products', - objectID: 'objectID', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/indexName/related-products/recommend/rules/objectID'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('getRecommendStatus', () => { - test('getRecommendStatus', async () => { - const req = (await client.getRecommendStatus({ - indexName: 'indexName', - model: 'related-products', - taskID: 12345, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/indexName/related-products/task/12345'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('getRecommendations', () => { - test('get recommendations for recommend model with minimal parameters', async () => { - const req = (await client.getRecommendations({ - requests: [{ indexName: 'indexName', objectID: 'objectID', model: 'related-products', threshold: 42.1 }], - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/*/recommendations'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [{ indexName: 'indexName', objectID: 'objectID', model: 'related-products', threshold: 42.1 }], - }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('get recommendations for recommend model with all parameters', async () => { - const req = (await client.getRecommendations({ - requests: [ - { - indexName: 'indexName', - objectID: 'objectID', - model: 'related-products', - threshold: 42.1, - maxRecommendations: 10, - queryParameters: { query: 'myQuery', facetFilters: ['query'] }, - fallbackParameters: { query: 'myQuery', facetFilters: ['fallback'] }, - }, - ], - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/*/recommendations'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [ - { - indexName: 'indexName', - objectID: 'objectID', - model: 'related-products', - threshold: 42.1, - maxRecommendations: 10, - queryParameters: { query: 'myQuery', facetFilters: ['query'] }, - fallbackParameters: { query: 'myQuery', facetFilters: ['fallback'] }, - }, - ], - }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('get recommendations for trending model with minimal parameters', async () => { - const req = (await client.getRecommendations({ - requests: [ - { indexName: 'indexName', model: 'trending-items', threshold: 42.1, facetName: 'facet', facetValue: 'value' }, - ], - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/*/recommendations'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [ - { indexName: 'indexName', model: 'trending-items', threshold: 42.1, facetName: 'facet', facetValue: 'value' }, - ], - }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('get recommendations for trending model with all parameters', async () => { - const req = (await client.getRecommendations({ - requests: [ - { - indexName: 'indexName', - model: 'trending-items', - threshold: 42.1, - maxRecommendations: 10, - facetName: 'myFacetName', - facetValue: 'myFacetValue', - queryParameters: { query: 'myQuery', facetFilters: ['query'] }, - fallbackParameters: { query: 'myQuery', facetFilters: ['fallback'] }, - }, - ], - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/*/recommendations'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [ - { - indexName: 'indexName', - model: 'trending-items', - threshold: 42.1, - maxRecommendations: 10, - facetName: 'myFacetName', - facetValue: 'myFacetValue', - queryParameters: { query: 'myQuery', facetFilters: ['query'] }, - fallbackParameters: { query: 'myQuery', facetFilters: ['fallback'] }, - }, - ], - }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('get multiple recommendations with minimal parameters', async () => { - const req = (await client.getRecommendations({ - requests: [ - { indexName: 'indexName1', objectID: 'objectID1', model: 'related-products', threshold: 21.7 }, - { indexName: 'indexName2', objectID: 'objectID2', model: 'related-products', threshold: 21.7 }, - ], - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/*/recommendations'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [ - { indexName: 'indexName1', objectID: 'objectID1', model: 'related-products', threshold: 21.7 }, - { indexName: 'indexName2', objectID: 'objectID2', model: 'related-products', threshold: 21.7 }, - ], - }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('get multiple recommendations with all parameters', async () => { - const req = (await client.getRecommendations({ - requests: [ - { - indexName: 'indexName1', - objectID: 'objectID1', - model: 'related-products', - threshold: 21.7, - maxRecommendations: 10, - queryParameters: { query: 'myQuery', facetFilters: ['query1'] }, - fallbackParameters: { query: 'myQuery', facetFilters: ['fallback1'] }, - }, - { - indexName: 'indexName2', - objectID: 'objectID2', - model: 'related-products', - threshold: 21.7, - maxRecommendations: 10, - queryParameters: { query: 'myQuery', facetFilters: ['query2'] }, - fallbackParameters: { query: 'myQuery', facetFilters: ['fallback2'] }, - }, - ], - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/*/recommendations'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [ - { - indexName: 'indexName1', - objectID: 'objectID1', - model: 'related-products', - threshold: 21.7, - maxRecommendations: 10, - queryParameters: { query: 'myQuery', facetFilters: ['query1'] }, - fallbackParameters: { query: 'myQuery', facetFilters: ['fallback1'] }, - }, - { - indexName: 'indexName2', - objectID: 'objectID2', - model: 'related-products', - threshold: 21.7, - maxRecommendations: 10, - queryParameters: { query: 'myQuery', facetFilters: ['query2'] }, - fallbackParameters: { query: 'myQuery', facetFilters: ['fallback2'] }, - }, - ], - }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('get frequently bought together recommendations', async () => { - const req = (await client.getRecommendations({ - requests: [{ indexName: 'indexName1', objectID: 'objectID1', model: 'bought-together', threshold: 42.7 }], - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/*/recommendations'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [{ indexName: 'indexName1', objectID: 'objectID1', model: 'bought-together', threshold: 42.7 }], - }); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('searchRecommendRules', () => { - test('searchRecommendRules', async () => { - const req = (await client.searchRecommendRules({ - indexName: 'indexName', - model: 'related-products', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/indexName/related-products/recommend/rules/search'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({}); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); diff --git a/tests/output/javascript/src/requests/search.test.ts b/tests/output/javascript/src/requests/search.test.ts deleted file mode 100644 index 8a1c19e79fc..00000000000 --- a/tests/output/javascript/src/requests/search.test.ts +++ /dev/null @@ -1,2320 +0,0 @@ -// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -import { searchClient } from '@algolia/client-search'; -import { nodeEchoRequester } from '@algolia/requester-testing'; -import type { EchoResponse } from '@algolia/requester-testing'; -import { describe, test, expect } from 'vitest'; - -const appId = process.env.ALGOLIA_APPLICATION_ID || 'test_app_id'; -const apiKey = process.env.ALGOLIA_SEARCH_KEY || 'test_api_key'; - -const client = searchClient(appId, apiKey, { requester: nodeEchoRequester() }); - -describe('addApiKey', () => { - test('addApiKey', async () => { - const req = (await client.addApiKey({ - acl: ['search', 'addObject'], - description: 'my new api key', - validity: 300, - maxQueriesPerIPPerHour: 100, - maxHitsPerQuery: 20, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/keys'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - acl: ['search', 'addObject'], - description: 'my new api key', - validity: 300, - maxQueriesPerIPPerHour: 100, - maxHitsPerQuery: 20, - }); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('addOrUpdateObject', () => { - test('addOrUpdateObject', async () => { - const req = (await client.addOrUpdateObject({ - indexName: 'indexName', - objectID: 'uniqueID', - body: { key: 'value' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/indexName/uniqueID'); - expect(req.method).toEqual('PUT'); - expect(req.data).toEqual({ key: 'value' }); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('appendSource', () => { - test('appendSource', async () => { - const req = (await client.appendSource({ - source: 'theSource', - description: 'theDescription', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/security/sources/append'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ source: 'theSource', description: 'theDescription' }); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('assignUserId', () => { - test('assignUserId', async () => { - const req = (await client.assignUserId({ - xAlgoliaUserID: 'userID', - assignUserIdParams: { cluster: 'theCluster' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/clusters/mapping'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ cluster: 'theCluster' }); - expect(req.searchParams).toStrictEqual(undefined); - expect(req.headers).toEqual(expect.objectContaining({ 'x-algolia-user-id': 'userID' })); - }); - - test('it should not encode the userID', async () => { - const req = (await client.assignUserId({ - xAlgoliaUserID: 'user id with spaces', - assignUserIdParams: { cluster: 'cluster with spaces' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/clusters/mapping'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ cluster: 'cluster with spaces' }); - expect(req.searchParams).toStrictEqual(undefined); - expect(req.headers).toEqual(expect.objectContaining({ 'x-algolia-user-id': 'user id with spaces' })); - }); -}); - -describe('batch', () => { - test('addObject', async () => { - const req = (await client.batch({ - indexName: '', - batchWriteParams: { - requests: [ - { action: 'addObject', body: { key: 'bar', foo: '1' } }, - { action: 'addObject', body: { key: 'baz', foo: '2' } }, - ], - }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/%3CYOUR_INDEX_NAME%3E/batch'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [ - { action: 'addObject', body: { key: 'bar', foo: '1' } }, - { action: 'addObject', body: { key: 'baz', foo: '2' } }, - ], - }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('clear', async () => { - const req = (await client.batch({ - indexName: '', - batchWriteParams: { requests: [{ action: 'clear', body: { key: 'value' } }] }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/%3CYOUR_INDEX_NAME%3E/batch'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ requests: [{ action: 'clear', body: { key: 'value' } }] }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('delete', async () => { - const req = (await client.batch({ - indexName: '', - batchWriteParams: { requests: [{ action: 'delete', body: { key: 'value' } }] }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/%3CYOUR_INDEX_NAME%3E/batch'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ requests: [{ action: 'delete', body: { key: 'value' } }] }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('deleteObject', async () => { - const req = (await client.batch({ - indexName: '', - batchWriteParams: { requests: [{ action: 'deleteObject', body: { key: 'value' } }] }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/%3CYOUR_INDEX_NAME%3E/batch'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ requests: [{ action: 'deleteObject', body: { key: 'value' } }] }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('partialUpdateObject', async () => { - const req = (await client.batch({ - indexName: '', - batchWriteParams: { requests: [{ action: 'partialUpdateObject', body: { key: 'value' } }] }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/%3CYOUR_INDEX_NAME%3E/batch'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ requests: [{ action: 'partialUpdateObject', body: { key: 'value' } }] }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('partialUpdateObjectNoCreate', async () => { - const req = (await client.batch({ - indexName: '', - batchWriteParams: { requests: [{ action: 'partialUpdateObjectNoCreate', body: { key: 'value' } }] }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/%3CYOUR_INDEX_NAME%3E/batch'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ requests: [{ action: 'partialUpdateObjectNoCreate', body: { key: 'value' } }] }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('updateObject', async () => { - const req = (await client.batch({ - indexName: '', - batchWriteParams: { requests: [{ action: 'updateObject', body: { key: 'value' } }] }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/%3CYOUR_INDEX_NAME%3E/batch'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ requests: [{ action: 'updateObject', body: { key: 'value' } }] }); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('batchAssignUserIds', () => { - test('batchAssignUserIds', async () => { - const req = (await client.batchAssignUserIds({ - xAlgoliaUserID: 'userID', - batchAssignUserIdsParams: { cluster: 'theCluster', users: ['user1', 'user2'] }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/clusters/mapping/batch'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ cluster: 'theCluster', users: ['user1', 'user2'] }); - expect(req.searchParams).toStrictEqual(undefined); - expect(req.headers).toEqual(expect.objectContaining({ 'x-algolia-user-id': 'userID' })); - }); -}); - -describe('batchDictionaryEntries', () => { - test('replace', async () => { - const req = (await client.batchDictionaryEntries({ - dictionaryName: 'plurals', - batchDictionaryEntriesParams: { - clearExistingDictionaryEntries: true, - requests: [ - { - action: 'addEntry', - body: { - objectID: '1', - language: 'en', - word: 'fancy', - words: ['believe', 'algolia'], - decomposition: ['trust', 'algolia'], - state: 'enabled', - }, - }, - ], - }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/dictionaries/plurals/batch'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - clearExistingDictionaryEntries: true, - requests: [ - { - action: 'addEntry', - body: { - objectID: '1', - language: 'en', - word: 'fancy', - words: ['believe', 'algolia'], - decomposition: ['trust', 'algolia'], - state: 'enabled', - }, - }, - ], - }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('delete', async () => { - const req = (await client.batchDictionaryEntries({ - dictionaryName: 'plurals', - batchDictionaryEntriesParams: { - clearExistingDictionaryEntries: true, - requests: [{ action: 'deleteEntry', body: { objectID: '1' } }], - }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/dictionaries/plurals/batch'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - clearExistingDictionaryEntries: true, - requests: [{ action: 'deleteEntry', body: { objectID: '1' } }], - }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('append', async () => { - const req = (await client.batchDictionaryEntries({ - dictionaryName: 'stopwords', - batchDictionaryEntriesParams: { - requests: [{ action: 'addEntry', body: { objectID: '1', language: 'en', additional: 'try me' } }], - }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/dictionaries/stopwords/batch'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [{ action: 'addEntry', body: { objectID: '1', language: 'en', additional: 'try me' } }], - }); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('browse', () => { - test('browse with minimal parameters', async () => { - const req = (await client.browse({ indexName: 'cts_e2e_browse' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/cts_e2e_browse/browse'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({}); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('browse with search parameters', async () => { - const req = (await client.browse({ - indexName: 'indexName', - browseParams: { query: 'myQuery', facetFilters: ['tags:algolia'] }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/indexName/browse'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ query: 'myQuery', facetFilters: ['tags:algolia'] }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('browse allow a cursor in parameters', async () => { - const req = (await client.browse({ - indexName: 'indexName', - browseParams: { cursor: 'test' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/indexName/browse'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ cursor: 'test' }); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('clearObjects', () => { - test('clearObjects', async () => { - const req = (await client.clearObjects({ indexName: 'theIndexName' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/theIndexName/clear'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('clearRules', () => { - test('clearRules', async () => { - const req = (await client.clearRules({ indexName: 'indexName' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/indexName/rules/clear'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('clearSynonyms', () => { - test('clearSynonyms', async () => { - const req = (await client.clearSynonyms({ indexName: 'indexName' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/indexName/synonyms/clear'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('customDelete', () => { - test('allow del method for a custom path with minimal parameters', async () => { - const req = (await client.customDelete({ path: 'test/minimal' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/minimal'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('allow del method for a custom path with all parameters', async () => { - const req = (await client.customDelete({ - path: 'test/all', - parameters: { query: 'parameters' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/all'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ query: 'parameters' }); - }); -}); - -describe('customGet', () => { - test('allow get method for a custom path with minimal parameters', async () => { - const req = (await client.customGet({ path: 'test/minimal' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/minimal'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('allow get method for a custom path with all parameters', async () => { - const req = (await client.customGet({ - path: 'test/all', - parameters: { query: 'parameters with space' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/all'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ query: 'parameters%20with%20space' }); - }); - - test('requestOptions should be escaped too', async () => { - const req = (await client.customGet( - { path: 'test/all', parameters: { query: 'to be overriden' } }, - { - queryParameters: { query: 'parameters with space', 'and an array': ['array', 'with spaces'] }, - headers: { 'x-header-1': 'spaces are left alone' }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/all'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ - query: 'parameters%20with%20space', - 'and%20an%20array': 'array%2Cwith%20spaces', - }); - expect(req.headers).toEqual(expect.objectContaining({ 'x-header-1': 'spaces are left alone' })); - }); -}); - -describe('customPost', () => { - test('allow post method for a custom path with minimal parameters', async () => { - const req = (await client.customPost({ path: 'test/minimal' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/minimal'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({}); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('allow post method for a custom path with all parameters', async () => { - const req = (await client.customPost({ - path: 'test/all', - parameters: { query: 'parameters' }, - body: { body: 'parameters' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/all'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ body: 'parameters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters' }); - }); - - test('requestOptions can override default query parameters', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { query: 'myQueryParameter' }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'myQueryParameter' }); - }); - - test('requestOptions merges query parameters with default ones', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { query2: 'myQueryParameter' }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', query2: 'myQueryParameter' }); - }); - - test('requestOptions can override default headers', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - headers: { 'x-algolia-api-key': 'ALGOLIA_API_KEY' }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters' }); - expect(req.headers).toEqual(expect.objectContaining({ 'x-algolia-api-key': 'ALGOLIA_API_KEY' })); - }); - - test('requestOptions merges headers with default ones', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - headers: { 'x-algolia-api-key': 'ALGOLIA_API_KEY' }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters' }); - expect(req.headers).toEqual(expect.objectContaining({ 'x-algolia-api-key': 'ALGOLIA_API_KEY' })); - }); - - test('requestOptions queryParameters accepts booleans', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { isItWorking: true }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', isItWorking: 'true' }); - }); - - test('requestOptions queryParameters accepts integers', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { myParam: 2 }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', myParam: '2' }); - }); - - test('requestOptions queryParameters accepts list of string', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { myParam: ['b and c', 'd'] }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', myParam: 'b%20and%20c%2Cd' }); - }); - - test('requestOptions queryParameters accepts list of booleans', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { myParam: [true, true, false] }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', myParam: 'true%2Ctrue%2Cfalse' }); - }); - - test('requestOptions queryParameters accepts list of integers', async () => { - const req = (await client.customPost( - { path: 'test/requestOptions', parameters: { query: 'parameters' }, body: { facet: 'filters' } }, - { - queryParameters: { myParam: [1, 2] }, - }, - )) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/requestOptions'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ facet: 'filters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters', myParam: '1%2C2' }); - }); -}); - -describe('customPut', () => { - test('allow put method for a custom path with minimal parameters', async () => { - const req = (await client.customPut({ path: 'test/minimal' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/minimal'); - expect(req.method).toEqual('PUT'); - expect(req.data).toEqual({}); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('allow put method for a custom path with all parameters', async () => { - const req = (await client.customPut({ - path: 'test/all', - parameters: { query: 'parameters' }, - body: { body: 'parameters' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/test/all'); - expect(req.method).toEqual('PUT'); - expect(req.data).toEqual({ body: 'parameters' }); - expect(req.searchParams).toStrictEqual({ query: 'parameters' }); - }); -}); - -describe('deleteApiKey', () => { - test('deleteApiKey', async () => { - const req = (await client.deleteApiKey({ key: 'myTestApiKey' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/keys/myTestApiKey'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('deleteBy', () => { - test('deleteBy', async () => { - const req = (await client.deleteBy({ - indexName: 'theIndexName', - deleteByParams: { filters: 'brand:brandName' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/theIndexName/deleteByQuery'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ filters: 'brand:brandName' }); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('deleteIndex', () => { - test('deleteIndex', async () => { - const req = (await client.deleteIndex({ indexName: 'theIndexName' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/theIndexName'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('deleteObject', () => { - test('deleteObject', async () => { - const req = (await client.deleteObject({ - indexName: '', - objectID: 'uniqueID', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/%3CYOUR_INDEX_NAME%3E/uniqueID'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('deleteRule', () => { - test('delete rule simple case', async () => { - const req = (await client.deleteRule({ indexName: 'indexName', objectID: 'id1' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/indexName/rules/id1'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('delete rule with simple characters to encode in objectID', async () => { - const req = (await client.deleteRule({ - indexName: 'indexName', - objectID: 'test/with/slash', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/indexName/rules/test%2Fwith%2Fslash'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('deleteSource', () => { - test('deleteSource', async () => { - const req = (await client.deleteSource({ source: 'theSource' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/security/sources/theSource'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('deleteSynonym', () => { - test('deleteSynonym', async () => { - const req = (await client.deleteSynonym({ indexName: 'indexName', objectID: 'id1' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/indexName/synonyms/id1'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('getApiKey', () => { - test('getApiKey', async () => { - const req = (await client.getApiKey({ key: 'myTestApiKey' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/keys/myTestApiKey'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('getAppTask', () => { - test('getAppTask', async () => { - const req = (await client.getAppTask({ taskID: 123 })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/task/123'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('getDictionaryLanguages', () => { - test('get getDictionaryLanguages', async () => { - const req = (await client.getDictionaryLanguages()) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/dictionaries/*/languages'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('getDictionarySettings', () => { - test('get getDictionarySettings results', async () => { - const req = (await client.getDictionarySettings()) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/dictionaries/*/settings'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('getLogs', () => { - test('getLogs with minimal parameters', async () => { - const req = (await client.getLogs()) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/logs'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('getLogs with parameters', async () => { - const req = (await client.getLogs({ - offset: 5, - length: 10, - indexName: 'theIndexName', - type: 'all', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/logs'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ offset: '5', length: '10', indexName: 'theIndexName', type: 'all' }); - }); -}); - -describe('getObject', () => { - test('getObject', async () => { - const req = (await client.getObject({ - indexName: 'theIndexName', - objectID: 'uniqueID', - attributesToRetrieve: ['attr1', 'attr2'], - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/theIndexName/uniqueID'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ attributesToRetrieve: 'attr1%2Cattr2' }); - }); -}); - -describe('getObjects', () => { - test('getObjects', async () => { - const req = (await client.getObjects({ - requests: [{ attributesToRetrieve: ['attr1', 'attr2'], objectID: 'uniqueID', indexName: 'theIndexName' }], - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/*/objects'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [{ attributesToRetrieve: ['attr1', 'attr2'], objectID: 'uniqueID', indexName: 'theIndexName' }], - }); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('getRule', () => { - test('getRule', async () => { - const req = (await client.getRule({ - indexName: 'cts_e2e_browse', - objectID: 'qr-1725004648916', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/cts_e2e_browse/rules/qr-1725004648916'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('getSettings', () => { - test('getSettings', async () => { - const req = (await client.getSettings({ indexName: 'cts_e2e_settings' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/cts_e2e_settings/settings'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('getSources', () => { - test('getSources', async () => { - const req = (await client.getSources()) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/security/sources'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('getSynonym', () => { - test('getSynonym', async () => { - const req = (await client.getSynonym({ indexName: 'indexName', objectID: 'id1' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/indexName/synonyms/id1'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('getTask', () => { - test('getTask', async () => { - const req = (await client.getTask({ indexName: 'theIndexName', taskID: 123 })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/theIndexName/task/123'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('getTopUserIds', () => { - test('getTopUserIds', async () => { - const req = (await client.getTopUserIds()) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/clusters/mapping/top'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('getUserId', () => { - test('getUserId', async () => { - const req = (await client.getUserId({ userID: 'uniqueID' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/clusters/mapping/uniqueID'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('hasPendingMappings', () => { - test('hasPendingMappings with minimal parameters', async () => { - const req = (await client.hasPendingMappings()) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/clusters/mapping/pending'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('hasPendingMappings with parameters', async () => { - const req = (await client.hasPendingMappings({ getClusters: true })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/clusters/mapping/pending'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ getClusters: 'true' }); - }); -}); - -describe('listApiKeys', () => { - test('listApiKeys', async () => { - const req = (await client.listApiKeys()) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/keys'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('listClusters', () => { - test('listClusters', async () => { - const req = (await client.listClusters()) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/clusters'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('listIndices', () => { - test('listIndices with minimal parameters', async () => { - const req = (await client.listIndices()) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('listIndices with parameters', async () => { - const req = (await client.listIndices({ page: 8, hitsPerPage: 3 })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ page: '8', hitsPerPage: '3' }); - }); -}); - -describe('listUserIds', () => { - test('listUserIds with minimal parameters', async () => { - const req = (await client.listUserIds()) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/clusters/mapping'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('listUserIds with parameters', async () => { - const req = (await client.listUserIds({ page: 8, hitsPerPage: 100 })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/clusters/mapping'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual({ page: '8', hitsPerPage: '100' }); - }); -}); - -describe('multipleBatch', () => { - test('multipleBatch', async () => { - const req = (await client.multipleBatch({ - requests: [{ action: 'addObject', body: { key: 'value' }, indexName: 'theIndexName' }], - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/*/batch'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [{ action: 'addObject', body: { key: 'value' }, indexName: 'theIndexName' }], - }); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('operationIndex', () => { - test('scopes', async () => { - const req = (await client.operationIndex({ - indexName: '', - operationIndexParams: { - operation: 'move', - destination: '', - scope: ['rules', 'settings'], - }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/%3CSOURCE_INDEX_NAME%3E/operation'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - operation: 'move', - destination: '', - scope: ['rules', 'settings'], - }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('copy', async () => { - const req = (await client.operationIndex({ - indexName: '', - operationIndexParams: { operation: 'copy', destination: '' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/%3CSOURCE_INDEX_NAME%3E/operation'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ operation: 'copy', destination: '' }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('move', async () => { - const req = (await client.operationIndex({ - indexName: '', - operationIndexParams: { operation: 'move', destination: '' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/%3CSOURCE_INDEX_NAME%3E/operation'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ operation: 'move', destination: '' }); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('partialUpdateObject', () => { - test('Partial update with a new value for a string attribute', async () => { - const req = (await client.partialUpdateObject({ - indexName: 'theIndexName', - objectID: 'uniqueID', - attributesToUpdate: { attributeId: 'new value' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/theIndexName/uniqueID/partial'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ attributeId: 'new value' }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('Partial update with a new value for an integer attribute', async () => { - const req = (await client.partialUpdateObject({ - indexName: 'theIndexName', - objectID: 'uniqueID', - attributesToUpdate: { attributeId: 1 }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/theIndexName/uniqueID/partial'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ attributeId: 1 }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('Partial update with a new value for a boolean attribute', async () => { - const req = (await client.partialUpdateObject({ - indexName: 'theIndexName', - objectID: 'uniqueID', - attributesToUpdate: { attributeId: true }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/theIndexName/uniqueID/partial'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ attributeId: true }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('Partial update with a new value for an array attribute', async () => { - const req = (await client.partialUpdateObject({ - indexName: 'theIndexName', - objectID: 'uniqueID', - attributesToUpdate: { attributeId: ['one', 'two', 'three'] }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/theIndexName/uniqueID/partial'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ attributeId: ['one', 'two', 'three'] }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('Partial update with a new value for an object attribute', async () => { - const req = (await client.partialUpdateObject({ - indexName: 'theIndexName', - objectID: 'uniqueID', - attributesToUpdate: { attributeId: { nested: 'value' } }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/theIndexName/uniqueID/partial'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ attributeId: { nested: 'value' } }); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('removeUserId', () => { - test('removeUserId', async () => { - const req = (await client.removeUserId({ userID: 'uniqueID' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/clusters/mapping/uniqueID'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('replaceSources', () => { - test('replaceSources', async () => { - const req = (await client.replaceSources({ - source: [{ source: 'theSource', description: 'theDescription' }], - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/security/sources'); - expect(req.method).toEqual('PUT'); - expect(req.data).toEqual([{ source: 'theSource', description: 'theDescription' }]); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('restoreApiKey', () => { - test('restoreApiKey', async () => { - const req = (await client.restoreApiKey({ key: 'ALGOLIA_API_KEY' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/keys/ALGOLIA_API_KEY/restore'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('saveObject', () => { - test('saveObject', async () => { - const req = (await client.saveObject({ - indexName: '', - body: { objectID: 'id', test: 'val' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/%3CYOUR_INDEX_NAME%3E'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ objectID: 'id', test: 'val' }); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('saveRule', () => { - test('saveRule with minimal parameters', async () => { - const req = (await client.saveRule({ - indexName: 'indexName', - objectID: 'id1', - rule: { objectID: 'id1', conditions: [{ pattern: 'apple', anchoring: 'contains' }] }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/indexName/rules/id1'); - expect(req.method).toEqual('PUT'); - expect(req.data).toEqual({ objectID: 'id1', conditions: [{ pattern: 'apple', anchoring: 'contains' }] }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('saveRule with all parameters', async () => { - const req = (await client.saveRule({ - indexName: 'indexName', - objectID: 'id1', - rule: { - objectID: 'id1', - conditions: [{ pattern: 'apple', anchoring: 'contains', alternatives: false, context: 'search' }], - consequence: { - params: { - filters: 'brand:apple', - query: { - remove: ['algolia'], - edits: [ - { type: 'remove', delete: 'abc', insert: 'cde' }, - { type: 'replace', delete: 'abc', insert: 'cde' }, - ], - }, - }, - hide: [{ objectID: '321' }], - filterPromotes: false, - userData: { algolia: 'aloglia' }, - promote: [ - { objectID: 'abc', position: 3 }, - { objectIDs: ['abc', 'def'], position: 1 }, - ], - }, - description: 'test', - enabled: true, - validity: [{ from: 1656670273, until: 1656670277 }], - }, - forwardToReplicas: true, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/indexName/rules/id1'); - expect(req.method).toEqual('PUT'); - expect(req.data).toEqual({ - objectID: 'id1', - conditions: [{ pattern: 'apple', anchoring: 'contains', alternatives: false, context: 'search' }], - consequence: { - params: { - filters: 'brand:apple', - query: { - remove: ['algolia'], - edits: [ - { type: 'remove', delete: 'abc', insert: 'cde' }, - { type: 'replace', delete: 'abc', insert: 'cde' }, - ], - }, - }, - hide: [{ objectID: '321' }], - filterPromotes: false, - userData: { algolia: 'aloglia' }, - promote: [ - { objectID: 'abc', position: 3 }, - { objectIDs: ['abc', 'def'], position: 1 }, - ], - }, - description: 'test', - enabled: true, - validity: [{ from: 1656670273, until: 1656670277 }], - }); - expect(req.searchParams).toStrictEqual({ forwardToReplicas: 'true' }); - }); -}); - -describe('saveRules', () => { - test('saveRules with minimal parameters', async () => { - const req = (await client.saveRules({ - indexName: '', - rules: [ - { objectID: 'a-rule-id', conditions: [{ pattern: 'smartphone', anchoring: 'contains' }] }, - { objectID: 'a-second-rule-id', conditions: [{ pattern: 'apple', anchoring: 'contains' }] }, - ], - forwardToReplicas: false, - clearExistingRules: true, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/%3CYOUR_INDEX_NAME%3E/rules/batch'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual([ - { objectID: 'a-rule-id', conditions: [{ pattern: 'smartphone', anchoring: 'contains' }] }, - { objectID: 'a-second-rule-id', conditions: [{ pattern: 'apple', anchoring: 'contains' }] }, - ]); - expect(req.searchParams).toStrictEqual({ forwardToReplicas: 'false', clearExistingRules: 'true' }); - }); - - test('saveRules with all parameters', async () => { - const req = (await client.saveRules({ - indexName: '', - rules: [ - { - objectID: 'id1', - conditions: [{ pattern: 'apple', anchoring: 'contains', alternatives: false, context: 'search' }], - consequence: { - params: { - filters: 'brand:apple', - query: { - remove: ['algolia'], - edits: [ - { type: 'remove', delete: 'abc', insert: 'cde' }, - { type: 'replace', delete: 'abc', insert: 'cde' }, - ], - }, - }, - hide: [{ objectID: '321' }], - filterPromotes: false, - userData: { algolia: 'aloglia' }, - promote: [ - { objectID: 'abc', position: 3 }, - { objectIDs: ['abc', 'def'], position: 1 }, - ], - }, - description: 'test', - enabled: true, - validity: [{ from: 1656670273, until: 1656670277 }], - }, - ], - forwardToReplicas: true, - clearExistingRules: true, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/%3CYOUR_INDEX_NAME%3E/rules/batch'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual([ - { - objectID: 'id1', - conditions: [{ pattern: 'apple', anchoring: 'contains', alternatives: false, context: 'search' }], - consequence: { - params: { - filters: 'brand:apple', - query: { - remove: ['algolia'], - edits: [ - { type: 'remove', delete: 'abc', insert: 'cde' }, - { type: 'replace', delete: 'abc', insert: 'cde' }, - ], - }, - }, - hide: [{ objectID: '321' }], - filterPromotes: false, - userData: { algolia: 'aloglia' }, - promote: [ - { objectID: 'abc', position: 3 }, - { objectIDs: ['abc', 'def'], position: 1 }, - ], - }, - description: 'test', - enabled: true, - validity: [{ from: 1656670273, until: 1656670277 }], - }, - ]); - expect(req.searchParams).toStrictEqual({ forwardToReplicas: 'true', clearExistingRules: 'true' }); - }); -}); - -describe('saveSynonym', () => { - test('saveSynonym', async () => { - const req = (await client.saveSynonym({ - indexName: 'indexName', - objectID: 'id1', - synonymHit: { objectID: 'id1', type: 'synonym', synonyms: ['car', 'vehicule', 'auto'] }, - forwardToReplicas: true, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/indexName/synonyms/id1'); - expect(req.method).toEqual('PUT'); - expect(req.data).toEqual({ objectID: 'id1', type: 'synonym', synonyms: ['car', 'vehicule', 'auto'] }); - expect(req.searchParams).toStrictEqual({ forwardToReplicas: 'true' }); - }); -}); - -describe('saveSynonyms', () => { - test('saveSynonyms', async () => { - const req = (await client.saveSynonyms({ - indexName: '', - synonymHit: [ - { objectID: 'id1', type: 'synonym', synonyms: ['car', 'vehicule', 'auto'] }, - { objectID: 'id2', type: 'onewaysynonym', input: 'iphone', synonyms: ['ephone', 'aphone', 'yphone'] }, - ], - forwardToReplicas: true, - replaceExistingSynonyms: true, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/%3CYOUR_INDEX_NAME%3E/synonyms/batch'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual([ - { objectID: 'id1', type: 'synonym', synonyms: ['car', 'vehicule', 'auto'] }, - { objectID: 'id2', type: 'onewaysynonym', input: 'iphone', synonyms: ['ephone', 'aphone', 'yphone'] }, - ]); - expect(req.searchParams).toStrictEqual({ forwardToReplicas: 'true', replaceExistingSynonyms: 'true' }); - }); -}); - -describe('search', () => { - test('withHitsPerPage', async () => { - const req = (await client.search({ - requests: [{ indexName: '', query: '', hitsPerPage: 50 }], - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/*/queries'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [{ indexName: '', query: '', hitsPerPage: 50 }], - }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('filterOnly', async () => { - const req = (await client.search({ - requests: [{ indexName: '', query: '', filters: 'actor:Scarlett Johansson' }], - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/*/queries'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [{ indexName: '', query: '', filters: 'actor:Scarlett Johansson' }], - }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('filterOr', async () => { - const req = (await client.search({ - requests: [ - { - indexName: '', - query: '', - filters: 'actor:Tom Cruise OR actor:Scarlett Johansson', - }, - ], - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/*/queries'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [ - { - indexName: '', - query: '', - filters: 'actor:Tom Cruise OR actor:Scarlett Johansson', - }, - ], - }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('filterNot', async () => { - const req = (await client.search({ - requests: [{ indexName: '', query: '', filters: 'NOT actor:Nicolas Cage' }], - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/*/queries'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [{ indexName: '', query: '', filters: 'NOT actor:Nicolas Cage' }], - }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('search for a single hits request with minimal parameters', async () => { - const req = (await client.search({ - requests: [{ indexName: 'cts_e2e_search_empty_index' }], - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/*/queries'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ requests: [{ indexName: 'cts_e2e_search_empty_index' }] }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('search with highlight and snippet results', async () => { - const req = (await client.search({ - requests: [ - { - indexName: 'cts_e2e_highlight_snippet_results', - query: 'vim', - attributesToSnippet: ['*:20'], - attributesToHighlight: ['*'], - attributesToRetrieve: ['*'], - }, - ], - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/*/queries'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [ - { - indexName: 'cts_e2e_highlight_snippet_results', - query: 'vim', - attributesToSnippet: ['*:20'], - attributesToHighlight: ['*'], - attributesToRetrieve: ['*'], - }, - ], - }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('retrieveFacets', async () => { - const req = (await client.search({ - requests: [{ indexName: '', query: '', facets: ['author', 'genre'] }], - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/*/queries'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [{ indexName: '', query: '', facets: ['author', 'genre'] }], - }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('retrieveFacetsWildcard', async () => { - const req = (await client.search({ - requests: [{ indexName: '', query: '', facets: ['*'] }], - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/*/queries'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ requests: [{ indexName: '', query: '', facets: ['*'] }] }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('search for a single facet request with minimal parameters', async () => { - const req = (await client.search({ - requests: [{ indexName: 'cts_e2e_search_facet', type: 'facet', facet: 'editor' }], - strategy: 'stopIfEnoughMatches', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/*/queries'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [{ indexName: 'cts_e2e_search_facet', type: 'facet', facet: 'editor' }], - strategy: 'stopIfEnoughMatches', - }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('search for a single hits request with all parameters', async () => { - const req = (await client.search({ - requests: [{ indexName: 'theIndexName', query: 'myQuery', hitsPerPage: 50, type: 'default' }], - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/*/queries'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [{ indexName: 'theIndexName', query: 'myQuery', hitsPerPage: 50, type: 'default' }], - }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('search for a single facet request with all parameters', async () => { - const req = (await client.search({ - requests: [ - { - indexName: 'theIndexName', - type: 'facet', - facet: 'theFacet', - facetQuery: 'theFacetQuery', - query: 'theQuery', - maxFacetHits: 50, - }, - ], - strategy: 'stopIfEnoughMatches', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/*/queries'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [ - { - indexName: 'theIndexName', - type: 'facet', - facet: 'theFacet', - facetQuery: 'theFacetQuery', - query: 'theQuery', - maxFacetHits: 50, - }, - ], - strategy: 'stopIfEnoughMatches', - }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('search for multiple mixed requests in multiple indices with minimal parameters', async () => { - const req = (await client.search({ - requests: [ - { indexName: 'theIndexName' }, - { indexName: 'theIndexName2', type: 'facet', facet: 'theFacet' }, - { indexName: 'theIndexName', type: 'default' }, - ], - strategy: 'stopIfEnoughMatches', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/*/queries'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [ - { indexName: 'theIndexName' }, - { indexName: 'theIndexName2', type: 'facet', facet: 'theFacet' }, - { indexName: 'theIndexName', type: 'default' }, - ], - strategy: 'stopIfEnoughMatches', - }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('search for multiple mixed requests in multiple indices with all parameters', async () => { - const req = (await client.search({ - requests: [ - { - indexName: 'theIndexName', - type: 'facet', - facet: 'theFacet', - facetQuery: 'theFacetQuery', - query: 'theQuery', - maxFacetHits: 50, - }, - { indexName: 'theIndexName', query: 'myQuery', hitsPerPage: 50, type: 'default' }, - ], - strategy: 'stopIfEnoughMatches', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/*/queries'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [ - { - indexName: 'theIndexName', - type: 'facet', - facet: 'theFacet', - facetQuery: 'theFacetQuery', - query: 'theQuery', - maxFacetHits: 50, - }, - { indexName: 'theIndexName', query: 'myQuery', hitsPerPage: 50, type: 'default' }, - ], - strategy: 'stopIfEnoughMatches', - }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('search filters accept all of the possible shapes', async () => { - const req = (await client.search({ - requests: [ - { - indexName: 'theIndexName', - facetFilters: 'mySearch:filters', - reRankingApplyFilter: 'mySearch:filters', - tagFilters: 'mySearch:filters', - numericFilters: 'mySearch:filters', - optionalFilters: 'mySearch:filters', - }, - { - indexName: 'theIndexName', - facetFilters: ['mySearch:filters', ['mySearch:filters', ['mySearch:filters']]], - reRankingApplyFilter: ['mySearch:filters', ['mySearch:filters']], - tagFilters: ['mySearch:filters', ['mySearch:filters']], - numericFilters: ['mySearch:filters', ['mySearch:filters']], - optionalFilters: ['mySearch:filters', ['mySearch:filters']], - }, - ], - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/*/queries'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [ - { - indexName: 'theIndexName', - facetFilters: 'mySearch:filters', - reRankingApplyFilter: 'mySearch:filters', - tagFilters: 'mySearch:filters', - numericFilters: 'mySearch:filters', - optionalFilters: 'mySearch:filters', - }, - { - indexName: 'theIndexName', - facetFilters: ['mySearch:filters', ['mySearch:filters', ['mySearch:filters']]], - reRankingApplyFilter: ['mySearch:filters', ['mySearch:filters']], - tagFilters: ['mySearch:filters', ['mySearch:filters']], - numericFilters: ['mySearch:filters', ['mySearch:filters']], - optionalFilters: ['mySearch:filters', ['mySearch:filters']], - }, - ], - }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('search filters end to end', async () => { - const req = (await client.search({ - requests: [ - { indexName: 'cts_e2e_search_facet', filters: "editor:'visual studio' OR editor:neovim" }, - { indexName: 'cts_e2e_search_facet', facetFilters: ["editor:'visual studio'", 'editor:neovim'] }, - { indexName: 'cts_e2e_search_facet', facetFilters: ["editor:'visual studio'", ['editor:neovim']] }, - { - indexName: 'cts_e2e_search_facet', - facetFilters: ["editor:'visual studio'", ['editor:neovim', ['editor:goland']]], - }, - ], - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/*/queries'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [ - { indexName: 'cts_e2e_search_facet', filters: "editor:'visual studio' OR editor:neovim" }, - { indexName: 'cts_e2e_search_facet', facetFilters: ["editor:'visual studio'", 'editor:neovim'] }, - { indexName: 'cts_e2e_search_facet', facetFilters: ["editor:'visual studio'", ['editor:neovim']] }, - { - indexName: 'cts_e2e_search_facet', - facetFilters: ["editor:'visual studio'", ['editor:neovim', ['editor:goland']]], - }, - ], - }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('search with all search parameters', async () => { - const req = (await client.search({ - requests: [ - { - advancedSyntax: true, - advancedSyntaxFeatures: ['exactPhrase'], - allowTyposOnNumericTokens: true, - alternativesAsExact: ['multiWordsSynonym'], - analytics: true, - analyticsTags: [''], - aroundLatLng: '', - aroundLatLngViaIP: true, - aroundPrecision: 0, - aroundRadius: 'all', - attributeCriteriaComputedByMinProximity: true, - attributesToHighlight: [''], - attributesToRetrieve: [''], - attributesToSnippet: [''], - clickAnalytics: true, - customRanking: [''], - decompoundQuery: true, - disableExactOnAttributes: [''], - disableTypoToleranceOnAttributes: [''], - distinct: 0, - enableABTest: true, - enablePersonalization: true, - enableReRanking: true, - enableRules: true, - exactOnSingleWordQuery: 'attribute', - facetFilters: [''], - facetingAfterDistinct: true, - facets: [''], - filters: '', - getRankingInfo: true, - highlightPostTag: '', - highlightPreTag: '', - hitsPerPage: 1, - ignorePlurals: false, - indexName: 'theIndexName', - insideBoundingBox: [ - [47.3165, 4.9665, 47.3424, 5.0201], - [40.9234, 2.1185, 38.643, 1.9916], - ], - insidePolygon: [ - [47.3165, 4.9665, 47.3424, 5.0201, 47.32, 4.9], - [40.9234, 2.1185, 38.643, 1.9916, 39.2587, 2.0104], - ], - keepDiacriticsOnCharacters: '', - length: 1, - maxValuesPerFacet: 0, - minProximity: 1, - minWordSizefor1Typo: 0, - minWordSizefor2Typos: 0, - minimumAroundRadius: 1, - naturalLanguages: ['fr'], - numericFilters: [''], - offset: 0, - optionalFilters: [''], - optionalWords: [''], - page: 0, - percentileComputation: true, - personalizationImpact: 0, - query: '', - queryLanguages: ['fr'], - queryType: 'prefixAll', - ranking: [''], - reRankingApplyFilter: [''], - relevancyStrictness: 0, - removeStopWords: true, - removeWordsIfNoResults: 'allOptional', - renderingContent: { - facetOrdering: { facets: { order: ['a', 'b'] }, values: { a: { order: ['b'], sortRemainingBy: 'count' } } }, - }, - replaceSynonymsInHighlight: true, - responseFields: [''], - restrictHighlightAndSnippetArrays: true, - restrictSearchableAttributes: [''], - ruleContexts: [''], - similarQuery: '', - snippetEllipsisText: '', - sortFacetValuesBy: '', - sumOrFiltersScores: true, - synonyms: true, - tagFilters: [''], - type: 'default', - typoTolerance: 'min', - userToken: '', - }, - ], - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/*/queries'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [ - { - advancedSyntax: true, - advancedSyntaxFeatures: ['exactPhrase'], - allowTyposOnNumericTokens: true, - alternativesAsExact: ['multiWordsSynonym'], - analytics: true, - analyticsTags: [''], - aroundLatLng: '', - aroundLatLngViaIP: true, - aroundPrecision: 0, - aroundRadius: 'all', - attributeCriteriaComputedByMinProximity: true, - attributesToHighlight: [''], - attributesToRetrieve: [''], - attributesToSnippet: [''], - clickAnalytics: true, - customRanking: [''], - decompoundQuery: true, - disableExactOnAttributes: [''], - disableTypoToleranceOnAttributes: [''], - distinct: 0, - enableABTest: true, - enablePersonalization: true, - enableReRanking: true, - enableRules: true, - exactOnSingleWordQuery: 'attribute', - facetFilters: [''], - facetingAfterDistinct: true, - facets: [''], - filters: '', - getRankingInfo: true, - highlightPostTag: '', - highlightPreTag: '', - hitsPerPage: 1, - ignorePlurals: false, - indexName: 'theIndexName', - insideBoundingBox: [ - [47.3165, 4.9665, 47.3424, 5.0201], - [40.9234, 2.1185, 38.643, 1.9916], - ], - insidePolygon: [ - [47.3165, 4.9665, 47.3424, 5.0201, 47.32, 4.9], - [40.9234, 2.1185, 38.643, 1.9916, 39.2587, 2.0104], - ], - keepDiacriticsOnCharacters: '', - length: 1, - maxValuesPerFacet: 0, - minProximity: 1, - minWordSizefor1Typo: 0, - minWordSizefor2Typos: 0, - minimumAroundRadius: 1, - naturalLanguages: ['fr'], - numericFilters: [''], - offset: 0, - optionalFilters: [''], - optionalWords: [''], - page: 0, - percentileComputation: true, - personalizationImpact: 0, - query: '', - queryLanguages: ['fr'], - queryType: 'prefixAll', - ranking: [''], - reRankingApplyFilter: [''], - relevancyStrictness: 0, - removeStopWords: true, - removeWordsIfNoResults: 'allOptional', - renderingContent: { - facetOrdering: { facets: { order: ['a', 'b'] }, values: { a: { order: ['b'], sortRemainingBy: 'count' } } }, - }, - replaceSynonymsInHighlight: true, - responseFields: [''], - restrictHighlightAndSnippetArrays: true, - restrictSearchableAttributes: [''], - ruleContexts: [''], - similarQuery: '', - snippetEllipsisText: '', - sortFacetValuesBy: '', - sumOrFiltersScores: true, - synonyms: true, - tagFilters: [''], - type: 'default', - typoTolerance: 'min', - userToken: '', - }, - ], - }); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('searchDictionaryEntries', () => { - test('get searchDictionaryEntries results with minimal parameters', async () => { - const req = (await client.searchDictionaryEntries({ - dictionaryName: 'stopwords', - searchDictionaryEntriesParams: { query: 'about' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/dictionaries/stopwords/search'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ query: 'about' }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('get searchDictionaryEntries results with all parameters', async () => { - const req = (await client.searchDictionaryEntries({ - dictionaryName: 'compounds', - searchDictionaryEntriesParams: { query: 'foo', page: 4, hitsPerPage: 2, language: 'fr' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/dictionaries/compounds/search'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ query: 'foo', page: 4, hitsPerPage: 2, language: 'fr' }); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('searchForFacetValues', () => { - test('get searchForFacetValues results with minimal parameters', async () => { - const req = (await client.searchForFacetValues({ - indexName: 'indexName', - facetName: 'facetName', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/indexName/facets/facetName/query'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({}); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('get searchForFacetValues results with all parameters', async () => { - const req = (await client.searchForFacetValues({ - indexName: 'indexName', - facetName: 'facetName', - searchForFacetValuesRequest: { params: "query=foo&facetFilters=['bar']", facetQuery: 'foo', maxFacetHits: 42 }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/indexName/facets/facetName/query'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ params: "query=foo&facetFilters=['bar']", facetQuery: 'foo', maxFacetHits: 42 }); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('searchRules', () => { - test('searchRules', async () => { - const req = (await client.searchRules({ - indexName: 'cts_e2e_browse', - searchRulesParams: { query: 'zorro' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/cts_e2e_browse/rules/search'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ query: 'zorro' }); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('searchSingleIndex', () => { - test('search with minimal parameters', async () => { - const req = (await client.searchSingleIndex({ indexName: 'indexName' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/indexName/query'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({}); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('search with special characters in indexName', async () => { - const req = (await client.searchSingleIndex({ indexName: 'cts_e2e_space in index' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/cts_e2e_space%20in%20index/query'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({}); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('search with searchParams', async () => { - const req = (await client.searchSingleIndex({ - indexName: 'indexName', - searchParams: { query: 'myQuery', facetFilters: ['tags:algolia'] }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/indexName/query'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ query: 'myQuery', facetFilters: ['tags:algolia'] }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('single search retrieve snippets', async () => { - const req = (await client.searchSingleIndex({ - indexName: 'cts_e2e_browse', - searchParams: { - query: 'batman mask of the phantasm', - attributesToRetrieve: ['*'], - attributesToSnippet: ['*:20'], - }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/cts_e2e_browse/query'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - query: 'batman mask of the phantasm', - attributesToRetrieve: ['*'], - attributesToSnippet: ['*:20'], - }); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('searchSynonyms', () => { - test('searchSynonyms with minimal parameters', async () => { - const req = (await client.searchSynonyms({ indexName: 'indexName' })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/indexName/synonyms/search'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({}); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('searchSynonyms with all parameters', async () => { - const req = (await client.searchSynonyms({ - indexName: 'indexName', - searchSynonymsParams: { query: 'myQuery', type: 'altcorrection1', page: 10, hitsPerPage: 10 }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/indexName/synonyms/search'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ query: 'myQuery', type: 'altcorrection1', page: 10, hitsPerPage: 10 }); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('searchUserIds', () => { - test('searchUserIds', async () => { - const req = (await client.searchUserIds({ - query: 'test', - clusterName: 'theClusterName', - page: 5, - hitsPerPage: 10, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/clusters/mapping/search'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ query: 'test', clusterName: 'theClusterName', page: 5, hitsPerPage: 10 }); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('setDictionarySettings', () => { - test('get setDictionarySettings results with minimal parameters', async () => { - const req = (await client.setDictionarySettings({ - disableStandardEntries: { plurals: { fr: false, en: false, ru: true } }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/dictionaries/*/settings'); - expect(req.method).toEqual('PUT'); - expect(req.data).toEqual({ disableStandardEntries: { plurals: { fr: false, en: false, ru: true } } }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('get setDictionarySettings results with all parameters', async () => { - const req = (await client.setDictionarySettings({ - disableStandardEntries: { - plurals: { fr: false, en: false, ru: true }, - stopwords: { fr: false }, - compounds: { ru: true }, - }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/dictionaries/*/settings'); - expect(req.method).toEqual('PUT'); - expect(req.data).toEqual({ - disableStandardEntries: { - plurals: { fr: false, en: false, ru: true }, - stopwords: { fr: false }, - compounds: { ru: true }, - }, - }); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('setSettings', () => { - test('setSettingsAttributesForFaceting', async () => { - const req = (await client.setSettings({ - indexName: '', - indexSettings: { attributesForFaceting: ['actor', 'filterOnly(category)', 'searchable(publisher)'] }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/%3CYOUR_INDEX_NAME%3E/settings'); - expect(req.method).toEqual('PUT'); - expect(req.data).toEqual({ attributesForFaceting: ['actor', 'filterOnly(category)', 'searchable(publisher)'] }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('setSettings with minimal parameters', async () => { - const req = (await client.setSettings({ - indexName: 'cts_e2e_settings', - indexSettings: { paginationLimitedTo: 10 }, - forwardToReplicas: true, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/cts_e2e_settings/settings'); - expect(req.method).toEqual('PUT'); - expect(req.data).toEqual({ paginationLimitedTo: 10 }); - expect(req.searchParams).toStrictEqual({ forwardToReplicas: 'true' }); - }); - - test('setSettings allow boolean `typoTolerance`', async () => { - const req = (await client.setSettings({ - indexName: 'theIndexName', - indexSettings: { typoTolerance: true }, - forwardToReplicas: true, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/theIndexName/settings'); - expect(req.method).toEqual('PUT'); - expect(req.data).toEqual({ typoTolerance: true }); - expect(req.searchParams).toStrictEqual({ forwardToReplicas: 'true' }); - }); - - test('setSettings allow enum `typoTolerance`', async () => { - const req = (await client.setSettings({ - indexName: 'theIndexName', - indexSettings: { typoTolerance: 'min' }, - forwardToReplicas: true, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/theIndexName/settings'); - expect(req.method).toEqual('PUT'); - expect(req.data).toEqual({ typoTolerance: 'min' }); - expect(req.searchParams).toStrictEqual({ forwardToReplicas: 'true' }); - }); - - test('setSettings allow boolean `ignorePlurals`', async () => { - const req = (await client.setSettings({ - indexName: 'theIndexName', - indexSettings: { ignorePlurals: true }, - forwardToReplicas: true, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/theIndexName/settings'); - expect(req.method).toEqual('PUT'); - expect(req.data).toEqual({ ignorePlurals: true }); - expect(req.searchParams).toStrictEqual({ forwardToReplicas: 'true' }); - }); - - test('setSettings allow list of string `ignorePlurals`', async () => { - const req = (await client.setSettings({ - indexName: 'theIndexName', - indexSettings: { ignorePlurals: ['fr'] }, - forwardToReplicas: true, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/theIndexName/settings'); - expect(req.method).toEqual('PUT'); - expect(req.data).toEqual({ ignorePlurals: ['fr'] }); - expect(req.searchParams).toStrictEqual({ forwardToReplicas: 'true' }); - }); - - test('setSettings allow boolean `removeStopWords`', async () => { - const req = (await client.setSettings({ - indexName: 'theIndexName', - indexSettings: { removeStopWords: true }, - forwardToReplicas: true, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/theIndexName/settings'); - expect(req.method).toEqual('PUT'); - expect(req.data).toEqual({ removeStopWords: true }); - expect(req.searchParams).toStrictEqual({ forwardToReplicas: 'true' }); - }); - - test('setSettings allow list of string `removeStopWords`', async () => { - const req = (await client.setSettings({ - indexName: 'theIndexName', - indexSettings: { removeStopWords: ['fr'] }, - forwardToReplicas: true, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/theIndexName/settings'); - expect(req.method).toEqual('PUT'); - expect(req.data).toEqual({ removeStopWords: ['fr'] }); - expect(req.searchParams).toStrictEqual({ forwardToReplicas: 'true' }); - }); - - test('setSettings allow boolean `distinct`', async () => { - const req = (await client.setSettings({ - indexName: 'theIndexName', - indexSettings: { distinct: true }, - forwardToReplicas: true, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/theIndexName/settings'); - expect(req.method).toEqual('PUT'); - expect(req.data).toEqual({ distinct: true }); - expect(req.searchParams).toStrictEqual({ forwardToReplicas: 'true' }); - }); - - test('setSettings allow integers for `distinct`', async () => { - const req = (await client.setSettings({ - indexName: 'theIndexName', - indexSettings: { distinct: 1 }, - forwardToReplicas: true, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/theIndexName/settings'); - expect(req.method).toEqual('PUT'); - expect(req.data).toEqual({ distinct: 1 }); - expect(req.searchParams).toStrictEqual({ forwardToReplicas: 'true' }); - }); - - test('setSettings allow all `indexSettings`', async () => { - const req = (await client.setSettings({ - indexName: 'theIndexName', - indexSettings: { - advancedSyntax: true, - advancedSyntaxFeatures: ['exactPhrase'], - allowCompressionOfIntegerArray: true, - allowTyposOnNumericTokens: true, - alternativesAsExact: ['singleWordSynonym'], - attributeCriteriaComputedByMinProximity: true, - attributeForDistinct: 'test', - attributesForFaceting: ['algolia'], - attributesToHighlight: ['algolia'], - attributesToRetrieve: ['algolia'], - attributesToSnippet: ['algolia'], - attributesToTransliterate: ['algolia'], - camelCaseAttributes: ['algolia'], - customNormalization: { algolia: { aloglia: 'aglolia' } }, - customRanking: ['algolia'], - decompoundQuery: false, - decompoundedAttributes: { algolia: 'aloglia' }, - disableExactOnAttributes: ['algolia'], - disablePrefixOnAttributes: ['algolia'], - disableTypoToleranceOnAttributes: ['algolia'], - disableTypoToleranceOnWords: ['algolia'], - distinct: 3, - enablePersonalization: true, - enableReRanking: false, - enableRules: true, - exactOnSingleWordQuery: 'attribute', - highlightPreTag: '', - highlightPostTag: '', - hitsPerPage: 10, - ignorePlurals: false, - indexLanguages: ['fr'], - keepDiacriticsOnCharacters: 'abc', - maxFacetHits: 20, - maxValuesPerFacet: 30, - minProximity: 6, - minWordSizefor1Typo: 5, - minWordSizefor2Typos: 11, - mode: 'neuralSearch', - numericAttributesForFiltering: ['algolia'], - optionalWords: ['myspace'], - paginationLimitedTo: 0, - queryLanguages: ['fr'], - queryType: 'prefixLast', - ranking: ['geo'], - reRankingApplyFilter: 'mySearch:filters', - relevancyStrictness: 10, - removeStopWords: false, - removeWordsIfNoResults: 'lastWords', - renderingContent: { - facetOrdering: { facets: { order: ['a', 'b'] }, values: { a: { order: ['b'], sortRemainingBy: 'count' } } }, - }, - replaceSynonymsInHighlight: true, - replicas: [''], - responseFields: ['algolia'], - restrictHighlightAndSnippetArrays: true, - searchableAttributes: ['foo'], - semanticSearch: { eventSources: ['foo'] }, - separatorsToIndex: 'bar', - snippetEllipsisText: '---', - sortFacetValuesBy: 'date', - typoTolerance: false, - unretrievableAttributes: ['foo'], - userData: { user: 'data' }, - }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/theIndexName/settings'); - expect(req.method).toEqual('PUT'); - expect(req.data).toEqual({ - advancedSyntax: true, - advancedSyntaxFeatures: ['exactPhrase'], - allowCompressionOfIntegerArray: true, - allowTyposOnNumericTokens: true, - alternativesAsExact: ['singleWordSynonym'], - attributeCriteriaComputedByMinProximity: true, - attributeForDistinct: 'test', - attributesForFaceting: ['algolia'], - attributesToHighlight: ['algolia'], - attributesToRetrieve: ['algolia'], - attributesToSnippet: ['algolia'], - attributesToTransliterate: ['algolia'], - camelCaseAttributes: ['algolia'], - customNormalization: { algolia: { aloglia: 'aglolia' } }, - customRanking: ['algolia'], - decompoundQuery: false, - decompoundedAttributes: { algolia: 'aloglia' }, - disableExactOnAttributes: ['algolia'], - disablePrefixOnAttributes: ['algolia'], - disableTypoToleranceOnAttributes: ['algolia'], - disableTypoToleranceOnWords: ['algolia'], - distinct: 3, - enablePersonalization: true, - enableReRanking: false, - enableRules: true, - exactOnSingleWordQuery: 'attribute', - highlightPreTag: '', - highlightPostTag: '', - hitsPerPage: 10, - ignorePlurals: false, - indexLanguages: ['fr'], - keepDiacriticsOnCharacters: 'abc', - maxFacetHits: 20, - maxValuesPerFacet: 30, - minProximity: 6, - minWordSizefor1Typo: 5, - minWordSizefor2Typos: 11, - mode: 'neuralSearch', - numericAttributesForFiltering: ['algolia'], - optionalWords: ['myspace'], - paginationLimitedTo: 0, - queryLanguages: ['fr'], - queryType: 'prefixLast', - ranking: ['geo'], - reRankingApplyFilter: 'mySearch:filters', - relevancyStrictness: 10, - removeStopWords: false, - removeWordsIfNoResults: 'lastWords', - renderingContent: { - facetOrdering: { facets: { order: ['a', 'b'] }, values: { a: { order: ['b'], sortRemainingBy: 'count' } } }, - }, - replaceSynonymsInHighlight: true, - replicas: [''], - responseFields: ['algolia'], - restrictHighlightAndSnippetArrays: true, - searchableAttributes: ['foo'], - semanticSearch: { eventSources: ['foo'] }, - separatorsToIndex: 'bar', - snippetEllipsisText: '---', - sortFacetValuesBy: 'date', - typoTolerance: false, - unretrievableAttributes: ['foo'], - userData: { user: 'data' }, - }); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - -describe('updateApiKey', () => { - test('updateApiKey', async () => { - const req = (await client.updateApiKey({ - key: 'ALGOLIA_API_KEY', - apiKey: { acl: ['search', 'addObject'], validity: 300, maxQueriesPerIPPerHour: 100, maxHitsPerQuery: 20 }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/keys/ALGOLIA_API_KEY'); - expect(req.method).toEqual('PUT'); - expect(req.data).toEqual({ - acl: ['search', 'addObject'], - validity: 300, - maxQueriesPerIPPerHour: 100, - maxHitsPerQuery: 20, - }); - expect(req.searchParams).toStrictEqual(undefined); - }); -});