Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: rename search-types to x-types #928

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ evolves.
- **[@empathyco/x-jest-utils](/packages/jest-utils)** - Jest extensions for easier testing.
- **[@empathyco/x-logger](/packages/logger)** - A custom implementation of a logger.
- **[@empathyco/x-adapter](/packages/search-adapter)** - A search client for Empathy's Search API.
- **[@empathyco/x-types](/packages/search-types)** - TypeScript types & guards for X models.
- **[@empathyco/x-types](/packages/x-types)** - TypeScript types & guards for X models.
- **[@empathyco/x-storage-service](/packages/storage-service)** - Storage service with TTL.
- **[@empathyco/x-react-wrapper](/packages/react-wrapper)** - A proxy that transforms Vue components
into React components.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,8 @@ To build your search and discovery UI, the following project dependencies are re
one from scratch using the
[`@empathyco/x-adapter`](https://github.com/empathyco/x/tree/main/packages/x-adapter) package.

- **x-types**
([`@empathyco/x-types`](https://github.com/empathyco/x/tree/main/packages/search-types)): The data
model used in the X Components to define types.
- **x-types** ([`@empathyco/x-types`](https://github.com/empathyco/x/tree/main/packages/x-types)):
The data model used in the X Components to define types.
diegopf marked this conversation as resolved.
Show resolved Hide resolved

Install the project dependencies via `npm` as follows:

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,46 +7,56 @@
## 8.0.0

> EX-3347 Remove `MultiSelect` model.
>
>
> EX-3300 Transform `Sort` model into a string.
>
>
> EX-3300 Remove `SortDirection` enum.

## 7.0.0

> EX-3222 Add `EditableNumberRangeFilter` model to represent range filters that the user can mutate its value.
> EX-3222 Add `EditableNumberRangeFilter` model to represent range filters that the user can mutate
> its value.
>
> EX-3222 Add `BooleanFilter` model to share the properties of filters that the user can select or deselect. `SimpleFilter`, `HierarchicalFilter` and `NumberRangeFilter` now extend from `BooleanFilter`.
> EX-3222 Add `BooleanFilter` model to share the properties of filters that the user can select or
> deselect. `SimpleFilter`, `HierarchicalFilter` and `NumberRangeFilter` now extend from
> `BooleanFilter`.
>
> EX-3222 `selected`, `totalResults` and `value` properties have been moved to `BooleanFilter` from `Filter`. It's necessary to replace `Filter` type references with `BooleanFilter`. Filters and facets schemas have been replaced accordingly.
> EX-3222 `selected`, `totalResults` and `value` properties have been moved to `BooleanFilter` from
> `Filter`. It's necessary to replace `Filter` type references with `BooleanFilter`. Filters and
> facets schemas have been replaced accordingly.

## 6.0.0

> EX-2521 Remove `BaseFilter` and `Facet` from the possible model names.
>
> EX-2320 Split the facet model into `Facet`, `SimpleFacet`, `HierarchicalFacet` and `RangeFacet`.
>
> EX-2320 Split the filter model into `Filter`, `SimpleFilter`, `HierarchicalFilter` and `RangeFilter`. The `Filter` changed the `value` to be always unknown and the `HierarchicalFilter` changed the `parent` and the `facet` properties to be identifier strings.
> EX-2320 Split the filter model into `Filter`, `SimpleFilter`, `HierarchicalFilter` and
> `RangeFilter`. The `Filter` changed the `value` to be always unknown and the `HierarchicalFilter`
> changed the `parent` and the `facet` properties to be identifier strings.

## 5.0.0

> EX-1837 Changed next query schema facets to be an array instead of an object.
>
> EX-1693 Renamed `term` property to`query` in `HistoryTerm`, `PartialResult` and `Suggestion` models.
> EX-1693 Renamed `term` property to`query` in `HistoryTerm`, `PartialResult` and `Suggestion`
> models.
>
> EX-1693 Renamed `resultsFacets` property to `facets` in `NextQuery` model.
>
> EX-1693 Renamed `HistoryTerm` model to `HistoryQuery`,
>
> EX-1693 Renamed `numFound` property to `totalResults` in `PartialResult` and `NextQuery` models.
>
> EX-1693 Remove `id` property from `NextQuery` model. The `query` should be unique, and can be used instead.
> EX-1693 Remove `id` property from `NextQuery` model. The `query` should be unique, and can be used
> instead.
>
> EX-1693 Remove `html` field from `Suggestion` and `ResultIdentifier` models. This field should be calculated in the component that consumes the suggestion.
> EX-1693 Remove `html` field from `Suggestion` and `ResultIdentifier` models. This field should be
> calculated in the component that consumes the suggestion.

## 4.0.0

> EX-1437 Update TypeScript version to `^3.7.2`
>
> EX-1437 Concatenate types in a single file. Projects that augment the types of this project must update the files location.

> EX-1437 Concatenate types in a single file. Projects that augment the types of this project must
> update the files location.
File renamed without changes.
File renamed without changes.
45 changes: 23 additions & 22 deletions packages/search-types/README.md → packages/x-types/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,55 +10,55 @@ npm install @empathyco/x-types --save

### How to use

The package export several model types that can be used to safely create objects that
match the expectations of X packages.
The package export several model types that can be used to safely create objects that match the
expectations of X packages.

```ts
import { RelatedTag } from "@empathyco/x-types";
import { RelatedTag } from '@empathyco/x-types';

const relatedTag: RelatedTag = {
query: "lego",
tag: "city",
query: 'lego',
tag: 'city',
selected: false,
previous: "lego",
previous: 'lego'
};
```

Additionally it also exposes some type guards to check between different types.

```ts
import { Filter, isHierarchicalFilter } from "@empathyco/x-types";
import { Filter, isHierarchicalFilter } from '@empathyco/x-types';

const filter: Filter = {
modelName: "HierarchicalFilter",
id: "color:red",
facetId: "color",
label: "red",
modelName: 'HierarchicalFilter',
id: 'color:red',
facetId: 'color',
label: 'red',
selected: false,
children: [],
children: []
};
// You can't access filter.children before the `if` because you have a `Filter`, not a `HierarchicalFilter`.

if (isHierarchicalFilter(filter)) {
// But after using the `isHierarchicalFilter` guard, you can acces it.
console.log("Children:", filter.children);
console.log('Children:', filter.children);
}
```

Finally, there are some `jest` schemas helpers that you could use to validate your objects.

```ts
import { HierarchicalFilterSchema } from "@empathyco/x-types/schemas";
import { Filter, isHierarchicalFilter } from "@empathyco/x-types";
import { HierarchicalFilterSchema } from '@empathyco/x-types/schemas';
import { Filter, isHierarchicalFilter } from '@empathyco/x-types';

it("is a hierarchical filter", () => {
it('is a hierarchical filter', () => {
const filter: Filter = {
modelName: "HierarchicalFilter",
id: "color:red",
facetId: "color",
label: "red",
modelName: 'HierarchicalFilter',
id: 'color:red',
facetId: 'color',
label: 'red',
selected: false,
children: [],
children: []
};

expect(filter).toEqual(HierarchicalFilterSchema);
Expand All @@ -67,7 +67,8 @@ it("is a hierarchical filter", () => {

### How to update the version

You can check if a new version has been published running [npm outdated](https://docs.npmjs.com/cli/outdated):
You can check if a new version has been published running
[npm outdated](https://docs.npmjs.com/cli/outdated):

`npm outdated @empathyco/x-types`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@
"tsdocMetadataFilePath": "<projectFolder>/report/tsdoc-metadata.json"
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Empathy search types",
"author": "Empathy Systems Corporation S.L.",
"license": "Apache-2.0",
"homepage": "https://github.com/empathyco/x/tree/main/packages/search-types#readme",
"homepage": "https://github.com/empathyco/x/tree/main/packages/x-types#readme",
"keywords": [
"search",
"types",
Expand All @@ -22,15 +22,15 @@
"repository": {
"type": "git",
"url": "https://github.com/empathyco/x.git",
"directory": "packages/search-types"
"directory": "packages/x-types"
},
"engines": {
"node": "16"
},
"scripts": {
"build": "rollup -c && npm run gen:docs",
"build:watch": "rollup -c -w",
"gen:model-docs": "api-extractor run -c search-types-extractor.json -l && api-extractor run -c schema-extractor.json -l && api-extractor run -l",
"gen:model-docs": "api-extractor run -c x-types-extractor.json -l && api-extractor run -c schema-extractor.json -l && api-extractor run -l",
"gen:typescript-docs": "api-documenter markdown -i report -o docs",
"gen:docs": "npm run gen:model-docs && npm run gen:typescript-docs",
"postbuild": "npm pack",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ const schemas = {
format: 'cjs'
},
external: ['@empathyco/x-jest-utils'],
plugins: [
del({ targets: 'schemas' }),
typescript({ clean: true }),
]
plugins: [del({ targets: 'schemas' }), typescript({ clean: true })]
};

export default [models, schemas];
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@ export interface Previewable {
query: string;
/** Facets to apply to the `query` property when searching. */
facets?: Facet[];
/** The results that the combination of `query` and `facets` properties return, or `null` if
* they have not been loaded yet. */
/**
* The results that the combination of `query` and `facets` properties return, or `null` if
* they have not been loaded yet.
*/
results?: Result[] | null;
/** The number of results that the combination of `query` and `facets` properties return, or
* `null` if they have not been loaded yet. */
/**
* The number of results that the combination of `query` and `facets` properties return, or
* `null` if they have not been loaded yet.
*/
totalResults?: number | null;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,8 @@
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"types": [
"jest",
"@empathyco/x-jest-utils"
],
"lib": [
"dom",
"esnext"
],
"types": ["jest", "@empathyco/x-jest-utils"],
"lib": ["dom", "esnext"],
"esModuleInterop": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true
Expand Down