@shakerquiz/utilities 0.4.36 → 0.4.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dprint.json +1 -1
- package/package.json +1 -1
- package/source/enumerations/entities/city-affilations.d.ts +1 -0
- package/source/enumerations/entities/city-affilations.js +4 -0
- package/source/enumerations/entities/registration-attributes.d.ts +2 -0
- package/source/enumerations/entities/registration-attributes.js +57 -0
- package/source/enumerations/entities/registration-lineups.d.ts +5 -0
- package/source/enumerations/entities/registration-lineups.js +43 -0
- package/source/enumerations/entities/registration-statuses.d.ts +4 -0
- package/source/enumerations/entities/registration-statuses.js +49 -0
- package/source/functions/tag.d.ts +1 -0
- package/source/functions/tag.js +5 -0
- package/source/index.d.ts +1 -1
- package/source/index.js +3 -1
- package/source/misc.d.ts +13 -18
- package/source/enumerations/entities/affilations.d.ts +0 -1
- package/source/enumerations/entities/affilations.js +0 -4
- package/source/enumerations/entities/lineups.d.ts +0 -1
- package/source/enumerations/entities/lineups.js +0 -4
package/dprint.json
CHANGED
package/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const CityAffilations: readonly ["Branch", "Franchise"];
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { getTag } from '../../functions/tag.js'
|
|
2
|
+
|
|
3
|
+
export var RegistrationAttributes = /** @type {const} */ ([
|
|
4
|
+
'Alone',
|
|
5
|
+
'Birthday',
|
|
6
|
+
'Newcomer',
|
|
7
|
+
'Public',
|
|
8
|
+
])
|
|
9
|
+
|
|
10
|
+
var RegistrationAttributeRegistrationProperties = /** @type {const} */ ([
|
|
11
|
+
'is_alone',
|
|
12
|
+
'is_birthday',
|
|
13
|
+
'is_first',
|
|
14
|
+
'is_extensible',
|
|
15
|
+
])
|
|
16
|
+
|
|
17
|
+
var RegistrationAttributeRegistrationProperty = /** @type {const} */ ({
|
|
18
|
+
'Alone': 'is_alone',
|
|
19
|
+
'Birthday': 'is_birthday',
|
|
20
|
+
'Newcomer': 'is_first',
|
|
21
|
+
'Public': 'is_extensible',
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
var RegistrationPropertyRegistrationAttribute = /** @type {const} */ ({
|
|
25
|
+
'is_alone': 'Alone',
|
|
26
|
+
'is_birthday': 'Birthday',
|
|
27
|
+
'is_first': 'Newcomer',
|
|
28
|
+
'is_extensible': 'Public',
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @param {RegistrationAttribute[] | Partial<Pick<RegistrationTable, 'is_alone' | 'is_birthday' | 'is_extensible' | 'is_first'>>} value
|
|
33
|
+
*/
|
|
34
|
+
export var getRegistrationAttributes = value => {
|
|
35
|
+
switch (getTag(value)) {
|
|
36
|
+
case 'Object':
|
|
37
|
+
return RegistrationAttributeRegistrationProperties
|
|
38
|
+
.map(property => value[property] ? RegistrationPropertyRegistrationAttribute[property] : '')
|
|
39
|
+
.filter(Boolean)
|
|
40
|
+
|
|
41
|
+
case 'Array':
|
|
42
|
+
if (!value.every(attribute => RegistrationAttributes.includes(attribute)))
|
|
43
|
+
throw TypeError(
|
|
44
|
+
`[Function: getRegistrationAttributes] Parameter 'value': '${value}' of type 'Array' must include only members of 'RegistrationAttributes'.`,
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
return value.reduce((attributes, attribute) => {
|
|
48
|
+
attributes[RegistrationAttributeRegistrationProperty[attribute]] = true
|
|
49
|
+
return attributes
|
|
50
|
+
}, {})
|
|
51
|
+
|
|
52
|
+
default:
|
|
53
|
+
throw TypeError(
|
|
54
|
+
`[Function: getRegistrationAttributes] Parameter 'value': '${value}' must be of types: 'Object', 'Array'.`,
|
|
55
|
+
)
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export const RegistrationLineups: readonly ["Main", "Reserve"];
|
|
2
|
+
export function getRegistrationLineup(value: RegistrationLineup | (typeof RegistrationLineupShape)[RegistrationLineup]): any;
|
|
3
|
+
/** @type {Record<RegistrationLineup, Pick<RegistrationTable, 'is_reserve'>>} */
|
|
4
|
+
declare let RegistrationLineupShape: Record<RegistrationLineup, Pick<RegistrationTable, "is_reserve">>;
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export var RegistrationLineups = /** @type {const} */ ([
|
|
2
|
+
'Main',
|
|
3
|
+
'Reserve',
|
|
4
|
+
])
|
|
5
|
+
|
|
6
|
+
/** @type {Record<RegistrationLineup, Pick<RegistrationTable, 'is_reserve'>>} */
|
|
7
|
+
let RegistrationLineupShape = {
|
|
8
|
+
'Main': {
|
|
9
|
+
is_reserve: false,
|
|
10
|
+
},
|
|
11
|
+
|
|
12
|
+
'Reserve': {
|
|
13
|
+
is_reserve: true,
|
|
14
|
+
},
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @param {RegistrationLineup | typeof RegistrationLineupShape[RegistrationLineup]} value
|
|
19
|
+
*/
|
|
20
|
+
export var getRegistrationLineup = value => {
|
|
21
|
+
switch (typeof value) {
|
|
22
|
+
case 'object':
|
|
23
|
+
let found = Object
|
|
24
|
+
.entries(RegistrationLineupShape)
|
|
25
|
+
.find(([, object]) => object.is_reserve === value.is_reserve)
|
|
26
|
+
?.at(0)
|
|
27
|
+
|
|
28
|
+
if (!RegistrationLineups.includes(found))
|
|
29
|
+
throw TypeError(
|
|
30
|
+
`[Function: getRegistrationLineup] Parameter 'found': '${found}' must be a member of 'Lineups'.`,
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
return found
|
|
34
|
+
|
|
35
|
+
case 'string':
|
|
36
|
+
if (!RegistrationLineups.includes(value))
|
|
37
|
+
throw TypeError(
|
|
38
|
+
`[Function: getRegistrationLineup] Parameter 'value': '${value}' must be a member of 'Lineups'.`,
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
return RegistrationLineupShape[value]
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -1 +1,5 @@
|
|
|
1
1
|
export const RegistrationStatuses: readonly ["Cancelled", "Confirmed", "Registered"];
|
|
2
|
+
export function getRegistrationStatus(value: RegistrationStatus | (typeof RegistrationStatusShape)[RegistrationStatus]): any;
|
|
3
|
+
/** @type {Record<RegistrationStatus, Pick<RegistrationTable, 'is_canceled' | 'is_confirm'>>} */
|
|
4
|
+
declare let RegistrationStatusShape: Record<RegistrationStatus, Pick<RegistrationTable, "is_canceled" | "is_confirm">>;
|
|
5
|
+
export {};
|
|
@@ -3,3 +3,52 @@ export var RegistrationStatuses = /** @type {const} */ ([
|
|
|
3
3
|
'Confirmed',
|
|
4
4
|
'Registered',
|
|
5
5
|
])
|
|
6
|
+
|
|
7
|
+
/** @type {Record<RegistrationStatus, Pick<RegistrationTable, 'is_canceled' | 'is_confirm'>>} */
|
|
8
|
+
let RegistrationStatusShape = {
|
|
9
|
+
'Cancelled': {
|
|
10
|
+
is_canceled: true,
|
|
11
|
+
is_confirm: false,
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
'Confirmed': {
|
|
15
|
+
is_canceled: false,
|
|
16
|
+
is_confirm: true,
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
'Registered': {
|
|
20
|
+
is_canceled: false,
|
|
21
|
+
is_confirm: false,
|
|
22
|
+
},
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @param {RegistrationStatus | typeof RegistrationStatusShape[RegistrationStatus]} value
|
|
27
|
+
*/
|
|
28
|
+
export let getRegistrationStatus = value => {
|
|
29
|
+
switch (typeof value) {
|
|
30
|
+
case 'object':
|
|
31
|
+
let found = Object
|
|
32
|
+
.entries(RegistrationStatusShape)
|
|
33
|
+
.find(([, object]) =>
|
|
34
|
+
object.is_canceled === value.is_canceled
|
|
35
|
+
&& object.is_confirm === value.is_confirm
|
|
36
|
+
)
|
|
37
|
+
?.at(0)
|
|
38
|
+
|
|
39
|
+
if (!RegistrationStatuses.includes(found))
|
|
40
|
+
throw TypeError(
|
|
41
|
+
`[Function: getRegistrationStatus] Parameter 'found': '${found}' must be a member of 'RegistrationStatuses'.`,
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
return found
|
|
45
|
+
|
|
46
|
+
case 'string':
|
|
47
|
+
if (!RegistrationStatuses.includes(value))
|
|
48
|
+
throw TypeError(
|
|
49
|
+
`[Function: getRegistrationStatus] Parameter 'value': '${value}' must be a member of 'RegistrationStatuses'.`,
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
return RegistrationStatusShape[value]
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function getTag(value: any): string;
|
package/source/index.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export * from './enumerations/misc/icons.d.ts'
|
|
|
16
16
|
export * from './enumerations/misc/phases.d.ts'
|
|
17
17
|
export * from './enumerations/misc/regexps.d.ts'
|
|
18
18
|
|
|
19
|
-
export * from './enumerations/entities/affilations.
|
|
19
|
+
export * from './enumerations/entities/city-affilations.js'
|
|
20
20
|
export * from './enumerations/entities/game-statuses.d.ts'
|
|
21
21
|
export * from './enumerations/entities/lineups.d.ts'
|
|
22
22
|
export * from './enumerations/entities/registration-statuses.d.ts'
|
package/source/index.js
CHANGED
|
@@ -11,8 +11,10 @@ export * from './enumerations/misc/icons.js'
|
|
|
11
11
|
export * from './enumerations/misc/phases.js'
|
|
12
12
|
export * from './enumerations/misc/regexps.js'
|
|
13
13
|
|
|
14
|
-
export * from './enumerations/entities/affilations.js'
|
|
14
|
+
export * from './enumerations/entities/city-affilations.js'
|
|
15
15
|
export * from './enumerations/entities/game-statuses.js'
|
|
16
16
|
export * from './enumerations/entities/lineups.js'
|
|
17
17
|
export * from './enumerations/entities/registration-statuses.js'
|
|
18
18
|
export * from './enumerations/entities/roles.js'
|
|
19
|
+
|
|
20
|
+
export * from './functions/tag.js'
|
package/source/misc.d.ts
CHANGED
|
@@ -26,8 +26,7 @@ type Method = (typeof import('./enumerations/core/methods.js').Methods)[number]
|
|
|
26
26
|
|
|
27
27
|
type Domain = (typeof import('./enumerations/core/features.js').Domains)[number]
|
|
28
28
|
|
|
29
|
-
type Procedure =
|
|
30
|
-
(typeof import('./enumerations/core/features.js').Procedures)[number]
|
|
29
|
+
type Procedure = (typeof import('./enumerations/core/features.js').Procedures)[number]
|
|
31
30
|
|
|
32
31
|
type Feature = Domain | Procedure
|
|
33
32
|
|
|
@@ -35,29 +34,25 @@ type Kind = (typeof import('./enumerations/core/kinds.js').Kinds)[number]
|
|
|
35
34
|
|
|
36
35
|
type Scope = `${Method}/${Feature}/${Kind}`
|
|
37
36
|
|
|
38
|
-
type Runtime =
|
|
39
|
-
(typeof import('./enumerations/core/runtimes.js').Runtimes)[number]
|
|
37
|
+
type Runtime = (typeof import('./enumerations/core/runtimes.js').Runtimes)[number]
|
|
40
38
|
|
|
41
|
-
type Network =
|
|
42
|
-
(typeof import('./enumerations/core/networks.js').Networks)[number]
|
|
39
|
+
type Network = (typeof import('./enumerations/core/networks.js').Networks)[number]
|
|
43
40
|
|
|
44
41
|
type Role = (typeof import('./enumerations/entities/roles.js').Roles)[number]
|
|
45
42
|
|
|
46
|
-
type
|
|
47
|
-
(typeof import('./enumerations/entities/game-statuses.js').GameStatuses)[
|
|
48
|
-
number
|
|
49
|
-
]
|
|
43
|
+
type CityAffilation = (typeof import('./enumerations/entities/city-affilations.js').CityAffilations)[number]
|
|
50
44
|
|
|
51
|
-
type
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
]
|
|
45
|
+
type GameStatus = (typeof import('./enumerations/entities/game-statuses.js').GameStatuses)[
|
|
46
|
+
number
|
|
47
|
+
]
|
|
55
48
|
|
|
56
|
-
type
|
|
57
|
-
(typeof import('./enumerations/entities/
|
|
49
|
+
type RegistrationAttribute =
|
|
50
|
+
(typeof import('./enumerations/entities/registration-attributes.js').RegistrationAttributes)[number]
|
|
58
51
|
|
|
59
|
-
type
|
|
60
|
-
|
|
52
|
+
type RegistrationLineup = (typeof import('./enumerations/entities/registration-lineups.js').RegistrationLineups)[number]
|
|
53
|
+
|
|
54
|
+
type RegistrationStatus =
|
|
55
|
+
(typeof import('./enumerations/entities/registration-statuses.js').RegistrationStatuses)[number]
|
|
61
56
|
|
|
62
57
|
/**
|
|
63
58
|
* Misc
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const Affilations: readonly ["Branch", "Franchise"];
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const Lineups: readonly ["Main", "Reserve"];
|