@glissandoo/lib 1.17.3 → 1.17.5
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/helpers/audios.d.ts +29 -0
- package/helpers/audios.js +34 -0
- package/helpers/objects.d.ts +6 -0
- package/helpers/objects.js +28 -0
- package/helpers/utils.d.ts +0 -3
- package/helpers/utils.js +8 -16
- package/models/Group/Repertory/File/index.js +2 -2
- package/models/Group/Repertory/FilePath/index.d.ts +21 -0
- package/models/Group/Repertory/FilePath/index.js +41 -0
- package/models/Group/Repertory/index.js +2 -2
- package/models/Group/index.js +4 -4
- package/package.json +3 -2
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
declare const extensionToMimetype: {
|
|
2
|
+
readonly '.abs': "audio/x-mpeg";
|
|
3
|
+
readonly '.aif': "audio/x-aiff";
|
|
4
|
+
readonly '.aifc': "audio/x-aiff";
|
|
5
|
+
readonly '.aiff': "audio/x-aiff";
|
|
6
|
+
readonly '.au': "audio/basic";
|
|
7
|
+
readonly '.kar': "audio/midi";
|
|
8
|
+
readonly '.m3u': "audio/x-mpegurl";
|
|
9
|
+
readonly '.mid': "audio/midi";
|
|
10
|
+
readonly '.midi': "audio/midi";
|
|
11
|
+
readonly '.mp1': "audio/mpeg";
|
|
12
|
+
readonly '.mp2': "audio/mpeg";
|
|
13
|
+
readonly '.mp3': "audio/mpeg";
|
|
14
|
+
readonly '.mpa': "audio/mpeg";
|
|
15
|
+
readonly '.mpega': "audio/x-mpeg";
|
|
16
|
+
readonly '.oga': "audio/ogg";
|
|
17
|
+
readonly '.ogg': "audio/ogg";
|
|
18
|
+
readonly '.spx': "audio/ogg";
|
|
19
|
+
readonly '.flac': "audio/flac";
|
|
20
|
+
readonly '.axa': "audio/annodex";
|
|
21
|
+
readonly '.pls': "audio/x-scpls";
|
|
22
|
+
readonly '.snd': "audio/basic";
|
|
23
|
+
readonly '.ulw': "audio/basic";
|
|
24
|
+
readonly '.wav': "audio/x-wav";
|
|
25
|
+
};
|
|
26
|
+
export declare const audioExtensions: (".abs" | ".aif" | ".aifc" | ".aiff" | ".au" | ".kar" | ".m3u" | ".mid" | ".midi" | ".mp1" | ".mp2" | ".mp3" | ".mpa" | ".mpega" | ".oga" | ".ogg" | ".spx" | ".flac" | ".axa" | ".pls" | ".snd" | ".ulw" | ".wav")[];
|
|
27
|
+
export declare const audioMimeTypes: ("audio/x-mpeg" | "audio/x-aiff" | "audio/basic" | "audio/midi" | "audio/x-mpegurl" | "audio/mpeg" | "audio/ogg" | "audio/flac" | "audio/annodex" | "audio/x-scpls" | "audio/x-wav")[];
|
|
28
|
+
export declare const audioExtensionToMimeType: (ext: keyof typeof extensionToMimetype) => "audio/x-mpeg" | "audio/x-aiff" | "audio/basic" | "audio/midi" | "audio/x-mpegurl" | "audio/mpeg" | "audio/ogg" | "audio/flac" | "audio/annodex" | "audio/x-scpls" | "audio/x-wav";
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.audioExtensionToMimeType = exports.audioMimeTypes = exports.audioExtensions = void 0;
|
|
4
|
+
const lodash_1 = require("lodash");
|
|
5
|
+
const ts_extras_1 = require("ts-extras");
|
|
6
|
+
const extensionToMimetype = {
|
|
7
|
+
'.abs': 'audio/x-mpeg',
|
|
8
|
+
'.aif': 'audio/x-aiff',
|
|
9
|
+
'.aifc': 'audio/x-aiff',
|
|
10
|
+
'.aiff': 'audio/x-aiff',
|
|
11
|
+
'.au': 'audio/basic',
|
|
12
|
+
'.kar': 'audio/midi',
|
|
13
|
+
'.m3u': 'audio/x-mpegurl',
|
|
14
|
+
'.mid': 'audio/midi',
|
|
15
|
+
'.midi': 'audio/midi',
|
|
16
|
+
'.mp1': 'audio/mpeg',
|
|
17
|
+
'.mp2': 'audio/mpeg',
|
|
18
|
+
'.mp3': 'audio/mpeg',
|
|
19
|
+
'.mpa': 'audio/mpeg',
|
|
20
|
+
'.mpega': 'audio/x-mpeg',
|
|
21
|
+
'.oga': 'audio/ogg',
|
|
22
|
+
'.ogg': 'audio/ogg',
|
|
23
|
+
'.spx': 'audio/ogg',
|
|
24
|
+
'.flac': 'audio/flac',
|
|
25
|
+
'.axa': 'audio/annodex',
|
|
26
|
+
'.pls': 'audio/x-scpls',
|
|
27
|
+
'.snd': 'audio/basic',
|
|
28
|
+
'.ulw': 'audio/basic',
|
|
29
|
+
'.wav': 'audio/x-wav',
|
|
30
|
+
};
|
|
31
|
+
exports.audioExtensions = ts_extras_1.objectKeys(extensionToMimetype);
|
|
32
|
+
exports.audioMimeTypes = lodash_1.uniq(Object.values(extensionToMimetype));
|
|
33
|
+
const audioExtensionToMimeType = (ext) => extensionToMimetype[ext];
|
|
34
|
+
exports.audioExtensionToMimeType = audioExtensionToMimeType;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const toArray: <T>(obj: Record<string, T>) => (T & {
|
|
2
|
+
id: string;
|
|
3
|
+
})[];
|
|
4
|
+
export declare const map: <KIn extends string, VIn, KOut extends string, VOut>(obj: Record<KIn, VIn>, fn: (key: `${KIn}`, value: VIn, index?: number | undefined) => [KOut, VOut]) => Record<KOut, VOut>;
|
|
5
|
+
export declare const filter: <K extends string, V>(obj: Record<K, V>, fn: (key: `${Exclude<K, symbol>}`, value: V, index?: number | undefined) => unknown) => Record<`${Exclude<K, symbol>}`, V>;
|
|
6
|
+
export declare const forEach: <K extends string, V>(obj: Record<K, V>, fn: (key: `${Exclude<K, symbol>}`, value: V, index?: number | undefined) => unknown) => void;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.forEach = exports.filter = exports.map = exports.toArray = void 0;
|
|
4
|
+
const ts_extras_1 = require("ts-extras");
|
|
5
|
+
const toArray = (obj) => {
|
|
6
|
+
return ts_extras_1.objectEntries(obj).map(([key, value]) => ({
|
|
7
|
+
...value,
|
|
8
|
+
id: key,
|
|
9
|
+
}));
|
|
10
|
+
};
|
|
11
|
+
exports.toArray = toArray;
|
|
12
|
+
const map = (obj, fn) => {
|
|
13
|
+
const entries = ts_extras_1.objectEntries(obj);
|
|
14
|
+
const mappedEntries = entries.map(([key, value], index) => fn(key, value, index));
|
|
15
|
+
return ts_extras_1.objectFromEntries(mappedEntries);
|
|
16
|
+
};
|
|
17
|
+
exports.map = map;
|
|
18
|
+
const filter = (obj, fn) => {
|
|
19
|
+
const entries = ts_extras_1.objectEntries(obj);
|
|
20
|
+
const filteredEntries = entries.filter(([key, value], index) => fn(key, value, index));
|
|
21
|
+
return ts_extras_1.objectFromEntries(filteredEntries);
|
|
22
|
+
};
|
|
23
|
+
exports.filter = filter;
|
|
24
|
+
const forEach = (obj, fn) => {
|
|
25
|
+
const entries = ts_extras_1.objectEntries(obj);
|
|
26
|
+
return entries.forEach(([key, value], index) => fn(key, value, index));
|
|
27
|
+
};
|
|
28
|
+
exports.forEach = forEach;
|
package/helpers/utils.d.ts
CHANGED
|
@@ -4,7 +4,4 @@ import { Descendant } from './slate';
|
|
|
4
4
|
export declare const replaceVarsBrackets: (string: string, values: MetaNotificationData) => string;
|
|
5
5
|
export declare const replaceKeysNotification: (string: string, values: MetaNotificationData, lang: LanguagesTypes) => string;
|
|
6
6
|
export declare const serializeSlateBlock: (nodes: Descendant[]) => string;
|
|
7
|
-
export declare const objToArray: <T>(obj: Record<string, T>) => (T & {
|
|
8
|
-
id: string;
|
|
9
|
-
})[];
|
|
10
7
|
export declare const orderByMatch: <T>(list: T[], field: keyof T, order: string[]) => T[];
|
package/helpers/utils.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.orderByMatch = exports.
|
|
6
|
+
exports.orderByMatch = exports.serializeSlateBlock = exports.replaceKeysNotification = exports.replaceVarsBrackets = void 0;
|
|
7
7
|
const date_fns_1 = require("date-fns");
|
|
8
8
|
const date_fns_tz_1 = require("date-fns-tz");
|
|
9
9
|
const lodash_1 = require("lodash");
|
|
@@ -86,21 +86,13 @@ const serializeSlateBlock = (nodes) => {
|
|
|
86
86
|
.join(' ');
|
|
87
87
|
};
|
|
88
88
|
exports.serializeSlateBlock = serializeSlateBlock;
|
|
89
|
-
const objToArray = (obj) => {
|
|
90
|
-
return Object.keys(obj).map((key) => ({
|
|
91
|
-
...obj[key],
|
|
92
|
-
id: key,
|
|
93
|
-
}));
|
|
94
|
-
};
|
|
95
|
-
exports.objToArray = objToArray;
|
|
96
89
|
const orderByMatch = (list, field, order) => {
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
return lodash_1.sortBy(match, [(player) => order.indexOf(get_1.default(player, field)), 'displayName']).concat(lodash_1.orderBy(noMatch, field, 'asc'));
|
|
90
|
+
const [match, noMatch] = lodash_1.partition(list, (item) => order.includes(get_1.default(item, field)));
|
|
91
|
+
const sortedmatch = lodash_1.sortBy(match, [
|
|
92
|
+
(player) => order.indexOf(get_1.default(player, field)),
|
|
93
|
+
'displayName',
|
|
94
|
+
]);
|
|
95
|
+
const sortedNoMatch = lodash_1.orderBy(noMatch, field, 'asc');
|
|
96
|
+
return [...sortedmatch, ...sortedNoMatch];
|
|
105
97
|
};
|
|
106
98
|
exports.orderByMatch = orderByMatch;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const objects_1 = require("../../../../helpers/objects");
|
|
4
4
|
const types_1 = require("../../types");
|
|
5
5
|
class ThemeFile {
|
|
6
6
|
constructor(id, data) {
|
|
@@ -38,7 +38,7 @@ class ThemeFile {
|
|
|
38
38
|
return Object.keys(this.sections);
|
|
39
39
|
}
|
|
40
40
|
get sectionsList() {
|
|
41
|
-
const list =
|
|
41
|
+
const list = objects_1.toArray(this.sections);
|
|
42
42
|
return list.map((section) => this.isFileByPages
|
|
43
43
|
? {
|
|
44
44
|
sectionId: section.id,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { FileSectionId } from '../File/Section/types';
|
|
3
|
+
import { GroupRepertoireFilePathItem } from '../types';
|
|
4
|
+
import { LanguagesTypes } from '../../../../lang';
|
|
5
|
+
import FileSection from '../File/Section';
|
|
6
|
+
import Group from '../../';
|
|
7
|
+
import path from 'path';
|
|
8
|
+
export default class ThemeFilePath {
|
|
9
|
+
sectionId: FileSectionId;
|
|
10
|
+
protected data: GroupRepertoireFilePathItem;
|
|
11
|
+
protected lang: LanguagesTypes;
|
|
12
|
+
constructor(sectionId: FileSectionId, data: GroupRepertoireFilePathItem, lang?: LanguagesTypes);
|
|
13
|
+
get path(): string;
|
|
14
|
+
get parsedPath(): path.ParsedPath;
|
|
15
|
+
get ext(): string;
|
|
16
|
+
get isPdf(): boolean;
|
|
17
|
+
get isAudio(): boolean;
|
|
18
|
+
get section(): FileSection;
|
|
19
|
+
get tag(): string;
|
|
20
|
+
getTagName(group: Group): string | null;
|
|
21
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const lang_1 = require("../../../../lang");
|
|
7
|
+
const Section_1 = __importDefault(require("../File/Section"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const audios_1 = require("../../../../helpers/audios");
|
|
10
|
+
class ThemeFilePath {
|
|
11
|
+
constructor(sectionId, data, lang = lang_1.defaultLocale) {
|
|
12
|
+
this.sectionId = sectionId;
|
|
13
|
+
this.data = data;
|
|
14
|
+
this.lang = lang;
|
|
15
|
+
}
|
|
16
|
+
get path() {
|
|
17
|
+
return this.data.path;
|
|
18
|
+
}
|
|
19
|
+
get parsedPath() {
|
|
20
|
+
return path_1.default.parse(this.path);
|
|
21
|
+
}
|
|
22
|
+
get ext() {
|
|
23
|
+
return this.parsedPath.ext;
|
|
24
|
+
}
|
|
25
|
+
get isPdf() {
|
|
26
|
+
return this.ext === '.pdf';
|
|
27
|
+
}
|
|
28
|
+
get isAudio() {
|
|
29
|
+
return this.ext in audios_1.audioExtensions;
|
|
30
|
+
}
|
|
31
|
+
get section() {
|
|
32
|
+
return new Section_1.default(this.sectionId, this.lang);
|
|
33
|
+
}
|
|
34
|
+
get tag() {
|
|
35
|
+
return this.data.tag;
|
|
36
|
+
}
|
|
37
|
+
getTagName(group) {
|
|
38
|
+
return group.getRepertoireTagName(this.tag);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.default = ThemeFilePath;
|
|
@@ -8,7 +8,7 @@ const isFuture_1 = __importDefault(require("date-fns/isFuture"));
|
|
|
8
8
|
const lodash_1 = require("lodash");
|
|
9
9
|
const get_1 = __importDefault(require("lodash/get"));
|
|
10
10
|
const orderBy_1 = __importDefault(require("lodash/orderBy"));
|
|
11
|
-
const
|
|
11
|
+
const objects_1 = require("../../../helpers/objects");
|
|
12
12
|
const lang_1 = require("../../../lang");
|
|
13
13
|
const tiny_1 = __importDefault(require("../../Evento/tiny"));
|
|
14
14
|
const basic_1 = __importDefault(require("../../Repertory/basic"));
|
|
@@ -37,7 +37,7 @@ class GroupRepertory extends basic_1.default {
|
|
|
37
37
|
return this.data.files || {};
|
|
38
38
|
}
|
|
39
39
|
get fileList() {
|
|
40
|
-
return
|
|
40
|
+
return objects_1.toArray(this.files);
|
|
41
41
|
}
|
|
42
42
|
get sectionIds() {
|
|
43
43
|
return lodash_1.uniq(this.fileList.map((file) => Object.keys(file.sections)).flat());
|
package/models/Group/index.js
CHANGED
|
@@ -7,7 +7,7 @@ const date_fns_1 = require("date-fns");
|
|
|
7
7
|
const lodash_1 = require("lodash");
|
|
8
8
|
const orders_1 = require("../../helpers/musicStyles/orders");
|
|
9
9
|
const plans_1 = require("../../helpers/plans");
|
|
10
|
-
const
|
|
10
|
+
const objects_1 = require("../../helpers/objects");
|
|
11
11
|
const lang_1 = require("../../lang");
|
|
12
12
|
const basic_1 = __importDefault(require("./basic"));
|
|
13
13
|
const types_1 = require("./types");
|
|
@@ -139,7 +139,7 @@ class Group extends basic_1.default {
|
|
|
139
139
|
return this.data.templates || {};
|
|
140
140
|
}
|
|
141
141
|
get templatesList() {
|
|
142
|
-
return
|
|
142
|
+
return objects_1.toArray(this.templates);
|
|
143
143
|
}
|
|
144
144
|
get satisfactionIndex() {
|
|
145
145
|
return this.data.satisfactionIndex || { current: 0, last: 0 };
|
|
@@ -157,7 +157,7 @@ class Group extends basic_1.default {
|
|
|
157
157
|
return this.data.stageTemplates || {};
|
|
158
158
|
}
|
|
159
159
|
get stageTemplatesList() {
|
|
160
|
-
return
|
|
160
|
+
return objects_1.toArray(this.stageTemplates);
|
|
161
161
|
}
|
|
162
162
|
get firstAnswerAt() {
|
|
163
163
|
return this.data.firstAnswerAt || null;
|
|
@@ -166,7 +166,7 @@ class Group extends basic_1.default {
|
|
|
166
166
|
return this.data.repertoireTags || {};
|
|
167
167
|
}
|
|
168
168
|
get repertoireTagsList() {
|
|
169
|
-
return
|
|
169
|
+
return objects_1.toArray(this.repertoireTags);
|
|
170
170
|
}
|
|
171
171
|
getRepertoireTagName(id) {
|
|
172
172
|
if (!(id in this.repertoireTags))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glissandoo/lib",
|
|
3
|
-
"version": "1.17.
|
|
3
|
+
"version": "1.17.5",
|
|
4
4
|
"description": "Glissandoo library js",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"types": "./index.d.ts",
|
|
@@ -27,7 +27,8 @@
|
|
|
27
27
|
"@google-cloud/firestore": "^4.8.1",
|
|
28
28
|
"date-fns": "^2.20.3",
|
|
29
29
|
"date-fns-tz": "^1.1.3",
|
|
30
|
-
"lodash": "^4.17.21"
|
|
30
|
+
"lodash": "^4.17.21",
|
|
31
|
+
"ts-extras": "^0.11.0"
|
|
31
32
|
},
|
|
32
33
|
"devDependencies": {
|
|
33
34
|
"@localazy/cli": "^1.6.5",
|