Skip to content

Commit 46cc6f6

Browse files
committed
update types
1 parent 5469038 commit 46cc6f6

File tree

7 files changed

+23
-26
lines changed

7 files changed

+23
-26
lines changed

src/app/src/composables/useDraftBase.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type { useGit } from './useGit'
77
import { useHooks } from './useHooks'
88
import { ref } from 'vue'
99

10-
export function useDraftBase<T extends DatabaseItem & { fsPath: string } | MediaItem & { fsPath: string }>(
10+
export function useDraftBase<T extends DatabaseItem | MediaItem>(
1111
type: 'media' | 'document',
1212
host: StudioHost,
1313
git: ReturnType<typeof useGit>,

src/app/src/composables/useDraftMedias.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export const useDraftMedias = createSharedComposable((host: StudioHost, git: Ret
6565

6666
await remove([fsPath], { rerender: false })
6767

68-
const newDbItem: MediaItem & { fsPath: string } = {
68+
const newDbItem: MediaItem = {
6969
...currentDbItem,
7070
fsPath: newFsPath,
7171
id: joinURL(VirtualMediaCollectionName, newFsPath),

src/app/src/types/database.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,13 @@ import type { BaseItem } from './item'
33

44
export interface DatabaseItem extends CollectionItemBase, BaseItem {
55
[key: string]: unknown
6-
fsPath: string
76
}
87

98
export interface DatabasePageItem extends PageCollectionItemBase, BaseItem {
109
path: string
11-
fsPath: string
1210
[key: string]: unknown
1311
}
1412

1513
export interface DatabaseDataItem extends DataCollectionItemBase, BaseItem {
16-
fsPath: string
1714
[key: string]: unknown
1815
}

src/app/src/types/draft.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ export interface DraftItem<T = DatabaseItem | MediaItem> {
1919
status: DraftStatus // status
2020

2121
githubFile?: GithubFile // file fetched on gh
22-
original?: T & { fsPath: string }
23-
modified?: T & { fsPath: string }
22+
original?: T
23+
modified?: T
2424
/**
2525
* - Buffer media content
2626
*/

src/app/src/utils/tree.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ TreeItem[] {
4747
continue
4848
}
4949

50-
const virtualDbItem: BaseItem & { fsPath: string } = {
50+
const virtualDbItem: BaseItem = {
5151
id: 'N/A',
5252
fsPath: deletedItem.fsPath,
5353
extension: getFileExtension(deletedItem.fsPath),

src/app/test/mocks/database.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { DatabaseItem } from '../../src/types/database'
22

3-
export const dbItemsList: (DatabaseItem & { fsPath: string })[] = [
3+
export const dbItemsList: DatabaseItem[] = [
44
{
55
id: 'landing/index.md',
66
title: '',
@@ -60,7 +60,7 @@ export const dbItemsList: (DatabaseItem & { fsPath: string })[] = [
6060
},
6161
]
6262

63-
export const nestedDbItemsList: (DatabaseItem & { fsPath: string })[] = [
63+
export const nestedDbItemsList: DatabaseItem[] = [
6464
{
6565
id: 'docs/1.essentials/2.configuration.md',
6666
title: 'Configuration',
@@ -101,7 +101,7 @@ export const nestedDbItemsList: (DatabaseItem & { fsPath: string })[] = [
101101
},
102102
]
103103

104-
export const languagePrefixedDbItemsList: (DatabaseItem & { fsPath: string })[] = [
104+
export const languagePrefixedDbItemsList: DatabaseItem[] = [
105105
{
106106
id: 'landing_en/en/index.md',
107107
title: '',

src/app/test/unit/utils/tree.test.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ describe('buildTree of documents with one level of depth', () => {
5151
})
5252

5353
it('With draft', () => {
54-
const createdDbItem: DatabaseItem & { fsPath: string } = dbItemsList[0]
54+
const createdDbItem: DatabaseItem = dbItemsList[0]
5555

5656
const draftList: DraftItem[] = [{
5757
fsPath: createdDbItem.fsPath,
@@ -71,7 +71,7 @@ describe('buildTree of documents with one level of depth', () => {
7171
})
7272

7373
it('With DELETED draft file in existing directory', () => {
74-
const deletedDbItem: DatabaseItem & { fsPath: string } = dbItemsList[1] // 2.introduction.md
74+
const deletedDbItem: DatabaseItem = dbItemsList[1] // 2.introduction.md
7575

7676
const draftList: DraftItem[] = [{
7777
fsPath: deletedDbItem.fsPath,
@@ -105,7 +105,7 @@ describe('buildTree of documents with one level of depth', () => {
105105
})
106106

107107
it('With DELETED draft file in non existing directory', () => {
108-
const deletedDbItem: DatabaseItem & { fsPath: string } = dbItemsList[2] // 3.installation.md
108+
const deletedDbItem: DatabaseItem = dbItemsList[2] // 3.installation.md
109109

110110
const draftList: DraftItem[] = [{
111111
fsPath: deletedDbItem.fsPath,
@@ -139,7 +139,7 @@ describe('buildTree of documents with one level of depth', () => {
139139
})
140140

141141
it('With UPDATED draft file in existing directory (directory status is set)', () => {
142-
const updatedDbItem: DatabaseItem & { fsPath: string } = dbItemsList[1] // 2.introduction.md
142+
const updatedDbItem: DatabaseItem = dbItemsList[1] // 2.introduction.md
143143

144144
const draftList: DraftItem[] = [{
145145
fsPath: updatedDbItem.fsPath,
@@ -175,8 +175,8 @@ describe('buildTree of documents with one level of depth', () => {
175175
})
176176

177177
it('With CREATED and OPENED draft files in exsiting directory (directory status is set)', () => {
178-
const createdDbItem: DatabaseItem & { fsPath: string } = dbItemsList[1] // 2.introduction.md
179-
const openedDbItem: DatabaseItem & { fsPath: string } = dbItemsList[2] // 3.installation.md
178+
const createdDbItem: DatabaseItem = dbItemsList[1] // 2.introduction.md
179+
const openedDbItem: DatabaseItem = dbItemsList[2] // 3.installation.md
180180

181181
const draftList: DraftItem[] = [{
182182
fsPath: createdDbItem.fsPath,
@@ -208,8 +208,8 @@ describe('buildTree of documents with one level of depth', () => {
208208
})
209209

210210
it('With OPENED draft files in existing directory (directory status is not set)', () => {
211-
const openedDbItem1: DatabaseItem & { fsPath: string } = dbItemsList[1] // 2.introduction.md
212-
const openedDbItem2: DatabaseItem & { fsPath: string } = dbItemsList[2] // 3.installation.md
211+
const openedDbItem1: DatabaseItem = dbItemsList[1] // 2.introduction.md
212+
const openedDbItem2: DatabaseItem = dbItemsList[2] // 3.installation.md
213213

214214
const draftList: DraftItem[] = [{
215215
fsPath: openedDbItem1.fsPath,
@@ -242,8 +242,8 @@ describe('buildTree of documents with one level of depth', () => {
242242
})
243243

244244
it('With same id DELETED and CREATED draft file resulting in RENAMED', () => {
245-
const deletedDbItem: DatabaseItem & { fsPath: string } = dbItemsList[1] // 2.introduction.md
246-
const createdDbItem: DatabaseItem & { fsPath: string } = { // 2.renamed.md
245+
const deletedDbItem: DatabaseItem = dbItemsList[1] // 2.introduction.md
246+
const createdDbItem: DatabaseItem = { // 2.renamed.md
247247
...dbItemsList[1],
248248
id: 'docs/1.getting-started/2.renamed.md',
249249
path: '/getting-started/renamed',
@@ -330,7 +330,7 @@ describe('buildTree of documents with two levels of depth', () => {
330330
})
331331

332332
it('With one level of depth draft files', () => {
333-
const updatedDbItem: DatabaseItem & { fsPath: string } = nestedDbItemsList[0] // 1.essentials/2.configuration.md
333+
const updatedDbItem: DatabaseItem = nestedDbItemsList[0] // 1.essentials/2.configuration.md
334334

335335
const draftList: DraftItem[] = [{
336336
fsPath: updatedDbItem.fsPath,
@@ -358,7 +358,7 @@ describe('buildTree of documents with two levels of depth', () => {
358358
})
359359

360360
it('With nested levels of depth draft files', () => {
361-
const updatedDbItem: DatabaseItem & { fsPath: string } = nestedDbItemsList[1] // 1.essentials/1.nested/2.advanced.md
361+
const updatedDbItem: DatabaseItem = nestedDbItemsList[1] // 1.essentials/1.nested/2.advanced.md
362362

363363
const draftList: DraftItem[] = [{
364364
fsPath: updatedDbItem.fsPath,
@@ -395,7 +395,7 @@ describe('buildTree of documents with two levels of depth', () => {
395395
})
396396

397397
it ('With DELETED draft file in nested non existing directory (directory status is set)', () => {
398-
const deletedDbItem: DatabaseItem & { fsPath: string } = nestedDbItemsList[1] // 1.essentials/1.nested/2.advanced.md
398+
const deletedDbItem: DatabaseItem = nestedDbItemsList[1] // 1.essentials/1.nested/2.advanced.md
399399

400400
const draftList: DraftItem[] = [{
401401
fsPath: deletedDbItem.fsPath,
@@ -488,15 +488,15 @@ describe('buildTree of medias', () => {
488488
const mediaId = joinURL(VirtualMediaCollectionName, mediaFsPath)
489489
const gitKeepId = joinURL(VirtualMediaCollectionName, gitKeepFsPath)
490490

491-
const gitkeepDbItem: MediaItem & { fsPath: string } = {
491+
const gitkeepDbItem: MediaItem = {
492492
id: gitKeepId,
493493
fsPath: gitKeepFsPath,
494494
stem: '.gitkeep',
495495
extension: 'gitkeep',
496496
path: withLeadingSlash(gitKeepFsPath),
497497
}
498498

499-
const mediaDbItem: MediaItem & { fsPath: string } = {
499+
const mediaDbItem: MediaItem = {
500500
id: mediaId,
501501
fsPath: mediaFsPath,
502502
stem: 'image',

0 commit comments

Comments
 (0)