Skip to content

Commit

Permalink
feat: Add ShareType enum to replace Type with more JS native naming
Browse files Browse the repository at this point in the history
This also prevents name clashes with other `Type` classes or enums

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
  • Loading branch information
susnux committed Jun 19, 2024
1 parent d697de1 commit 3892f2e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
* SPDX-License-Identifier: CC0-1.0
*/
import { expect, test } from 'vitest'
import { Type } from '.'
import { ShareType } from '.'

test('ShareType', () => {
for (const type of Object.values(Type)) {
for (const type of Object.values(ShareType)) {
if (typeof type === 'string') {
// This should be the key of the enum, so we should be able to get the value
// eslint-disable-next-line @typescript-eslint/no-explicit-any
expect((Type as any)[type]).toBeTypeOf('number')
expect((ShareType as any)[type]).toBeTypeOf('number')
} else {
expect(type).toBeTypeOf('number')
expect(Type[type]).toBeTypeOf('string')
expect(ShareType[type]).toBeTypeOf('string')
}
}
})
26 changes: 26 additions & 0 deletions lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/**
* SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/

/** @deprecated will be removed with the next version use `ShareType` instead */
export enum Type {
SHARE_TYPE_USER = 0,
SHARE_TYPE_GROUP = 1,
Expand All @@ -14,3 +20,23 @@ export enum Type {
*/
SHARE_TYPE_FEDERATED_GROUP = 14,
}

export enum ShareType {
User = 0,
Grup = 1,
Link = 3,
Email = 4,
Remote = 6,
/**
* Was called `Circle` before Nextcloud 29
*/
Team = 7,
Guest = 8,
RemoteGroup = 9,
Room = 10,
Deck = 12,
/**
* @since 26.0.0
*/
FederatedGroup = 14,
}

0 comments on commit 3892f2e

Please sign in to comment.