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: update tag type for search #722

Merged
merged 6 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions src/item/itemSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ export type ItemSettings = {
isResizable?: boolean;
isCollapsible?: boolean;
enableSaveActions?: boolean;
/**
* @deprecated use entities tags and item tags instead
*/
tags?: string[];
displayCoEditors?: boolean;
// allow null to delete setting in the backend
Expand Down
6 changes: 2 additions & 4 deletions src/search/search.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ItemTypeUnion } from '@/item/itemType.js';

export const INDEX_NAME = 'itemIndex';
import { TagCategory } from '@/tag/tag.js';

type IndexMember = {
id: string;
Expand All @@ -13,14 +12,13 @@ export type IndexItem = {
creator: IndexMember;
description: string;
type: ItemTypeUnion;
categories: string[];
content: string;
isPublishedRoot: boolean;
isHidden: boolean;
createdAt: string;
updatedAt: string;
lang: string;
};
} & { [key in TagCategory]: string[] };

// TODO: get type from meilisearch library?
type Hits = IndexItem & {
Expand Down
4 changes: 2 additions & 2 deletions src/tag/factory.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { v4 } from 'uuid';

import { TagCategory } from './tag.js';
import { Tag, TagCategory } from './tag.js';
import { faker } from '@faker-js/faker';

export function TagFactory(
args: { name?: string; category?: TagCategory } = {},
) {
): Tag {
return {
id: v4(),
name: args.name ?? faker.word.noun(),
Expand Down
4 changes: 4 additions & 0 deletions src/tag/tag.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { UUID } from '@/types.js';

export enum TagCategory {
Level = 'level',
Discipline = 'discipline',
ResourceType = 'resource-type',
}

export type Tag = { id: UUID; name: string; category: TagCategory };
Loading