
Security News
Socket Integrates With Bun 1.3’s Security Scanner API
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
@empathyco/x-types
Advanced tools
TypeScript model types, guards, and jest schemas to use across the X project.
npm install @empathyco/x-types --save
The package export several model types that can be used to safely create objects that match the expectations of X packages.
import { RelatedTag } from '@empathyco/x-types'
const relatedTag: RelatedTag = {
query: 'lego',
tag: 'city',
selected: false,
previous: 'lego',
}
Additionally it also exposes some type guards to check between different types.
import { Filter, isHierarchicalFilter } from '@empathyco/x-types'
const filter: Filter = {
modelName: 'HierarchicalFilter',
id: 'color:red',
facetId: 'color',
label: 'red',
selected: false,
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)
}
Finally, there are some jest
schemas helpers that you could use to validate your objects.
import { Filter, isHierarchicalFilter } from '@empathyco/x-types'
import { HierarchicalFilterSchema } from '@empathyco/x-types/schemas'
it('is a hierarchical filter', () => {
const filter: Filter = {
modelName: 'HierarchicalFilter',
id: 'color:red',
facetId: 'color',
label: 'red',
selected: false,
children: [],
}
expect(filter).toEqual(HierarchicalFilterSchema)
})
You can check if a new version has been published running npm outdated:
npm outdated @empathyco/x-types
And update it using npm update:
npm update --save @empathyco/x-types
FAQs
Empathy search types
The npm package @empathyco/x-types receives a total of 2,166 weekly downloads. As such, @empathyco/x-types popularity was classified as popular.
We found that @empathyco/x-types demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
Security News
Python 3.14 adds template strings, deferred annotations, and subinterpreters, plus free-threaded mode, an experimental JIT, and Sigstore verification.
Security News
Former RubyGems maintainers have launched The Gem Cooperative, a new community-run project aimed at rebuilding open governance in the Ruby ecosystem.