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: Add ShareType enum to replace Type with more JS native naming #22

Merged
merged 1 commit into from
Jun 19, 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
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,
}
Loading