@shakerquiz/utilities 1.0.0 → 2.0.0

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.
Files changed (98) hide show
  1. package/dprint.json +3 -8
  2. package/jsconfig.json +13 -6
  3. package/package.json +12 -9
  4. package/source/enumerations/core/features.d.ts +40 -0
  5. package/source/enumerations/core/features.js +205 -0
  6. package/source/enumerations/core/kinds.d.ts +1 -0
  7. package/source/enumerations/core/kinds.js +4 -0
  8. package/source/enumerations/core/methods.d.ts +8 -0
  9. package/source/enumerations/core/methods.js +25 -0
  10. package/source/enumerations/core/networks.d.ts +1 -0
  11. package/source/enumerations/core/networks.js +4 -0
  12. package/source/enumerations/core/runtimes.d.ts +1 -0
  13. package/source/enumerations/core/runtimes.js +4 -0
  14. package/source/enumerations/core/scopes.d.ts +5 -0
  15. package/source/enumerations/core/scopes.js +27 -0
  16. package/source/enumerations/entities/city-affilations.d.ts +1 -0
  17. package/source/enumerations/entities/city-affilations.js +4 -0
  18. package/source/enumerations/entities/game-statuses.d.ts +1 -0
  19. package/source/enumerations/entities/game-statuses.js +11 -0
  20. package/source/enumerations/entities/registration-attributes.d.ts +2 -0
  21. package/source/enumerations/entities/registration-attributes.js +57 -0
  22. package/source/enumerations/entities/registration-channels.d.ts +1 -0
  23. package/source/enumerations/entities/registration-channels.js +5 -0
  24. package/source/enumerations/entities/registration-lineups.d.ts +5 -0
  25. package/source/enumerations/entities/registration-lineups.js +43 -0
  26. package/source/enumerations/entities/registration-mailings.d.ts +1 -0
  27. package/source/enumerations/entities/registration-mailings.js +6 -0
  28. package/source/enumerations/entities/registration-statuses.d.ts +5 -0
  29. package/source/enumerations/entities/registration-statuses.js +54 -0
  30. package/source/enumerations/entities/roles.d.ts +1 -0
  31. package/source/enumerations/entities/roles.js +5 -0
  32. package/source/enumerations/entities/venue-statuses.d.ts +1 -0
  33. package/source/enumerations/entities/venue-statuses.js +4 -0
  34. package/source/enumerations/misc/constants.d.ts +3 -0
  35. package/source/enumerations/{constants.js → misc/constants.js} +2 -2
  36. package/source/enumerations/misc/cookies.d.ts +5 -0
  37. package/source/enumerations/{cookies.js → misc/cookies.js} +2 -2
  38. package/source/enumerations/misc/icons.d.ts +1 -0
  39. package/source/enumerations/misc/icons.js +326 -0
  40. package/source/enumerations/misc/phases.d.ts +1 -0
  41. package/source/enumerations/misc/phases.js +7 -0
  42. package/source/enumerations/misc/regexps.d.ts +5 -0
  43. package/source/enumerations/{regexps.js → misc/regexps.js} +2 -2
  44. package/source/functions/tag.d.ts +1 -0
  45. package/source/functions/tag.js +5 -0
  46. package/source/index.d.ts +26 -14
  47. package/source/index.js +24 -11
  48. package/source/misc.d.ts +79 -0
  49. package/source/schemas/PATCH/Game/admin/schema.json +34 -0
  50. package/source/schemas/PATCH/Game/default/schema.json +6 -0
  51. package/source/schemas/PATCH/Game/organizer/schema.json +34 -0
  52. package/source/schemas/PATCH/Registration/admin/schema.json +6 -0
  53. package/source/schemas/PATCH/Registration/default/schema.json +104 -0
  54. package/source/schemas/PATCH/Registration/organizer/schema.json +43 -0
  55. package/source/schemas/PATCH/Venue/admin/schema.json +40 -0
  56. package/source/schemas/PATCH/Venue/default/schema.json +6 -0
  57. package/source/schemas/PATCH/Venue/organizer/schema.json +43 -0
  58. package/source/schemas/POST/Game/admin/schema.json +27 -0
  59. package/source/schemas/POST/Game/default/schema.json +27 -0
  60. package/source/schemas/POST/Game/organizer/schema.json +27 -0
  61. package/source/schemas/POST/Mailing/admin/schema.json +6 -0
  62. package/source/schemas/POST/Mailing/default/schema.json +6 -0
  63. package/source/schemas/POST/Mailing/organizer/schema.json +12 -0
  64. package/source/schemas/POST/Registration/admin/schema.json +6 -0
  65. package/source/schemas/POST/Registration/default/schema.json +125 -0
  66. package/source/schemas/POST/Registration/organizer/schema.json +6 -0
  67. package/source/schemas/POST/Venue/admin/schema.json +6 -0
  68. package/source/schemas/POST/Venue/default/schema.json +6 -0
  69. package/source/schemas/POST/Venue/organizer/schema.json +49 -0
  70. package/source/schemas/game.schema.json +93 -0
  71. package/source/schemas/registration.schema.json +123 -0
  72. package/source/schemas/theme.schema.json +48 -0
  73. package/source/schemas/venue.schema.json +56 -0
  74. package/source/scope.d.ts +874 -0
  75. package/source/server.d.ts +5 -0
  76. package/source/tables.d.ts +187 -0
  77. package/source/enumerations/constants.d.ts +0 -3
  78. package/source/enumerations/cookies.d.ts +0 -5
  79. package/source/enumerations/features.d.ts +0 -58
  80. package/source/enumerations/features.js +0 -49
  81. package/source/enumerations/game-statuses.d.ts +0 -39
  82. package/source/enumerations/game-statuses.js +0 -39
  83. package/source/enumerations/kinds.d.ts +0 -4
  84. package/source/enumerations/kinds.js +0 -4
  85. package/source/enumerations/methods.d.ts +0 -7
  86. package/source/enumerations/methods.js +0 -7
  87. package/source/enumerations/networks.d.ts +0 -4
  88. package/source/enumerations/networks.js +0 -4
  89. package/source/enumerations/phases.d.ts +0 -7
  90. package/source/enumerations/phases.js +0 -7
  91. package/source/enumerations/regexps.d.ts +0 -4
  92. package/source/enumerations/roles.d.ts +0 -5
  93. package/source/enumerations/roles.js +0 -5
  94. package/source/functions/request.d.ts +0 -131
  95. package/source/functions/request.js +0 -202
  96. package/source/globals.d.ts +0 -14
  97. package/source/results.d.ts +0 -137
  98. package/source/rows.d.ts +0 -533
package/dprint.json CHANGED
@@ -6,22 +6,17 @@
6
6
  "useTabs": false,
7
7
  "useBraces": "maintain",
8
8
  "arrowFunction.useParentheses": "preferNone",
9
- "lineWidth": 80
9
+ "lineWidth": 120,
10
+ "importDeclaration.forceSingleLine": true
10
11
  },
11
-
12
12
  "json": {},
13
-
14
13
  "markdown": {},
15
-
16
14
  "dockerfile": {},
17
-
18
15
  "yaml": {},
19
-
20
16
  "excludes": [
21
17
  "**/node_modules",
22
18
  "**/*-lock.json"
23
19
  ],
24
-
25
20
  "plugins": [
26
21
  "https://plugins.dprint.dev/typescript-0.93.0.wasm",
27
22
  "https://plugins.dprint.dev/json-0.19.3.wasm",
@@ -29,4 +24,4 @@
29
24
  "https://plugins.dprint.dev/dockerfile-0.3.2.wasm",
30
25
  "https://plugins.dprint.dev/g-plane/pretty_yaml-v0.5.0.wasm"
31
26
  ]
32
- }
27
+ }
package/jsconfig.json CHANGED
@@ -1,11 +1,18 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "baseUrl": ".",
4
-
5
4
  "module": "NodeNext",
6
5
  "moduleResolution": "nodenext",
7
-
8
- "strictBindCallApply": true,
9
- "allowArbitraryExtensions": true
10
- }
11
- }
6
+ "allowJs": true,
7
+ "emitDeclarationOnly": true,
8
+ "declaration": true,
9
+ "paths": {
10
+ "source/": [
11
+ "./source/*"
12
+ ]
13
+ }
14
+ },
15
+ "include": [
16
+ "source/**/*"
17
+ ]
18
+ }
package/package.json CHANGED
@@ -1,20 +1,23 @@
1
1
  {
2
+ "type": "module",
2
3
  "name": "@shakerquiz/utilities",
3
- "version": "1.0.0",
4
+ "version": "2.0.0",
4
5
  "author": "yurkimus <yurkimus@gmail.com>",
5
6
  "license": "ISC",
7
+ "scripts": {
8
+ "type": "tsc --declaration --emitdeclarationonly --allowjs"
9
+ },
6
10
  "exports": {
7
11
  ".": {
8
12
  "types": "./source/index.d.ts",
9
- "import": "./source/index.js",
10
- "edge-light": "./source/index.js"
11
- }
13
+ "default": "./source/index.js"
14
+ },
15
+ "./schemas/*.json": "./source/schemas/*.json"
12
16
  },
13
17
  "dependencies": {
14
- "@yurkimus/cookies": "0.0.7",
15
- "@yurkimus/errors": "0.1.3",
16
- "@yurkimus/message": "0.0.13",
17
- "@yurkimus/response-status": "0.1.0",
18
- "@yurkimus/url": "0.2.7"
18
+ "urlpattern-polyfill": "10.1.0"
19
+ },
20
+ "devDependencies": {
21
+ "typescript": "5.8.3"
19
22
  }
20
23
  }
@@ -0,0 +1,40 @@
1
+ export const Domains: readonly ["User", "Role", "Country", "Currency", "City", "Venue", "Theme", "Game", "Registration"];
2
+ /**
3
+ * @type {Record<Domain, Icon>}
4
+ */
5
+ export const DomainIcon: Record<Domain, Icon>;
6
+ /**
7
+ * @type {Record<Domain, Record<Kind, string>>}
8
+ */
9
+ export const DomainKindPathname: Record<Domain, Record<Kind, string>>;
10
+ export const Procedures: readonly ["Checkin", "Redirect"];
11
+ /**
12
+ * @type {Record<Procedure, Icon>}
13
+ */
14
+ export const ProcedureIcon: Record<Procedure, Icon>;
15
+ /**
16
+ * @type {Record<Procedure, Record<Kind, string>>}
17
+ */
18
+ export const ProcedureKindPathname: Record<Procedure, Record<Kind, string>>;
19
+ /**
20
+ * @type {Array<Domain | Procedure>}
21
+ */
22
+ export const Features: Array<Domain | Procedure>;
23
+ /**
24
+ * @type {Record<Feature, Icon>}
25
+ */
26
+ export const FeatureIcon: Record<Feature, Icon>;
27
+ /**
28
+ * @type {Record<Feature, Record<Kind, string>>}
29
+ */
30
+ export const FeatureKindPathname: Record<Feature, Record<Kind, string>>;
31
+ /**
32
+ * @type {Array<[feature: Feature, kind: Kind, pathname: string]>}
33
+ */
34
+ export const FeatureKindPathnames: Array<[feature: Feature, kind: Kind, pathname: string]>;
35
+ /**
36
+ * @type {Array<[feature: Feature, kind: Kind, pattern: URLPattern]>}
37
+ */
38
+ export const FeatureKindPatterns: Array<[feature: Feature, kind: Kind, pattern: URLPattern]>;
39
+ export function getPathname(feature: Feature, kind: Kind): string;
40
+ export function getPattern(feature: Feature, kind: Kind): any;
@@ -0,0 +1,205 @@
1
+ import { Kinds } from './kinds.js'
2
+
3
+ export var Domains = /** @type {const} */ ([
4
+ // 'Asset',
5
+ 'User',
6
+ 'Role',
7
+ 'Country',
8
+ 'Currency',
9
+ 'City',
10
+ 'Venue',
11
+ 'Theme',
12
+ // 'ThemeAsset',
13
+ 'Game',
14
+ // 'GameAsset',
15
+ 'Registration',
16
+ 'Mailing',
17
+ ])
18
+
19
+ /**
20
+ * @type {Record<Domain, Icon>}
21
+ */
22
+ export var DomainIcon = {
23
+ 'User': 'users',
24
+ 'Role': 'identification',
25
+ 'Country': 'no-symbol',
26
+ 'Currency': 'no-symbol',
27
+ 'City': 'building-office',
28
+ 'Venue': 'map-pin',
29
+ 'Theme': 'document-text',
30
+ 'Game': 'newspaper',
31
+ 'Registration': 'user-group',
32
+ 'Mailing': 'envelope',
33
+ }
34
+
35
+ /**
36
+ * @type {Record<Domain, Record<Kind, string>>}
37
+ */
38
+ export var DomainKindPathname = /** @type {const} */ ({
39
+ 'User': {
40
+ 'Unit': '/user/:user?',
41
+ 'Set': '/users',
42
+ },
43
+
44
+ 'Role': {
45
+ 'Unit': '/role/:role?',
46
+ 'Set': '/roles',
47
+ },
48
+
49
+ 'Country': {
50
+ 'Unit': '/country/:country?',
51
+ 'Set': '/countries',
52
+ },
53
+
54
+ 'Currency': {
55
+ 'Unit': '/currency/:currency?',
56
+ 'Set': '/currencies',
57
+ },
58
+
59
+ 'City': {
60
+ 'Unit': '/city/:city?',
61
+ 'Set': '/cities',
62
+ },
63
+
64
+ 'Venue': {
65
+ 'Unit': '/venue/:venue?',
66
+ 'Set': '/venues',
67
+ },
68
+
69
+ 'Theme': {
70
+ 'Unit': '/theme/:theme?',
71
+ 'Set': '/themes',
72
+ },
73
+
74
+ 'Game': {
75
+ /**
76
+ * Parameter "game" can be one of:
77
+ * - UUID of a Game,
78
+ * - Game alias combined with City (UUID, alias or VK group ID),
79
+ * - UUID of a Registration
80
+ */
81
+ 'Unit': '/game/:game?',
82
+ 'Set': '/games',
83
+ },
84
+
85
+ 'Registration': {
86
+ /**
87
+ * Parameter "registration" can be one of:
88
+ * - UUID of a Registration,
89
+ * - VK identifier of a Registration
90
+ */
91
+ 'Unit': '/registration/:registration?',
92
+ 'Set': '/registrations',
93
+ },
94
+
95
+ 'Mailing': {
96
+ 'Unit': '/mailing/:mailing?',
97
+ 'Set': '/mailings',
98
+ },
99
+ })
100
+
101
+ export var Procedures = /** @type {const} */ ([
102
+ 'Checkin',
103
+ 'Redirect',
104
+ ])
105
+
106
+ /**
107
+ * @type {Record<Procedure, Icon>}
108
+ */
109
+ export var ProcedureIcon = {
110
+ 'Checkin': 'arrow-right-end-on-rectangle',
111
+ 'Redirect': 'no-symbol',
112
+ }
113
+
114
+ /**
115
+ * @type {Record<Procedure, Record<Kind, string>>}
116
+ */
117
+ export var ProcedureKindPathname = /** @type {const} */ ({
118
+ 'Checkin': {
119
+ 'Unit': '/checkin',
120
+ 'Set': '/checkins',
121
+ },
122
+
123
+ 'Redirect': {
124
+ 'Unit': '/redirect',
125
+ 'Set': '/redirects',
126
+ },
127
+ })
128
+
129
+ /**
130
+ * @type {Array<Domain | Procedure>}
131
+ */
132
+ export var Features = Domains.concat(Procedures)
133
+
134
+ /**
135
+ * @type {Record<Feature, Icon>}
136
+ */
137
+ export var FeatureIcon = {
138
+ ...DomainIcon,
139
+ ...ProcedureIcon,
140
+ }
141
+
142
+ /**
143
+ * @type {Record<Feature, Record<Kind, string>>}
144
+ */
145
+ export var FeatureKindPathname = {
146
+ ...DomainKindPathname,
147
+ ...ProcedureKindPathname,
148
+ }
149
+
150
+ /**
151
+ * @type {Array<[feature: Feature, kind: Kind, pathname: string]>}
152
+ */
153
+ export var FeatureKindPathnames = Object
154
+ .keys(FeatureKindPathname)
155
+ .flatMap(feature =>
156
+ Object
157
+ .keys(FeatureKindPathname[feature])
158
+ .map(kind => [feature, kind, FeatureKindPathname[feature][kind]])
159
+ )
160
+
161
+ /**
162
+ * @type {Array<[feature: Feature, kind: Kind, pattern: URLPattern]>}
163
+ */
164
+ export var FeatureKindPatterns = FeatureKindPathnames
165
+ .map(([feature, kind, pathname]) => [
166
+ feature,
167
+ kind,
168
+ new URLPattern({ pathname }),
169
+ ])
170
+
171
+ /**
172
+ * @param {Feature} feature
173
+ * @param {Kind} kind
174
+ */
175
+ export var getPathname = (feature, kind) => {
176
+ if (!Features.includes(feature))
177
+ throw TypeError(
178
+ `[getPathname] Feature '${feature}' must be listed in 'Features'.`,
179
+ )
180
+
181
+ if (!Kinds.includes(kind))
182
+ throw TypeError(
183
+ `[getPathname] Kind '${kind}' must be listed in 'Kinds'.`,
184
+ )
185
+
186
+ return FeatureKindPathname[feature][kind]
187
+ }
188
+
189
+ /**
190
+ * @param {Feature} feature
191
+ * @param {Kind} kind
192
+ */
193
+ export var getPattern = (feature, kind) => {
194
+ if (!Features.includes(feature))
195
+ throw TypeError(
196
+ `[getPattern] Feature '${feature}' must be listed in 'Features'.`,
197
+ )
198
+
199
+ if (!Kinds.includes(kind))
200
+ throw TypeError(
201
+ `[getPattern] Kind '${kind}' must be listed in 'Kinds'.`,
202
+ )
203
+
204
+ return FeatureKindPatterns.find(([f, k]) => f == feature && k == kind)[2]
205
+ }
@@ -0,0 +1 @@
1
+ export const Kinds: readonly ["Unit", "Set"];
@@ -0,0 +1,4 @@
1
+ export var Kinds = /** @type {const} */ ([
2
+ 'Unit',
3
+ 'Set',
4
+ ])
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Related specifications:
3
+ * - HTTP/1.1 (Core Methods): {@link https://datatracker.ietf.org/doc/html/rfc7231#section-4.3}
4
+ * - PATCH: {@link https://datatracker.ietf.org/doc/html/rfc5789}
5
+ * - CONNECT: {@link https://datatracker.ietf.org/doc/html/rfc9110}
6
+ * - WebDAV Extensions {@link https://datatracker.ietf.org/doc/html/rfc4918}
7
+ */
8
+ export const Methods: readonly ["DELETE", "GET", "OPTIONS", "PATCH", "POST", "PUT"];
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Related specifications:
3
+ * - HTTP/1.1 (Core Methods): {@link https://datatracker.ietf.org/doc/html/rfc7231#section-4.3}
4
+ * - PATCH: {@link https://datatracker.ietf.org/doc/html/rfc5789}
5
+ * - CONNECT: {@link https://datatracker.ietf.org/doc/html/rfc9110}
6
+ * - WebDAV Extensions {@link https://datatracker.ietf.org/doc/html/rfc4918}
7
+ */
8
+ export var Methods = /** @type {const} */ ([
9
+ // 'CONNECT',
10
+ // 'COPY',
11
+ 'DELETE',
12
+ 'GET',
13
+ // 'HEAD',
14
+ // 'LOCK',
15
+ // 'MKCOL',
16
+ // 'MOVE',
17
+ 'OPTIONS',
18
+ 'PATCH',
19
+ 'POST',
20
+ // 'PROPFIND',
21
+ // 'PROPPATCH',
22
+ 'PUT',
23
+ // 'TRACE',
24
+ // 'UNLOCK',
25
+ ])
@@ -0,0 +1 @@
1
+ export const Networks: readonly ["Docker", "Public"];
@@ -0,0 +1,4 @@
1
+ export var Networks = /** @type {const} */ ([
2
+ 'Docker',
3
+ 'Public',
4
+ ])
@@ -0,0 +1 @@
1
+ export const Runtimes: readonly ["Next", "React"];
@@ -0,0 +1,4 @@
1
+ export var Runtimes = /** @type {const} */ ([
2
+ 'Next',
3
+ 'React',
4
+ ])
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @type {Scope[]}
3
+ */
4
+ export const Scopes: Scope[];
5
+ export function getScope(request: Request): Scope | "";
@@ -0,0 +1,27 @@
1
+ import { FeatureKindPatterns, Features } from './features.js'
2
+ import { Kinds } from './kinds.js'
3
+ import { Methods } from './methods.js'
4
+
5
+ /**
6
+ * @type {Scope[]}
7
+ */
8
+ export var Scopes = Object
9
+ .values(Methods)
10
+ .flatMap(method => Object.values(Features).map(feature => [method, feature]))
11
+ .flatMap(array => Object.values(Kinds).map(kind => array.concat(kind)))
12
+ .map(array => array.join('/'))
13
+
14
+ /**
15
+ * @param {Request} request
16
+ *
17
+ * @returns {Scope | ''}
18
+ */
19
+ export var getScope = request => {
20
+ var found = FeatureKindPatterns
21
+ .find(([, , pattern]) => pattern.test(request.url))
22
+ ?.slice(0, -1)
23
+
24
+ return found
25
+ ? request.method + '/' + found[0] + '/' + found[1]
26
+ : ''
27
+ }
@@ -0,0 +1 @@
1
+ export const CityAffilations: readonly ["Branch", "Franchise"];
@@ -0,0 +1,4 @@
1
+ export var CityAffilations = /** @type {const} */ ([
2
+ 'Branch',
3
+ 'Franchise',
4
+ ])
@@ -0,0 +1 @@
1
+ export const GameStatuses: readonly ["APPROVED", "ARCHIVE", "CLOSED", "FINISHED", "FORINVITES", "MODERATION", "PUBLISHED", "REJECTED", "IS_RESERVE"];
@@ -0,0 +1,11 @@
1
+ export var GameStatuses = /** @type {const} */ ([
2
+ 'APPROVED',
3
+ 'ARCHIVE',
4
+ 'CLOSED',
5
+ 'FINISHED',
6
+ 'FORINVITES',
7
+ 'MODERATION',
8
+ 'PUBLISHED',
9
+ 'REJECTED',
10
+ 'IS_RESERVE',
11
+ ])
@@ -0,0 +1,2 @@
1
+ export const RegistrationAttributes: readonly ["Alone", "Birthday", "Newcomer", "Public"];
2
+ export function getRegistrationAttributes(value: RegistrationAttribute[] | Partial<Pick<RegistrationTable, "is_alone" | "is_birthday" | "is_extensible" | "is_first">>): any;
@@ -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 @@
1
+ export const RegistrationChannels: readonly ["email", "telegramBot", "vkontakte"];
@@ -0,0 +1,5 @@
1
+ export var RegistrationChannels = /** @type {const} */ ([
2
+ 'email',
3
+ 'telegramBot',
4
+ 'vkontakte',
5
+ ])
@@ -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
+ }
@@ -0,0 +1 @@
1
+ export const RegistrationMailings: readonly ["Idle", "Pending", "Delivered", "Failed"];
@@ -0,0 +1,6 @@
1
+ export var RegistrationMailings = /** @type {const} */ ([
2
+ 'Idle',
3
+ 'Pending',
4
+ 'Delivered',
5
+ 'Failed',
6
+ ])
@@ -0,0 +1,5 @@
1
+ export const RegistrationStatuses: readonly ["Created", "Confirmed", "Cancelled"];
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 {};
@@ -0,0 +1,54 @@
1
+ export var RegistrationStatuses = /** @type {const} */ ([
2
+ 'Created',
3
+ 'Confirmed',
4
+ 'Cancelled',
5
+ ])
6
+
7
+ /** @type {Record<RegistrationStatus, Pick<RegistrationTable, 'is_canceled' | 'is_confirm'>>} */
8
+ let RegistrationStatusShape = {
9
+ 'Created': {
10
+ is_canceled: false,
11
+ is_confirm: false,
12
+ },
13
+
14
+ 'Confirmed': {
15
+ is_canceled: false,
16
+ is_confirm: true,
17
+ },
18
+
19
+ 'Cancelled': {
20
+ is_canceled: true,
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 const Roles: readonly ["admin", "default", "organizer"];
@@ -0,0 +1,5 @@
1
+ export var Roles = /** @type {const} */ ([
2
+ 'admin',
3
+ 'default',
4
+ 'organizer',
5
+ ])
@@ -0,0 +1 @@
1
+ export const VenueStatuses: readonly ['ACTIVE', 'ARCHIVE']