From f7f8693b916582bbe6a67b1c4ee549bd48a92f3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20Westk=C3=A4mper?= Date: Wed, 15 Nov 2023 10:33:04 +0200 Subject: [PATCH] Cleanup of GraphQL codegen --- cleanup.js | 14 + package.json | 2 +- src/api/search/generated.ts | 969 ++++++++++++++++++------------------ src/api/search/index.ts | 16 +- src/entries/base.ts | 2 +- 5 files changed, 499 insertions(+), 504 deletions(-) create mode 100644 cleanup.js diff --git a/cleanup.js b/cleanup.js new file mode 100644 index 0000000..8509182 --- /dev/null +++ b/cleanup.js @@ -0,0 +1,14 @@ +import fs from "fs" + +const fileName = "src/api/search/generated.ts" +let fileContents = fs.readFileSync(fileName, "utf8") + +fileContents = fileContents.replaceAll(/export type (Maybe|InputMaybe|Exact|Make|Incremental).*$/gm, "") +fileContents = fileContents.replaceAll(/InputMaybe<(.+)>;$/gm, "$1") +fileContents = fileContents.replaceAll(/Maybe<(.+)>;$/gm, "$1") +fileContents = fileContents.replaceAll(/Scalars\['(ID|String)'\]\['\w+'\]/gm, "string") +fileContents = fileContents.replaceAll(/Scalars\['Boolean'\]\['\w+'\]/gm, "boolean") +fileContents = fileContents.replaceAll(/Scalars\['(Int|Float)'\]\['\w+'\]/gm, "number") +fileContents = fileContents.replaceAll(/Scalars\['Json'\]\['\w+'\]/gm, "unknown") +fileContents = fileContents.replaceAll(/Array<(\w+)>/gm, "$1[]") +fs.writeFileSync(fileName, fileContents.trim()) \ No newline at end of file diff --git a/package.json b/package.json index 4bcd0a5..a578dc7 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "build:docs": "typedoc src/index.ts", "build:site": "npm run build:docs && npm run test:cov && rm -rf site && cp -r./docs ./site && cp -r./examples ./site/examples && cp -r./coverage ./site/coverage", "lint": "eslint 'src/**/*.{ts,tsx}' --cache", - "prettify": "prettier --write \"{src,spec}/**/*.ts\"", + "prettify": "node cleanup.js && prettier --write \"{src,spec}/**/*.ts\"", "test": "jest spec", "test:cov": "jest --coverage spec && make-coverage-badge", "codegen": "graphql-codegen", diff --git a/src/api/search/generated.ts b/src/api/search/generated.ts index f9c99c7..af3dd62 100644 --- a/src/api/search/generated.ts +++ b/src/api/search/generated.ts @@ -1,33 +1,11 @@ -export type Maybe = T -export type InputMaybe = T -export type Exact = { - [K in keyof T]: T[K] -} -export type MakeOptional = Omit & { - [SubKey in K]?: Maybe -} -export type MakeMaybe = Omit & { - [SubKey in K]: Maybe -} -export type MakeEmpty< - T extends { [key: string]: unknown }, - K extends keyof T, -> = { [_ in K]?: never } -export type Incremental = - | T - | { - [P in keyof T]?: P extends " $fragmentName" | "__typename" - ? T[P] - : never - } /** All built-in and custom scalars, mapped to their actual values */ export interface Scalars { - ID: { input: string; output: string } - String: { input: string; output: string } - Boolean: { input: boolean; output: boolean } - Int: { input: number; output: number } - Float: { input: number; output: number } - Json: { input: unknown; output: unknown } + ID: { input: string; output: string; } + String: { input: string; output: string; } + Boolean: { input: boolean; output: boolean; } + Int: { input: number; output: number; } + Float: { input: number; output: number; } + Json: { input: unknown; output: unknown; } } /** @@ -60,29 +38,29 @@ export interface Scalars { * */ export interface InputSearchBoost { - /** Joins nested filters with logical AND */ - all?: InputMaybe> - /** Joins nested filters with logical OR */ - any?: InputMaybe> - /** Product field to apply filter on */ - field?: InputMaybe - /** - * - * If `true`, matches all products which have the value on selected field. - * If `false`, matches all products which have no value in selected field. - * - */ - hasValue?: InputMaybe - /** Joins nested filters with logical AND and inverts match */ - not?: InputMaybe> - /** List of prefixes to match */ - prefix?: InputMaybe> - /** List of range filters to apply */ - range?: InputMaybe> - /** List of values to filter by, joined by OR operator */ - value?: InputMaybe> - /** boost weight */ - weight: Scalars["Float"]["input"] + /** Joins nested filters with logical AND */ + all?: InputSearchFilter[] + /** Joins nested filters with logical OR */ + any?: InputSearchFilter[] + /** Product field to apply filter on */ + field?: string + /** + * + * If `true`, matches all products which have the value on selected field. + * If `false`, matches all products which have no value in selected field. + * + */ + hasValue?: boolean + /** Joins nested filters with logical AND and inverts match */ + not?: InputSearchFilter[] + /** List of prefixes to match */ + prefix?: string[] + /** List of range filters to apply */ + range?: InputSearchRangeFilter[] + /** List of values to filter by, joined by OR operator */ + value?: string[] + /** boost weight */ + weight: number; } /** @@ -117,26 +95,26 @@ export interface InputSearchBoost { * */ export interface InputSearchFacetConfig { - /** If facet is disabled, it won't be calculated. Used to disable facets created in dashboard */ - enabled?: InputMaybe - /** Field on which facet will be calculated */ - field?: InputMaybe - /** Facet ID */ - id: Scalars["String"]["input"] - /** Adds a infix filter on facet's terms. Only applies if type is `terms`. Cannot be combined with prefix */ - infix?: InputMaybe> - /** This name is returned with search response. Used as a display name in frontend */ - name?: InputMaybe - /** Returned facet order. Only applies if type is `terms` */ - order?: InputMaybe - /** Returned facet position in search response facets array */ - position?: InputMaybe - /** Adds a prefix filter on facet's terms. Only applies if type is `terms`. Cannot be combined with infix */ - prefix?: InputMaybe> - /** How many facet terms to return. Only applies if type is `terms` */ - size?: InputMaybe - /** Facet type */ - type?: InputMaybe + /** If facet is disabled, it won't be calculated. Used to disable facets created in dashboard */ + enabled?: boolean + /** Field on which facet will be calculated */ + field?: string + /** Facet ID */ + id: string; + /** Adds a infix filter on facet's terms. Only applies if type is `terms`. Cannot be combined with prefix */ + infix?: string[] + /** This name is returned with search response. Used as a display name in frontend */ + name?: string + /** Returned facet order. Only applies if type is `terms` */ + order?: SearchFacetOrder + /** Returned facet position in search response facets array */ + position?: number + /** Adds a prefix filter on facet's terms. Only applies if type is `terms`. Cannot be combined with infix */ + prefix?: string[] + /** How many facet terms to return. Only applies if type is `terms` */ + size?: number + /** Facet type */ + type?: SearchFacetType } /** @@ -272,27 +250,27 @@ export interface InputSearchFacetConfig { * */ export interface InputSearchFilter { - /** Joins nested filters with logical AND */ - all?: InputMaybe> - /** Joins nested filters with logical OR */ - any?: InputMaybe> - /** Product field to apply filter on */ - field?: InputMaybe - /** - * - * If `true`, matches all products which have the value on selected field. - * If `false`, matches all products which have no value in selected field. - * - */ - hasValue?: InputMaybe - /** Joins nested filters with logical AND and inverts match */ - not?: InputMaybe> - /** List of prefixes to match */ - prefix?: InputMaybe> - /** List of range filters to apply */ - range?: InputMaybe> - /** List of values to filter by, joined by OR operator */ - value?: InputMaybe> + /** Joins nested filters with logical AND */ + all?: InputSearchFilter[] + /** Joins nested filters with logical OR */ + any?: InputSearchFilter[] + /** Product field to apply filter on */ + field?: string + /** + * + * If `true`, matches all products which have the value on selected field. + * If `false`, matches all products which have no value in selected field. + * + */ + hasValue?: boolean + /** Joins nested filters with logical AND and inverts match */ + not?: InputSearchFilter[] + /** List of prefixes to match */ + prefix?: string[] + /** List of range filters to apply */ + range?: InputSearchRangeFilter[] + /** List of values to filter by, joined by OR operator */ + value?: string[] } /** @@ -315,25 +293,25 @@ export interface InputSearchFilter { * */ export interface InputSearchHighlight { - postTag: Scalars["String"]["input"] - preTag: Scalars["String"]["input"] + postTag: string; + preTag: string; } export interface InputSearchKeywords { - /** List of custom boosts */ - boost?: InputMaybe> - /** Matches all objects if query is not provided or empty. Defaults to false. */ - emptyQueryMatchesAll?: InputMaybe - /** List of filters. Values are joined with AND operator */ - filter?: InputMaybe> - /** Offset of returned keyword list. Used for pagination, use together with `size` parameter */ - from?: InputMaybe - /** Highlight tag */ - highlight?: InputMaybe - /** How many keywords will be returned */ - size?: InputMaybe - /** Sets how results should be sorted. After sorting by all the options provided in sort param, or in case sort param is not set, results will be sorted by relevance. */ - sort?: InputMaybe> + /** List of custom boosts */ + boost?: InputSearchBoost[] + /** Matches all objects if query is not provided or empty. Defaults to false. */ + emptyQueryMatchesAll?: boolean + /** List of filters. Values are joined with AND operator */ + filter?: InputSearchTopLevelFilter[] + /** Offset of returned keyword list. Used for pagination, use together with `size` parameter */ + from?: number + /** Highlight tag */ + highlight?: InputSearchHighlight + /** How many keywords will be returned */ + size?: number + /** Sets how results should be sorted. After sorting by all the options provided in sort param, or in case sort param is not set, results will be sorted by relevance. */ + sort?: InputSearchSort[] } /** @@ -345,83 +323,83 @@ export interface InputSearchKeywords { * */ export interface InputSearchPin { - /** Which product field will be used to match value on. If not provided, `productId` is used */ - field?: InputMaybe - /** Where the pinned product will appear on the search page. Starts from 1 */ - position: Scalars["Int"]["input"] - /** If product field matches any of the provided values, pin will be applied. Currently, only exact match of values is supported */ - value: Array + /** Which product field will be used to match value on. If not provided, `productId` is used */ + field?: string + /** Where the pinned product will appear on the search page. Starts from 1 */ + position: number; + /** If product field matches any of the provided values, pin will be applied. Currently, only exact match of values is supported */ + value: string[]; } export interface InputSearchProducts { - /** List of custom boosts */ - boost?: InputMaybe> - /** Provide category id if search engine is used to get results for category pages. provide either `categoryId` or `categoryPath`, don't use both */ - categoryId?: InputMaybe - /** Provide category path if search engine is used to get results for category pages. provide either `categoryId` or `categoryPath`, don't use both */ - categoryPath?: InputMaybe - /** Returns only one result for each unique value for provided field. Can be used to group product variations (e.g. different colors) */ - collapse?: InputMaybe - /** Enables to add or modify facet configuration on query time. If facet with the same ID is present in the dashboard configuration, their parameters will be merged. In that case, only partial facet parameters can be provided. If facet is not present in the configuration, all required params must be present. */ - customFacets?: InputMaybe> - /** Matches all objects if query is not provided or empty. Defaults to true if no name provided, false for serp and autocomplete */ - emptyQueryMatchesAll?: InputMaybe - /** `(Private key only)` Overwrite default exclusions behavior */ - exclusionBehaviour?: InputMaybe - /** List of facet ID's, the ones configured in the dashboard, to be counted. The search engine will automatically filter out irrelevant facets depending on search queries, so not all facets listed here may be returned. `*` selects all facets */ - facets?: InputMaybe> - /** List of filters. Values are joined with AND operator */ - filter?: InputMaybe> - /** Offset of returned product list. Used for pagination, use together with `size` parameter */ - from?: InputMaybe - /** `(Private key only)` Overwrite default out of stock behavior */ - outOfStockBehaviour?: InputMaybe - /** Used to provide brand, category, and other affinities from Nosto personalization frontend script. These will be different for each user */ - personalizationBoost?: InputMaybe> - /** Personalization impact in comparison to relevance and other boosts */ - personalizationWeight?: InputMaybe - /** Used to change positions of returned products. Pinning rearranges returned product positions, which means that if product is not returned with search results, it won't be pinned */ - pin?: InputMaybe> - /** Same format as filter, but is always applied before counting facets. `excludeFacets` param is not allowed */ - preFilter?: InputMaybe> - /** - * Queries data only from searchable fields with specified priorities. Use [ `high`, `medium`, `low` ] for serp. - * Use [ `high`, `medium` ] for autocomplete - */ - queryFields?: InputMaybe> - /** How much weight has relevance in comparison to other scores (e.g. boost) */ - relevanceWeight?: InputMaybe - /** `(Private key only)` Allow private fields to be returned in search results and used in query parameters */ - showPrivateFields?: InputMaybe - /** How many products will be returned */ - size?: InputMaybe - /** Sets how results should be sorted. After sorting by all the options provided in sort param, or in case sort param is not set, results will be sorted by relevance. For example, if you set sort by availability status, products with the same availability status will be sorted by relevance. */ - sort?: InputMaybe> - /** Selects product variation or currency */ - variationId?: InputMaybe + /** List of custom boosts */ + boost?: InputSearchBoost[] + /** Provide category id if search engine is used to get results for category pages. provide either `categoryId` or `categoryPath`, don't use both */ + categoryId?: string + /** Provide category path if search engine is used to get results for category pages. provide either `categoryId` or `categoryPath`, don't use both */ + categoryPath?: string + /** Returns only one result for each unique value for provided field. Can be used to group product variations (e.g. different colors) */ + collapse?: string + /** Enables to add or modify facet configuration on query time. If facet with the same ID is present in the dashboard configuration, their parameters will be merged. In that case, only partial facet parameters can be provided. If facet is not present in the configuration, all required params must be present. */ + customFacets?: InputSearchFacetConfig[] + /** Matches all objects if query is not provided or empty. Defaults to true if no name provided, false for serp and autocomplete */ + emptyQueryMatchesAll?: boolean + /** `(Private key only)` Overwrite default exclusions behavior */ + exclusionBehaviour?: SearchExclusionBehaviour + /** List of facet ID's, the ones configured in the dashboard, to be counted. The search engine will automatically filter out irrelevant facets depending on search queries, so not all facets listed here may be returned. `*` selects all facets */ + facets?: string[] + /** List of filters. Values are joined with AND operator */ + filter?: InputSearchTopLevelFilter[] + /** Offset of returned product list. Used for pagination, use together with `size` parameter */ + from?: number + /** `(Private key only)` Overwrite default out of stock behavior */ + outOfStockBehaviour?: SearchOutOfStockBehaviour + /** Used to provide brand, category, and other affinities from Nosto personalization frontend script. These will be different for each user */ + personalizationBoost?: InputSearchBoost[] + /** Personalization impact in comparison to relevance and other boosts */ + personalizationWeight?: number + /** Used to change positions of returned products. Pinning rearranges returned product positions, which means that if product is not returned with search results, it won't be pinned */ + pin?: InputSearchPin[] + /** Same format as filter, but is always applied before counting facets. `excludeFacets` param is not allowed */ + preFilter?: InputSearchFilter[] + /** + * Queries data only from searchable fields with specified priorities. Use [ `high`, `medium`, `low` ] for serp. + * Use [ `high`, `medium` ] for autocomplete + */ + queryFields?: SearchQueryField[] + /** How much weight has relevance in comparison to other scores (e.g. boost) */ + relevanceWeight?: number + /** `(Private key only)` Allow private fields to be returned in search results and used in query parameters */ + showPrivateFields?: boolean + /** How many products will be returned */ + size?: number + /** Sets how results should be sorted. After sorting by all the options provided in sort param, or in case sort param is not set, results will be sorted by relevance. For example, if you set sort by availability status, products with the same availability status will be sorted by relevance. */ + sort?: InputSearchSort[] + /** Selects product variation or currency */ + variationId?: string } export interface InputSearchQuery { - /** Your account ID */ - accountId?: InputMaybe - /** Any custom rules that should be added in this search request. These rules are appended to the rule list defined in nosto dashboard */ - customRules?: InputMaybe> - /** `(Private key only)` Returns scoring information for each object if true. This should only be used for debugging as performance will suffer. If not needed, omit this parameter */ - explain?: InputMaybe - /** Keyword specific parameters */ - keywords?: InputMaybe - /** Product specific parameters */ - products?: InputMaybe - /** Search text (raw user input) */ - query?: InputMaybe - redirect?: InputMaybe - /** List of rule ID's or ID matching patterns with wildcards. Patterns [ `global-*`, `query-*` ] should be used here to match all rules created in dashboard */ - rules?: InputMaybe> - /** Segment ID's user belongs to */ - segments?: InputMaybe> - sessionParams?: InputMaybe - /** `(Private key only)` Overwrites current time. Used to trigger scheduled rules ahead of schedule */ - time?: InputMaybe + /** Your account ID */ + accountId?: string + /** Any custom rules that should be added in this search request. These rules are appended to the rule list defined in nosto dashboard */ + customRules?: InputSearchRule[] + /** `(Private key only)` Returns scoring information for each object if true. This should only be used for debugging as performance will suffer. If not needed, omit this parameter */ + explain?: boolean + /** Keyword specific parameters */ + keywords?: InputSearchKeywords + /** Product specific parameters */ + products?: InputSearchProducts + /** Search text (raw user input) */ + query?: string + redirect?: string + /** List of rule ID's or ID matching patterns with wildcards. Patterns [ `global-*`, `query-*` ] should be used here to match all rules created in dashboard */ + rules?: string[] + /** Segment ID's user belongs to */ + segments?: string[] + sessionParams?: InputSearchQuery + /** `(Private key only)` Overwrites current time. Used to trigger scheduled rules ahead of schedule */ + time?: number } /** @@ -455,29 +433,29 @@ export interface InputSearchQuery { * */ export interface InputSearchRangeFilter { - /** Greater than */ - gt?: InputMaybe - /** Greater than or equals */ - gte?: InputMaybe - /** Lower than */ - lt?: InputMaybe - /** Lower than or equals */ - lte?: InputMaybe + /** Greater than */ + gt?: string + /** Greater than or equals */ + gte?: string + /** Lower than */ + lt?: string + /** Lower than or equals */ + lte?: string } /** Rules allow search query modification based on search parameters */ export interface InputSearchRule { - /** Used to disable rules creating through dashboard */ - enabled?: InputMaybe - id: Scalars["String"]["input"] - /** Condition that must be met for query to match */ - match?: InputMaybe - /** User friendly name */ - name?: InputMaybe - /** Defines when the rule will be applied based on date/time */ - schedule?: InputMaybe> - /** Search query parameters that will be set if rule matches. Same format as search query itself but not all params are allowed */ - set?: InputMaybe + /** Used to disable rules creating through dashboard */ + enabled?: boolean + id: string; + /** Condition that must be met for query to match */ + match?: InputSearchRuleMatch + /** User friendly name */ + name?: string + /** Defines when the rule will be applied based on date/time */ + schedule?: InputSearchSchedule[] + /** Search query parameters that will be set if rule matches. Same format as search query itself but not all params are allowed */ + set?: InputSearchQuery } /** @@ -590,37 +568,37 @@ export interface InputSearchRule { * */ export interface InputSearchRuleMatch { - /** Applies logical AND to nested rule match clauses. Matches if all of them match */ - all?: InputMaybe> - /** Applies logical OR to nested rule match clauses. Matches if any of them match */ - any?: InputMaybe> - /** If set to `true`, rule will always match. Skip this parameter if it's not needed, does not accept `false` value. Used to create global rules in dashboard */ - everything?: InputMaybe - /** Expected values to be compared against. Rule matches if at least one of them matches */ - function?: InputMaybe - /** Applies logical NOT to rule match clause. Matches if nested clause does not match */ - not?: InputMaybe - /** Param from search query from where the value will be extracted */ - param?: InputMaybe - /** Expected values to be compared against. Rule matches if at least one of them matches */ - value?: InputMaybe> + /** Applies logical AND to nested rule match clauses. Matches if all of them match */ + all?: InputSearchRuleMatch[] + /** Applies logical OR to nested rule match clauses. Matches if any of them match */ + any?: InputSearchRuleMatch[] + /** If set to `true`, rule will always match. Skip this parameter if it's not needed, does not accept `false` value. Used to create global rules in dashboard */ + everything?: boolean + /** Expected values to be compared against. Rule matches if at least one of them matches */ + function?: SearchParamComparisonFunction + /** Applies logical NOT to rule match clause. Matches if nested clause does not match */ + not?: InputSearchRuleMatch + /** Param from search query from where the value will be extracted */ + param?: string + /** Expected values to be compared against. Rule matches if at least one of them matches */ + value?: string[] } /** Defines when the rule will be applied based on date/time */ export interface InputSearchSchedule { - /** Date in format `yyyy-MM-dd'T'HH:mm:ss`. Only applies if type is `ONE_TIME` */ - from?: InputMaybe - /** Format example `12:00:00`. Only applies if type is `weekly` */ - fromTime?: InputMaybe - /** Format example `Europe/Paris` */ - timezone?: InputMaybe - /** Date in format `yyyy-MM-dd'T'HH:mm:ss`. Only applies if type is `ONE_TIME` */ - to?: InputMaybe - /** Format example `16:00:00`. Only applies if type is `weekly` */ - toTime?: InputMaybe - type?: InputMaybe - /** Array of days to trigger the rule. Only applies if type is `weekly` */ - weekDays?: InputMaybe> + /** Date in format `yyyy-MM-dd'T'HH:mm:ss`. Only applies if type is `ONE_TIME` */ + from?: string + /** Format example `12:00:00`. Only applies if type is `weekly` */ + fromTime?: string + /** Format example `Europe/Paris` */ + timezone?: string + /** Date in format `yyyy-MM-dd'T'HH:mm:ss`. Only applies if type is `ONE_TIME` */ + to?: string + /** Format example `16:00:00`. Only applies if type is `weekly` */ + toTime?: string + type?: SearchRuleScheduleType + /** Array of days to trigger the rule. Only applies if type is `weekly` */ + weekDays?: SearchRuleScheduleWeekday[] } /** @@ -635,367 +613,372 @@ export interface InputSearchSchedule { * */ export interface InputSearchSort { - field: Scalars["String"]["input"] - order: SearchSortOrder + field: string; + order: SearchSortOrder; } /** Same as `InputSearchFilter` type, but accepts an additional optional parameter `excludeFacets` */ export interface InputSearchTopLevelFilter { - /** Joins nested filters with logical AND */ - all?: InputMaybe> - /** Joins nested filters with logical OR */ - any?: InputMaybe> - /** List of facet ID's to which this filter should not be applied. (default: all facets with the same field as filter if filter contains field, otherwise empty) */ - excludeFacets?: InputMaybe> - /** Product field to apply filter on */ - field?: InputMaybe - /** - * - * If true, matches all products which have the value on selected field. - * If false, matches all products which have no value in selected field. - * - */ - hasValue?: InputMaybe - /** Joins nested filters with logical AND and inverts match */ - not?: InputMaybe> - /** List of prefixes to match */ - prefix?: InputMaybe> - /** List of range filters to apply */ - range?: InputMaybe> - /** List of values to filter by, joined by OR operator */ - value?: InputMaybe> + /** Joins nested filters with logical AND */ + all?: InputSearchFilter[] + /** Joins nested filters with logical OR */ + any?: InputSearchFilter[] + /** List of facet ID's to which this filter should not be applied. (default: all facets with the same field as filter if filter contains field, otherwise empty) */ + excludeFacets?: string[] + /** Product field to apply filter on */ + field?: string + /** + * + * If true, matches all products which have the value on selected field. + * If false, matches all products which have no value in selected field. + * + */ + hasValue?: boolean + /** Joins nested filters with logical AND and inverts match */ + not?: InputSearchFilter[] + /** List of prefixes to match */ + prefix?: string[] + /** List of range filters to apply */ + range?: InputSearchRangeFilter[] + /** List of values to filter by, joined by OR operator */ + value?: string[] } /** Query search engine for search results */ export interface Query { - search?: Maybe + search?: SearchResult } + /** Query search engine for search results */ export interface QuerySearchArgs { - accountId?: InputMaybe - customRules?: InputMaybe> - explain?: InputMaybe - keywords?: InputMaybe - products?: InputMaybe - query?: InputMaybe - redirect?: InputMaybe - rules?: InputMaybe> - segments?: InputMaybe> - sessionParams?: InputMaybe - time?: InputMaybe + accountId?: string + customRules?: InputSearchRule[] + explain?: boolean + keywords?: InputSearchKeywords + products?: InputSearchProducts + query?: string + redirect?: string + rules?: string[] + segments?: string[] + sessionParams?: InputSearchQuery + time?: number } export interface SearchAutocorrect { - /** Original query value before autocorrect */ - original: Scalars["String"]["output"] + /** Original query value before autocorrect */ + original: string; } /** Determines how excluded products are handled */ export type SearchExclusionBehaviour = - /** Moves excluded products to the end of search results */ - | "deboost" - /** Hides excluded products */ - | "hide" - /** Does not handle excluded products in any special way */ - | "none" + /** Moves excluded products to the end of search results */ + | 'deboost' + /** Hides excluded products */ + | 'hide' + /** Does not handle excluded products in any special way */ + | 'none'; /** Gives additional info on why search results are the way they are. */ export interface SearchExplain { - /** Matched rules are returned */ - matchedRules: Array + /** Matched rules are returned */ + matchedRules: SearchExplainRule[]; } export interface SearchExplainRule { - id: Scalars["String"]["output"] - /** Name of the rule that matched */ - name?: Maybe - /** JSON object scalar, parse on frontend. Which params were set after triggering query rule */ - set?: Maybe + id: string; + /** Name of the rule that matched */ + name?: string + /** JSON object scalar, parse on frontend. Which params were set after triggering query rule */ + set?: unknown } -export type SearchFacet = SearchStatsFacet | SearchTermsFacet +export type SearchFacet = SearchStatsFacet | SearchTermsFacet; /** Returned facet order. Only applies if facet type is `terms` */ export type SearchFacetOrder = - /** Order by term count */ - | "count" - /** Order by term name */ - | "index" + /** Order by term count */ + | 'count' + /** Order by term name */ + | 'index'; export interface SearchFacetTerm { - /** How many products had this term */ - count: Scalars["Int"]["output"] - /** Was this term selected, to add selected checkbox in frontend */ - selected: Scalars["Boolean"]["output"] - /** Term value */ - value: Scalars["String"]["output"] + /** How many products had this term */ + count: number; + /** Was this term selected, to add selected checkbox in frontend */ + selected: boolean; + /** Term value */ + value: string; } /** Type of facet */ export type SearchFacetType = - /** Returns min and max values for a numeric field */ - | "stats" - /** Returns all unique terms in a field */ - | "terms" + /** Returns min and max values for a numeric field */ + | 'stats' + /** Returns all unique terms in a field */ + | 'terms'; export interface SearchHighlight { - keyword?: Maybe + keyword?: string } export interface SearchKeyword { - _explain?: Maybe - _highlight?: Maybe - _redirect?: Maybe - _score?: Maybe - facets: Array - keyword: Scalars["String"]["output"] - position?: Maybe - /** @deprecated Use position instead. */ - priority: Scalars["Int"]["output"] - total: Scalars["Int"]["output"] + _explain?: unknown + _highlight?: SearchHighlight + _redirect?: string + _score?: number + facets: SearchFacet[]; + keyword: string; + position?: number + /** @deprecated Use position instead. */ + priority: number; + total: number; } export interface SearchKeywords { - /** Unmodified request parameter `from` to be used for further pagination */ - from?: Maybe - /** If main search query returned no results and fuzzy search was triggered */ - fuzzy?: Maybe - /** Keyword list */ - hits: Array - /** Unmodified request parameter `size` to be used for further pagination */ - size?: Maybe - /** How many products were found */ - total: Scalars["Int"]["output"] + /** Unmodified request parameter `from` to be used for further pagination */ + from?: number + /** If main search query returned no results and fuzzy search was triggered */ + fuzzy?: boolean + /** Keyword list */ + hits: SearchKeyword[]; + /** Unmodified request parameter `size` to be used for further pagination */ + size?: number + /** How many products were found */ + total: number; } /** Determines how out of stock products are handled */ export type SearchOutOfStockBehaviour = - /** Moves out of stock products to the end of search results */ - | "deboost" - /** Hides out of stock products */ - | "hide" - /** Does not handle out of stock products in any special way */ - | "none" + /** Moves out of stock products to the end of search results */ + | 'deboost' + /** Hides out of stock products */ + | 'hide' + /** Does not handle out of stock products in any special way */ + | 'none'; /** Defines how input values and expected values are compared */ export type SearchParamComparisonFunction = - /** Applies partial match on param value from expected values list */ - | "contains" - /** Applies stemming algorithm to param values and expected values and does an exact match of outputs */ - | "stemmed" - /** Applies stemming algorithm and does partial match on param value from expected values list */ - | "stemmedContains" + /** Applies partial match on param value from expected values list */ + | 'contains' + /** Applies stemming algorithm to param values and expected values and does an exact match of outputs */ + | 'stemmed' + /** Applies stemming algorithm and does partial match on param value from expected values list */ + | 'stemmedContains'; export interface SearchProduct { - _explain?: Maybe - _pinned?: Maybe - _score?: Maybe - affinities?: Maybe - ageGroup?: Maybe - ai?: Maybe - alternateImageUrls?: Maybe> - availability?: Maybe - available?: Maybe - brand?: Maybe - categories?: Maybe> - categoryIds?: Maybe> - condition?: Maybe - customFields?: Maybe> - datePublished?: Maybe - description?: Maybe - extra?: Maybe> - gender?: Maybe - googleCategory?: Maybe - gtin?: Maybe - /** Product image url */ - imageUrl?: Maybe - inventoryLevel?: Maybe - isExcluded?: Maybe - listPrice?: Maybe - /** Product Name */ - name?: Maybe - onDiscount?: Maybe - pid?: Maybe - price?: Maybe - priceCurrencyCode?: Maybe - priceText?: Maybe - productId?: Maybe - ratingValue?: Maybe - realVariantIds?: Maybe> - reviewCount?: Maybe - saleable?: Maybe - skus?: Maybe> - stats?: Maybe - supplierCost?: Maybe - tags1?: Maybe> - tags2?: Maybe> - tags3?: Maybe> - /** Product thumbnail url */ - thumbUrl?: Maybe - unitPricingBaseMeasure?: Maybe - unitPricingMeasure?: Maybe - unitPricingUnit?: Maybe - /** Product page url */ - url?: Maybe - variantId?: Maybe - variations?: Maybe> + _explain?: unknown + _pinned?: boolean + _score?: number + affinities?: SearchProductAffinities + ageGroup?: string + ai?: SearchProductAiDetected + alternateImageUrls?: string[] + availability?: string + available?: boolean + brand?: string + categories?: string[] + categoryIds?: string[] + condition?: string + customFields?: SearchProductCustomField[] + datePublished?: number + description?: string + extra?: SearchProductExtra[] + gender?: string + googleCategory?: string + gtin?: string + /** Product image url */ + imageUrl?: string + inventoryLevel?: number + isExcluded?: boolean + listPrice?: number + /** Product Name */ + name?: string + onDiscount?: boolean + pid?: string + price?: number + priceCurrencyCode?: string + priceText?: string + productId?: string + ratingValue?: number + realVariantIds?: string[] + reviewCount?: number + saleable?: boolean + skus?: SearchProductSku[] + stats?: SearchProductStats + supplierCost?: number + tags1?: string[] + tags2?: string[] + tags3?: string[] + /** Product thumbnail url */ + thumbUrl?: string + unitPricingBaseMeasure?: number + unitPricingMeasure?: number + unitPricingUnit?: string + /** Product page url */ + url?: string + variantId?: string + variations?: SearchProductKeyedVariation[] } export interface SearchProductAiDetected { - dominantColors?: Maybe> - overridingColor?: Maybe - primaryColor?: Maybe + dominantColors?: string[] + overridingColor?: string + primaryColor?: string } export interface SearchProductAffinities { - brand?: Maybe - categories?: Maybe> - color?: Maybe> - size?: Maybe> + brand?: string + categories?: string[] + color?: string[] + size?: string[] } export interface SearchProductCustomField { - key: Scalars["String"]["output"] - value: Scalars["String"]["output"] + key: string; + value: string; } export interface SearchProductExtra { - key: Scalars["String"]["output"] - value: Array + key: string; + value: string[]; } export interface SearchProductKeyedVariation { - key: Scalars["String"]["output"] - value: SearchVariationValue + key: string; + value: SearchVariationValue; } export interface SearchProductSku { - ai?: Maybe - availability?: Maybe - customFields?: Maybe> - id?: Maybe - imageUrl?: Maybe - inventoryLevel?: Maybe - listPrice?: Maybe - name?: Maybe - price?: Maybe - priceText?: Maybe - url?: Maybe + ai?: SearchProductAiDetected + availability?: string + customFields?: SearchProductCustomField[] + id?: string + imageUrl?: string + inventoryLevel?: number + listPrice?: number + name?: string + price?: number + priceText?: string + url?: string } export interface SearchProductStats { - age?: Maybe - availabilityRatio?: Maybe - buys?: Maybe - cartRatio?: Maybe - clicks?: Maybe - conversion?: Maybe - discount?: Maybe - impressions?: Maybe - inventoryLevel?: Maybe - inventoryTurnover?: Maybe - listPrice?: Maybe - margin?: Maybe - marginPercentage?: Maybe - orders?: Maybe - price?: Maybe - profitPerImpression?: Maybe - profitPerView?: Maybe - published?: Maybe - ratingValue?: Maybe - revenue?: Maybe - revenuePerImpression?: Maybe - revenuePerView?: Maybe - reviewCount?: Maybe - views?: Maybe + age?: number + availabilityRatio?: number + buys?: number + cartRatio?: number + clicks?: number + conversion?: number + discount?: number + impressions?: number + inventoryLevel?: number + inventoryTurnover?: number + listPrice?: number + margin?: number + marginPercentage?: number + orders?: number + price?: number + profitPerImpression?: number + profitPerView?: number + published?: number + ratingValue?: number + revenue?: number + revenuePerImpression?: number + revenuePerView?: number + reviewCount?: number + views?: number } export interface SearchProducts { - /** Unmodified request parameter `categoryId` */ - categoryId?: Maybe - /** Unmodified request parameter `categoryPath` */ - categoryPath?: Maybe - /** Returns only one result for each unique value for provided field. Can be used to group product variations (e.g. different colors) */ - collapse?: Maybe - /** Facet list */ - facets?: Maybe> - /** Unmodified request parameter `from` to be used for further pagination */ - from?: Maybe - /** If main search query returned no results and fuzzy search was triggered */ - fuzzy?: Maybe - /** Product list */ - hits: Array - /** Unmodified request parameter `size` to be used for further pagination */ - size?: Maybe - /** How many products were found */ - total: Scalars["Int"]["output"] + /** Unmodified request parameter `categoryId` */ + categoryId?: string + /** Unmodified request parameter `categoryPath` */ + categoryPath?: string + /** Returns only one result for each unique value for provided field. Can be used to group product variations (e.g. different colors) */ + collapse?: string + /** Facet list */ + facets?: SearchFacet[] + /** Unmodified request parameter `from` to be used for further pagination */ + from?: number + /** If main search query returned no results and fuzzy search was triggered */ + fuzzy?: boolean + /** Product list */ + hits: SearchProduct[]; + /** Unmodified request parameter `size` to be used for further pagination */ + size?: number + /** How many products were found */ + total: number; } /** Searchable fields of priority */ export type SearchQueryField = - /** Searchable fields with `High` priority */ - | "high" - /** Searchable fields with `Low` priority */ - | "low" - /** Searchable fields with `Medium` priority */ - | "medium" + /** Searchable fields with `High` priority */ + | 'high' + /** Searchable fields with `Low` priority */ + | 'low' + /** Searchable fields with `Medium` priority */ + | 'medium'; /** Search response */ export interface SearchResult { - /** Returned if autocorrect was triggered */ - autocorrect?: Maybe - /** Gives additional info on why search results are the way they are. Returned if request was sent with `explain: true` parameter. */ - explain?: Maybe - /** Keywords response */ - keywords?: Maybe - /** Product response */ - products?: Maybe - /** Search text the results were returned for */ - query?: Maybe - /** Returns redirect url if redirect rule matched */ - redirect?: Maybe -} - -export type SearchRuleScheduleType = "ONE_TIME" | "WEEKLY" + /** Returned if autocorrect was triggered */ + autocorrect?: SearchAutocorrect + /** Gives additional info on why search results are the way they are. Returned if request was sent with `explain: true` parameter. */ + explain?: SearchExplain + /** Keywords response */ + keywords?: SearchKeywords + /** Product response */ + products?: SearchProducts + /** Search text the results were returned for */ + query?: string + /** Returns redirect url if redirect rule matched */ + redirect?: string +} + +export type SearchRuleScheduleType = + | 'ONE_TIME' + | 'WEEKLY'; export type SearchRuleScheduleWeekday = - | "FRIDAY" - | "MONDAY" - | "SATURDAY" - | "SUNDAY" - | "THURSDAY" - | "TUESDAY" - | "WEDNESDAY" + | 'FRIDAY' + | 'MONDAY' + | 'SATURDAY' + | 'SUNDAY' + | 'THURSDAY' + | 'TUESDAY' + | 'WEDNESDAY'; /** Order of the sort */ -export type SearchSortOrder = "asc" | "desc" +export type SearchSortOrder = + | 'asc' + | 'desc'; export interface SearchStatsFacet { - /** Numeric field for which min/max values were calculated */ - field: Scalars["String"]["output"] - id: Scalars["String"]["output"] - /** Maximum value of faceted field */ - max: Scalars["Float"]["output"] - /** Minimum value of faceted field */ - min: Scalars["Float"]["output"] - name: Scalars["String"]["output"] - type: SearchFacetType + /** Numeric field for which min/max values were calculated */ + field: string; + id: string; + /** Maximum value of faceted field */ + max: number; + /** Minimum value of faceted field */ + min: number; + name: string; + type: SearchFacetType; } export interface SearchTermsFacet { - /** Facet term list */ - data: Array - /** Field from which terms were calculated */ - field: Scalars["String"]["output"] - id: Scalars["String"]["output"] - name: Scalars["String"]["output"] - type: SearchFacetType + /** Facet term list */ + data: SearchFacetTerm[]; + /** Field from which terms were calculated */ + field: string; + id: string; + name: string; + type: SearchFacetType; } export interface SearchVariationValue { - availability?: Maybe - listPrice?: Maybe - price?: Maybe - priceCurrencyCode?: Maybe -} + availability?: string + listPrice?: number + price?: number + priceCurrencyCode?: string +} \ No newline at end of file diff --git a/src/api/search/index.ts b/src/api/search/index.ts index 9b93217..fcacd38 100644 --- a/src/api/search/index.ts +++ b/src/api/search/index.ts @@ -1,24 +1,22 @@ -import { InputMaybe, InputSearchQuery } from "./generated" +import { InputSearchQuery } from "./generated" /** * @group Nosto Client * @category Search Types */ export interface InputSearchQueryWithFields extends InputSearchQuery { - products?: InputMaybe<{ + products?: { /** * The fields to return in the response. */ - fields?: InputMaybe - }> & - InputSearchQuery["products"] - keywords?: InputMaybe<{ + fields?: string[] + } & InputSearchQuery["products"] + keywords?: { /** * The fields to return in the response. */ - fields?: InputMaybe - }> & - InputSearchQuery["keywords"] + fields?: string[] + } & InputSearchQuery["keywords"] } export * from "./generated" diff --git a/src/entries/base.ts b/src/entries/base.ts index 3db7719..def014d 100644 --- a/src/entries/base.ts +++ b/src/entries/base.ts @@ -60,4 +60,4 @@ export { SearchStatsFacet, SearchTermsFacet, SearchVariationValue, -} from "../api/search" +} from "../api/search" \ No newline at end of file