Skip to content

Commit

Permalink
more deps
Browse files Browse the repository at this point in the history
  • Loading branch information
ncovercash committed Jan 8, 2024
1 parent 6b612b0 commit 01dff74
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
},
"dependencies": {
"@folio/stripes-react-hotkeys": "^3.0.0",
"apollo-client": "^2.6.10",
"ky": "^0.33.3",
"moment": "^2.29.4",
"popper.js": "^1.16.1",
Expand Down
52 changes: 52 additions & 0 deletions smart-components/lib/SearchAndSort/makeQueryFunction.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { FilterGroupsConfig } from '../../../components';
import Logger from '../../../util/logger';
import { NsParamsType } from './nsQueryFunctions';

/**
* Returns a string, or null, which stripes-connect will use to construct a resource query.
*
* Accepts four params:
* @param queryParams An object containing the UI URL's query parameters (as accessed by ?{name}).
* @param pathComponents An object containing the UI URL's path components (as accessed by :{name}).
* @param resourceData An object containing the component's resources' data (as accessed by %{name}).
* @param logger A logger object.
*/
export type QueryFunction = (
queryParams: Record<string, unknown>,
pathComponents: Record<string, unknown>,
resourceData: { query: Record<string, unknown> },
logger: Logger,
) => string | null;

/**
* Builds a {@link QueryFunction}
*
* @param findAll CQL query to retrieve all records when there is a sort clause but no CQL query
* @param queryTemplate CQL query to interpolate, or function which will return CQL
* @param sortMap map from sort keys to CQL fields
* @param filterConfig list of filter objects, see {@link FilterGroupsConfig}
* @param failOnCondition one of the following:
* - 0 (or false (legacy)): do not fail even if query and filters and empty
* - 1 (or true (legacy)): fail if query is empty, whatever the filter state
* - 2: fail if both query and filters and empty
* @param nsParams namespace keys
* @param configOrEscape an object containing configuration parameters:
* - escape: whether to escape the query string (default true)
* - rightTrunc: whether to right-truncate the query string (default true)
* For backwards compatibility, this parameter may also be a boolean, in which case it is used as the `escape` configuration value.
*/
export default function makeQueryFunction(
findAll: string,
queryTemplate:
| string
| ((
nsQueryParams: Record<string, unknown>,
pathComponents: Record<string, unknown>,
queryObj: { query: Record<string, unknown> },
) => string),
sortMap: Record<string, string>,
filterConfig: FilterGroupsConfig,
failOnCondition: 0 | 1 | 2 | true | false,
nsParams: NsParamsType,
configOrEscape: boolean | { escape?: boolean; rightTrunc?: boolean },
): QueryFunction;
32 changes: 32 additions & 0 deletions smart-components/lib/SearchAndSort/nsQueryFunctions.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
export type NsParamsType = string | Record<string, unknown> | undefined | null;

export function getNsKey(key: string, params?: NsParamsType): string;

/**
*
* Adds namespace / prefix to keys in whitelist for given values object
*
* @example
* ```
* values = mapNsKeys({ query: "test", filters: 'active', userId: 1 }, 'users')
* // result: { "users.query" : "test", "users.filters": "active", userId: 1 }
* ```
*/
export function mapNsKeys(
values: Record<string, unknown>,
params?: NsParamsType,
): Record<string, unknown>;

/**
* Removes namespace / prefix from keys for given values object
*
* @example
* ```
* values = removeNsKeys({ "users.query" : "test", "users.filters": "active" }, 'users')
* // result: { query: "test", filters: 'active' }
* ```
*/
export function removeNsKeys(
values: Record<string, unknown>,
params?: NsParamsType,
): Record<string, unknown>;

0 comments on commit 01dff74

Please sign in to comment.