Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Commit

Permalink
feat(client): search service (#1467)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkucmus authored May 5, 2021
1 parent 7eee960 commit 33074fd
Show file tree
Hide file tree
Showing 27 changed files with 58 additions and 905 deletions.
50 changes: 0 additions & 50 deletions api/composables.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { CustomerUpdateEmailParam } from '@shopware-pwa/shopware-6-client';
import { CustomerUpdatePasswordParam } from '@shopware-pwa/shopware-6-client';
import { CustomerUpdateProfileParam } from '@shopware-pwa/shopware-6-client';
import { EntityError } from '@shopware-pwa/commons/interfaces/models/common/EntityError';
import { EqualsFilter } from '@shopware-pwa/commons/interfaces/search/SearchFilter';
import { Includes } from '@shopware-pwa/commons/interfaces/search/SearchCriteria';
import { IUseListing as IUseListing_2 } from '@shopware-pwa/composables';
import { LineItem } from '@shopware-pwa/commons/interfaces/models/checkout/cart/line-item/LineItem';
Expand All @@ -35,9 +34,7 @@ import { PageResolverProductResult } from '@shopware-pwa/commons/interfaces/mode
import { PageResolverResult } from '@shopware-pwa/commons/interfaces/models/content/cms/CmsPage';
import { PaymentMethod } from '@shopware-pwa/commons/interfaces/models/checkout/payment/PaymentMethod';
import { Product } from '@shopware-pwa/commons/interfaces/models/content/product/Product';
import { ProductListingResult } from '@shopware-pwa/commons/interfaces/response/ProductListingResult';
import { PropertyGroup } from '@shopware-pwa/commons/interfaces/models/content/property/PropertyGroup';
import { RangeFilter } from '@shopware-pwa/commons/interfaces/search/SearchFilter';
import { Ref } from '@vue/composition-api';
import { Salutation } from '@shopware-pwa/commons/interfaces/models/system/salutation/Salutation';
import { SessionContext } from '@shopware-pwa/commons/interfaces/response/SessionContext';
Expand Down Expand Up @@ -140,16 +137,6 @@ export function createListingComposable<ELEMENTS_TYPE>({ rootContext, searchMeth
listingKey: string;
}): IUseListing<ELEMENTS_TYPE>;

// @beta (undocumented)
export interface CurrentPagination {
// (undocumented)
currentPage: number | undefined;
// (undocumented)
perPage: number | undefined;
// (undocumented)
total: number | undefined;
}

// @beta (undocumented)
export function getApplicationContext(rootContext: ApplicationVueContext, key?: string): {
apiInstance: ShopwareApiInstance | undefined;
Expand Down Expand Up @@ -659,43 +646,6 @@ export const useProductConfigurator: (rootContext: ApplicationVueContext, produc
// @beta (undocumented)
export const useProductQuickSearch: (rootContext: ApplicationVueContext_2) => IUseProductQuickSearch;

// @alpha @deprecated (undocumented)
export interface UseProductSearch {
// (undocumented)
availableFilters: Readonly<Ref<any>>;
// (undocumented)
changePage: (page: number) => Promise<void>;
// (undocumented)
changeSorting: (sorting: Sort) => void;
// (undocumented)
currentPagination: Ref<CurrentPagination | undefined>;
// (undocumented)
currentSearchTerm: Readonly<Ref<string>>;
// (undocumented)
loadingSearch: Readonly<Ref<boolean>>;
// (undocumented)
loadingSuggestions: Readonly<Ref<boolean>>;
// (undocumented)
resetFilters: () => void;
// (undocumented)
search: (term: string) => Promise<void>;
// (undocumented)
searchResult: Readonly<Ref<ProductListingResult | null>>;
// (undocumented)
selectedEntityFilters: Readonly<Ref<any>>;
// (undocumented)
selectedFilters: Readonly<Ref<any>>;
// (undocumented)
suggestionsResult: Readonly<Ref<ProductListingResult | null>>;
// (undocumented)
suggestSearch: (term: string) => Promise<void>;
// (undocumented)
toggleFilter: (filter: EqualsFilter | RangeFilter, forceSave: boolean) => void;
}

// @alpha @deprecated (undocumented)
export const useProductSearch: (rootContext: ApplicationVueContext) => UseProductSearch;

// @beta (undocumented)
export interface UseSalutations {
// (undocumented)
Expand Down
20 changes: 3 additions & 17 deletions api/shopware-6-client.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -313,14 +313,6 @@ export const getNewsletterSubscribeEndpoint: () => string;
// @beta (undocumented)
export const getNewsletterUnsubscribeEndpoint: () => string;

// @beta
export function getOrderPaymentUrl({ orderId, finishUrl, }: {
orderId: string;
finishUrl?: string;
}, contextInstance?: ShopwareApiInstance): Promise<{
paymentUrl: string;
}>;

// @beta (undocumented)
export const getOrderPaymentUrlEndpoint: (orderId: string) => string;

Expand Down Expand Up @@ -357,13 +349,10 @@ export const getProductsIds: (options?: any, contextInstance?: ShopwareApiInstan
// @beta (undocumented)
export const getProductsIdsEndpoint: () => string;

// @beta @deprecated (undocumented)
export function getResults(term: string, searchCriteria?: SearchCriteria, contextInstance?: ShopwareApiInstance): Promise<ProductListingResult>;

// @beta (undocumented)
export const getSearchEndpoint: () => string;

// @beta (undocumented)
// @beta @deprecated (undocumented)
export function getSearchResults(term: string, searchCriteria?: SearchCriteria, contextInstance?: ShopwareApiInstance): Promise<ProductListingResult>;

// @beta (undocumented)
Expand Down Expand Up @@ -411,17 +400,14 @@ export const getStoreNewsletterSubscribeEndpoint: () => string;
export const getStoreNewsletterUnsubscribeEndpoint: () => string;

// @beta (undocumented)
export function getStoreOrderPaymentUrl(orderId: string, contextInstance?: ShopwareApiInstance): Promise<{
redirectResponse: unknown;
export function getStoreOrderPaymentUrl(orderId: string, finishUrl?: string, errorUrl?: string, contextInstance?: ShopwareApiInstance): Promise<{
redirectUrl: string | null;
apiAlias: string;
}>;

// @beta (undocumented)
export const getStoreOrderPaymentUrlEndpoint: () => string;

// @alpha @deprecated (undocumented)
export function getSuggestedResults(term: string, searchCriteria?: SearchCriteria, contextInstance?: ShopwareApiInstance): Promise<ProductListingResult>;

// @beta (undocumented)
export const getSuggestSearchEndpoint: () => string;

Expand Down

This file was deleted.

24 changes: 0 additions & 24 deletions docs/landing/resources/api/composables.currentpagination.md

This file was deleted.

This file was deleted.

14 changes: 0 additions & 14 deletions docs/landing/resources/api/composables.currentpagination.total.md

This file was deleted.

1 change: 0 additions & 1 deletion docs/landing/resources/api/composables.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
| Interface | Description |
| --- | --- |
| [ApplicationVueContext](./composables.applicationvuecontext.md) | <b><i>(BETA)</i></b> Application Context for Shopware PWA. It's an extended Vue instance. |
| [CurrentPagination](./composables.currentpagination.md) | <b><i>(BETA)</i></b> |
| [IInterceptorCallbackFunction](./composables.iinterceptorcallbackfunction.md) | <b><i>(BETA)</i></b> interface for the callback function of interceptors |
| [IUseAddToCart](./composables.iuseaddtocart.md) | <b><i>(BETA)</i></b> interface for [useAddToCart](./composables.useaddtocart.md) composable |
| [IUseCart](./composables.iusecart.md) | <b><i>(BETA)</i></b> interface for [useCart](./composables.usecart.md) composable |
Expand Down
37 changes: 0 additions & 37 deletions docs/landing/resources/api/shopware-6-client.getorderpaymenturl.md

This file was deleted.

32 changes: 0 additions & 32 deletions docs/landing/resources/api/shopware-6-client.getresults.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
>
> Warning: This API is now obsolete.
>
> use searchProducts instead
>
<b>Signature:</b>

```typescript
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@
> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
>

<b>Signature:</b>

```typescript
export declare function getStoreOrderPaymentUrl(orderId: string, contextInstance?: ShopwareApiInstance): Promise<{
redirectResponse: unknown;
export declare function getStoreOrderPaymentUrl(orderId: string, finishUrl?: string, errorUrl?: string, contextInstance?: ShopwareApiInstance): Promise<{
redirectUrl: string | null;
apiAlias: string;
}>;
```
Expand All @@ -21,10 +20,12 @@ export declare function getStoreOrderPaymentUrl(orderId: string, contextInstance

| Parameter | Type | Description |
| --- | --- | --- |
| orderId | string | |
| orderId | string | Id of an order |
| finishUrl | string | URL where the customer is redirected to after payment is done |
| errorUrl | string | URL where the customer is redirected to after payment fails |
| contextInstance | [ShopwareApiInstance](./shopware-6-client.shopwareapiinstance.md) | |

<b>Returns:</b>

Promise&lt;{ redirectResponse: unknown; apiAlias: string; }&gt;
Promise&lt;{ redirectUrl: string \| null; apiAlias: string; }&gt;

4 changes: 1 addition & 3 deletions docs/landing/resources/api/shopware-6-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,16 @@
| [getCustomerAddresses(contextInstance)](./shopware-6-client.getcustomeraddresses.md) | <b><i>(BETA)</i></b> Get all customer's addresses |
| [getCustomerOrderDetails(orderId, contextInstance, additionalQueryParams)](./shopware-6-client.getcustomerorderdetails.md) | <b><i>(BETA)</i></b> Get order details |
| [getCustomerOrders(contextInstance)](./shopware-6-client.getcustomerorders.md) | <b><i>(BETA)</i></b> Get all customer's orders |
| [getOrderPaymentUrl({ orderId, finishUrl, }, contextInstance)](./shopware-6-client.getorderpaymenturl.md) | <b><i>(BETA)</i></b> Get payment address to redirect user after placing order. |
| [getPage(path, searchCriteria, contextInstance)](./shopware-6-client.getpage.md) | <b><i>(BETA)</i></b> |
| [getPaymentMethodDetails(paymentId, contextInstance)](./shopware-6-client.getpaymentmethoddetails.md) | <b><i>(BETA)</i></b> |
| [getProduct(productId, params, contextInstance)](./shopware-6-client.getproduct.md) | <b><i>(BETA)</i></b> Get the product with passed productId |
| [getProductPage(path, searchCriteria, contextInstance)](./shopware-6-client.getproductpage.md) | <b><i>(BETA)</i></b> |
| [getResults(term, searchCriteria, contextInstance)](./shopware-6-client.getresults.md) | <b><i>(BETA)</i></b> |
| [getSearchResults(term, searchCriteria, contextInstance)](./shopware-6-client.getsearchresults.md) | <b><i>(BETA)</i></b> |
| [getSeoUrls(entityId, languageId, contextInstance)](./shopware-6-client.getseourls.md) | <b><i>(BETA)</i></b> Returns an array of SEO URLs for given entity Can be used for other languages as well by providing the languageId |
| [getSessionContext(contextInstance)](./shopware-6-client.getsessioncontext.md) | <b><i>(BETA)</i></b> Loads session context, containing all session-related data. |
| [getShippingMethodDetails(shippingId, contextInstance)](./shopware-6-client.getshippingmethoddetails.md) | <b><i>(BETA)</i></b> |
| [getStoreNavigation({ requestActiveId, requestRootId, depth, buildTree, searchCriteria, }, contextInstance)](./shopware-6-client.getstorenavigation.md) | <b><i>(BETA)</i></b> |
| [getStoreOrderPaymentUrl(orderId, contextInstance)](./shopware-6-client.getstoreorderpaymenturl.md) | <b><i>(BETA)</i></b> |
| [getStoreOrderPaymentUrl(orderId, finishUrl, errorUrl, contextInstance)](./shopware-6-client.getstoreorderpaymenturl.md) | <b><i>(BETA)</i></b> |
| [getUserCountry(countryId, contextInstance)](./shopware-6-client.getusercountry.md) | <b><i>(BETA)</i></b> |
| [getUserSalutation(salutationId, contextInstance)](./shopware-6-client.getusersalutation.md) | <b><i>(BETA)</i></b> |
| [invokeGet({ address }, contextInstance)](./shopware-6-client.invokeget.md) | <b><i>(BETA)</i></b> Invoke custom GET request to shopware API. Mostly for plugins usage. You can skip domain and pass only endpoint ex. <code>/api/my/endpoint</code> |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface ProductListingResult {
sortings: Sort[];
availableSortings: Sort[];
aggregations: Aggregations;
entity: string;
currentFilters: {
manufacturer: string[];
properties: string[];
Expand Down
2 changes: 1 addition & 1 deletion packages/commons/interfaces/response/SessionContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ShippingMethod } from "../models/checkout/shipping/ShippingMethod";
import { Country } from "../models/system/country/Country";
import { User } from "../models/system/user/User";
import { Currency } from "../models/system/currency/Currency";
import { ShippingAddress } from "../request/GuestOrderParams";
import { ShippingAddress } from "../models/checkout/customer/ShippingAddress";

export interface ContextTokenResponse {
contextToken: string;
Expand Down
12 changes: 12 additions & 0 deletions packages/composables/__tests__/helpers/searchCriteria.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,18 @@ describe("composables searchCriteria", () => {
);
expect(searchCriteria.properties).toStrictEqual(["blue", "black"]);
});
it("should append the search criteria params", () => {
const searchCriteria: any = {};
appendQueryParamsToSearchCriteria(
{ query: "test", sort: "-name" },
searchCriteria
);
expect(searchCriteria.sort).toStrictEqual({
field: "",
name: "-name",
order: "name",
});
});
});

describe("resetSearchCriteria", () => {
Expand Down
Loading

0 comments on commit 33074fd

Please sign in to comment.