From 57ec5c2d502c021a9d1584659fe8cdae24343e6b Mon Sep 17 00:00:00 2001 From: kim Date: Wed, 27 Nov 2024 10:57:31 +0100 Subject: [PATCH 1/5] feat: add tag type --- src/search/search.ts | 1 + src/tag/factory.ts | 4 ++-- src/tag/tag.ts | 4 ++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/search/search.ts b/src/search/search.ts index 9284e528..c0746336 100644 --- a/src/search/search.ts +++ b/src/search/search.ts @@ -20,6 +20,7 @@ export type IndexItem = { createdAt: string; updatedAt: string; lang: string; + tags: string[]; }; // TODO: get type from meilisearch library? diff --git a/src/tag/factory.ts b/src/tag/factory.ts index 3acfd245..effe853b 100644 --- a/src/tag/factory.ts +++ b/src/tag/factory.ts @@ -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(), diff --git a/src/tag/tag.ts b/src/tag/tag.ts index 85e4b6c8..70eecbbf 100644 --- a/src/tag/tag.ts +++ b/src/tag/tag.ts @@ -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 }; From 934b94d255b946bdb740674785cb49f994a289b1 Mon Sep 17 00:00:00 2001 From: kim Date: Wed, 4 Dec 2024 17:05:18 +0100 Subject: [PATCH 2/5] refactor: deprecate settings tags --- src/item/itemSettings.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/item/itemSettings.ts b/src/item/itemSettings.ts index 2d88fd24..69d75a0a 100644 --- a/src/item/itemSettings.ts +++ b/src/item/itemSettings.ts @@ -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 From ef095f286292f00a6c2112b219d35f1fbfd1d195 Mon Sep 17 00:00:00 2001 From: kim Date: Wed, 4 Dec 2024 17:22:47 +0100 Subject: [PATCH 3/5] refactor: update indexitem --- src/search/search.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/search/search.ts b/src/search/search.ts index c0746336..4a21cdee 100644 --- a/src/search/search.ts +++ b/src/search/search.ts @@ -1,4 +1,5 @@ import { ItemTypeUnion } from '@/item/itemType.js'; +import { TagCategory } from '@/tag/tag.js'; export const INDEX_NAME = 'itemIndex'; @@ -13,7 +14,6 @@ export type IndexItem = { creator: IndexMember; description: string; type: ItemTypeUnion; - categories: string[]; content: string; isPublishedRoot: boolean; isHidden: boolean; @@ -21,7 +21,7 @@ export type IndexItem = { updatedAt: string; lang: string; tags: string[]; -}; +} & { [key in TagCategory]: string[] }; // TODO: get type from meilisearch library? type Hits = IndexItem & { From 4d3c97537eaf90dc8bccc24ce4d96919f3a01986 Mon Sep 17 00:00:00 2001 From: kim Date: Wed, 4 Dec 2024 17:25:27 +0100 Subject: [PATCH 4/5] refactor: remove tags from search item --- src/search/search.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/search/search.ts b/src/search/search.ts index 4a21cdee..3ec59cb2 100644 --- a/src/search/search.ts +++ b/src/search/search.ts @@ -20,7 +20,6 @@ export type IndexItem = { createdAt: string; updatedAt: string; lang: string; - tags: string[]; } & { [key in TagCategory]: string[] }; // TODO: get type from meilisearch library? From 89b58b5573235cfebdce92a79caf1747b6a964cc Mon Sep 17 00:00:00 2001 From: kim Date: Thu, 5 Dec 2024 14:50:48 +0100 Subject: [PATCH 5/5] refactor: remove index name --- src/search/search.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/search/search.ts b/src/search/search.ts index 3ec59cb2..e36ea7b5 100644 --- a/src/search/search.ts +++ b/src/search/search.ts @@ -1,8 +1,6 @@ import { ItemTypeUnion } from '@/item/itemType.js'; import { TagCategory } from '@/tag/tag.js'; -export const INDEX_NAME = 'itemIndex'; - type IndexMember = { id: string; name: string;