@glissandoo/lib 1.16.9 → 1.16.11

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/utils.js CHANGED
@@ -10,6 +10,7 @@ const lodash_1 = require("lodash");
10
10
  const get_1 = __importDefault(require("lodash/get"));
11
11
  const lang_1 = require("../lang");
12
12
  const Instrument_1 = __importDefault(require("../models/Instrument"));
13
+ const instruments_1 = require("./instruments");
13
14
  const replaceVarsBrackets = (string, values) => {
14
15
  const matches = string.match(/[^[\]]+(?=])/g);
15
16
  let replaceString = string;
@@ -39,10 +40,11 @@ const replaceKeysNotification = (string, values, lang) => {
39
40
  switch (type) {
40
41
  case 'instrument': {
41
42
  const instrumentId = get_1.default(newValues, key.split('.'));
42
- const instrument = new Instrument_1.default(instrumentId, lang);
43
- if (instrument) {
44
- replaceString = replaceString.replace(match, instrument.name.toLowerCase());
43
+ if (!Object.values(instruments_1.InstrumentId).includes(instrumentId)) {
44
+ throw new Error(`Invalid instrumentId: ${instrumentId} from value: ${value}`);
45
45
  }
46
+ const instrument = new Instrument_1.default(instrumentId, lang);
47
+ replaceString = replaceString.replace(match, instrument.name.toLowerCase());
46
48
  break;
47
49
  }
48
50
  case 'date': {
@@ -2,7 +2,7 @@ import { DocumentReference, DocumentSnapshot } from '@google-cloud/firestore';
2
2
  import { PlansGroup } from '../../helpers/plans';
3
3
  import { LanguagesTypes } from '../../lang';
4
4
  import GroupBasic from './basic';
5
- import { GroupData, GroupStatus, SocialNetwork, GroupRepertoireTag } from './types';
5
+ import { GroupData, GroupRepertoireTag, GroupStatus, SocialNetwork } from './types';
6
6
  export default class Group extends GroupBasic<GroupData> {
7
7
  constructor(doc: DocumentSnapshot, lang?: LanguagesTypes);
8
8
  get owner(): DocumentReference;
@@ -65,5 +65,6 @@ export default class Group extends GroupBasic<GroupData> {
65
65
  get repertoireTagsList(): (GroupRepertoireTag & {
66
66
  id: string;
67
67
  })[];
68
+ getRepertoireTagName(id: string): string | null;
68
69
  getRepertoireTagNameTranslator(): (id: string, repertoireTags?: Record<string, GroupRepertoireTag>, lang?: LanguagesTypes) => string | null;
69
70
  }
@@ -168,6 +168,12 @@ class Group extends basic_1.default {
168
168
  get repertoireTagsList() {
169
169
  return utils_1.objToArray(this.repertoireTags);
170
170
  }
171
+ getRepertoireTagName(id) {
172
+ if (!(id in this.repertoireTags))
173
+ return null;
174
+ const tag = this.repertoireTags[id];
175
+ return tag.default ? lang_1.getTranslation(tag.title, this.lang) : tag.title;
176
+ }
171
177
  getRepertoireTagNameTranslator() {
172
178
  return (id, repertoireTags = { ...this.repertoireTags }, lang = this.lang) => {
173
179
  if (!(id in repertoireTags))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glissandoo/lib",
3
- "version": "1.16.9",
3
+ "version": "1.16.11",
4
4
  "description": "Glissandoo library js",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",