Skip to content

Commit

Permalink
Merge branch 'master' into f/slug-w-id
Browse files Browse the repository at this point in the history
  • Loading branch information
tomwayson committed Nov 22, 2024
2 parents 7da5379 + 7d7a5c6 commit ce5db42
Show file tree
Hide file tree
Showing 21 changed files with 1,147 additions and 66 deletions.
96 changes: 76 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions packages/common/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# @esri/hub-common [15.11.0](https://github.com/Esri/hub.js/compare/@esri/hub-common@15.10.0...@esri/hub-common@15.11.0) (2024-11-22)


### Features

* add link org settings in user workspace ([#1707](https://github.com/Esri/hub.js/issues/1707)) ([83ddde5](https://github.com/Esri/hub.js/commit/83ddde516dc06f37f2a7b87abe6089efbdbd32c3))

# @esri/hub-common [15.10.0](https://github.com/Esri/hub.js/compare/@esri/hub-common@15.9.0...@esri/hub-common@15.10.0) (2024-11-22)


### Features

* add executed query length to search response ([#1733](https://github.com/Esri/hub.js/issues/1733)) ([1388046](https://github.com/Esri/hub.js/commit/138804661a4d5c868aae2839b94d70db1241490d))

# @esri/hub-common [15.9.0](https://github.com/Esri/hub.js/compare/@esri/hub-common@15.8.0...@esri/hub-common@15.9.0) (2024-11-20)


Expand Down
4 changes: 2 additions & 2 deletions packages/common/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@esri/hub-common",
"version": "15.9.0",
"version": "15.11.0",
"description": "Common TypeScript types and utility functions for @esri/hub.js.",
"main": "dist/node/index.js",
"module": "dist/esm/index.js",
Expand Down
3 changes: 2 additions & 1 deletion packages/common/src/search/_internal/portalSearchGroups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
IHubSearchResult,
IQuery,
} from "../types";
import { getNextFunction } from "../utils";
import { getNextFunction, getKilobyteSizeOfQuery } from "../utils";
import { expandPredicate } from "./expandPredicate";

/**
Expand Down Expand Up @@ -106,6 +106,7 @@ async function searchPortal(
resp.total,
searchPortal
),
executedQuerySize: getKilobyteSizeOfQuery(searchOptions.q),
};
}

Expand Down
14 changes: 12 additions & 2 deletions packages/common/src/search/_internal/portalSearchItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ import {
IPredicate,
IQuery,
} from "../types";
import { addDefaultItemSearchPredicates, getNextFunction } from "../utils";
import {
addDefaultItemSearchPredicates,
getNextFunction,
getKilobyteSizeOfQuery,
expandPortalQuery,
} from "../utils";
import { convertPortalAggregations } from "./portalSearchUtils";
import { expandPredicate } from "./expandPredicate";
import HubError from "../../HubError";
Expand Down Expand Up @@ -59,6 +64,9 @@ export function portalSearchItemsAsItems(
}

/**
* DEPRECATED - use expandPortalQuery instead
*
*
* @internal
* Expand an IQuery by applying well-known filters and predicates,
* and then expanding all the predicates into IMatchOption objects.
Expand Down Expand Up @@ -103,7 +111,7 @@ function processSearchParams(options: IHubSearchOptions, query: IQuery) {
);
}

const updatedQuery = expandQuery(query);
const updatedQuery = expandPortalQuery(query);

// Serialize the all the groups for portal
const so = serializeQueryForPortal(updatedQuery);
Expand Down Expand Up @@ -166,6 +174,7 @@ async function searchPortalAsItem(
resp.total,
searchPortalAsItem
),
executedQuerySize: getKilobyteSizeOfQuery(searchOptions.q),
};
}

Expand Down Expand Up @@ -209,6 +218,7 @@ async function searchPortalAsHubSearchResult(
resp.total,
searchPortalAsHubSearchResult
),
executedQuerySize: getKilobyteSizeOfQuery(searchOptions.q),
};
}

Expand Down
3 changes: 3 additions & 0 deletions packages/common/src/search/_internal/portalSearchUsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
import { getNextFunction } from "../utils";
import { expandPredicate } from "./expandPredicate";
import { cloneObject } from "../../util";
import { getKilobyteSizeOfQuery } from "../utils";

function buildSearchOptions(
query: IQuery,
Expand Down Expand Up @@ -203,6 +204,7 @@ async function searchPortal(
resp.total,
searchPortal
),
executedQuerySize: getKilobyteSizeOfQuery(searchOptions.q),
};
}

Expand Down Expand Up @@ -232,6 +234,7 @@ async function searchCommunity(
resp.total,
searchCommunity
),
executedQuerySize: getKilobyteSizeOfQuery(searchOptions.q),
};
}

Expand Down
3 changes: 2 additions & 1 deletion packages/common/src/search/explainQueryResult.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { IFilter, IPredicate, IQuery } from "./types";
import { expandQuery } from "./_internal/portalSearchItems";
import { cloneObject } from "../util";
import { explainFilter } from "./_internal/explainFilter";
import { expandPortalQuery } from "./utils";

/**
* Explanation of why a result matched a query
Expand Down Expand Up @@ -123,7 +124,7 @@ export async function explainQueryResult(
}

// Expand the query so we have a standardized structure to work with
const expandedQuery = expandQuery(query);
const expandedQuery = expandPortalQuery(query);

// iterate the filters on the query and get explanations for each
const filterExplanations: IFilterExplanation[] = [];
Expand Down
7 changes: 7 additions & 0 deletions packages/common/src/search/types/IHubSearchResponse.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { IMessage } from "../../types/IMessage";
import { IHubAggregation } from "./IHubAggregation";
import { Kilobyte } from "./types";

/**
* Defines a generic search response interface with parameterized result type
Expand Down Expand Up @@ -36,4 +37,10 @@ export interface IHubSearchResponse<T> {
* Array of messages / warnings
*/
messages?: IMessage[];

/**
* The length of the query string that was just executed in the search,
* measured in kilobytes
*/
executedQuerySize?: Kilobyte;
}
7 changes: 7 additions & 0 deletions packages/common/src/search/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,10 @@ export interface ICatalogSearchResponse {

export interface ISearchResponseHash
extends Record<string, IHubSearchResponse<IHubSearchResult>> {}

/**
* Type wrapper for a kilobyte
* This is complete syntactic sugar, it makes sizes easier to understand
* with units as a type
*/
export type Kilobyte = number;
Loading

0 comments on commit ce5db42

Please sign in to comment.