@glissandoo/lib 1.31.0 → 1.32.1
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.d.ts +1 -1
- package/helpers/utils.js +43 -38
- package/models/Evento/basic.d.ts +1 -0
- package/models/Evento/basic.js +5 -0
- package/models/Evento/index.d.ts +0 -11
- package/models/Evento/index.js +0 -21
- package/models/Evento/tiny.d.ts +1 -0
- package/models/Evento/tiny.js +3 -0
- package/models/Evento/types.d.ts +1 -1
- package/models/Group/index.d.ts +5 -4
- package/models/Group/index.js +5 -1
- package/models/Group/types.d.ts +1 -0
- package/package.json +1 -1
package/helpers/utils.d.ts
CHANGED
|
@@ -2,6 +2,6 @@ import { LanguagesTypes } from '../lang';
|
|
|
2
2
|
import { MetaNotificationData } from '../models/User/Notification/types';
|
|
3
3
|
import { Descendant } from './slate';
|
|
4
4
|
export declare const replaceVarsBrackets: (string: string, values: MetaNotificationData) => string;
|
|
5
|
-
export declare const replaceKeysNotification: (
|
|
5
|
+
export declare const replaceKeysNotification: (text: string, values: MetaNotificationData, lang: LanguagesTypes) => string;
|
|
6
6
|
export declare const serializeSlateBlock: (nodes: Descendant[]) => string;
|
|
7
7
|
export declare const orderByMatch: <T>(list: T[], field: keyof T, order: string[]) => T[];
|
package/helpers/utils.js
CHANGED
|
@@ -21,54 +21,59 @@ const replaceVarsBrackets = (string, values) => {
|
|
|
21
21
|
return replaceString;
|
|
22
22
|
};
|
|
23
23
|
exports.replaceVarsBrackets = replaceVarsBrackets;
|
|
24
|
-
const replaceKeysNotification = (
|
|
24
|
+
const replaceKeysNotification = (text, values, lang) => {
|
|
25
25
|
const dateLang = (0, lang_1.getDateLang)(lang);
|
|
26
|
-
const matches =
|
|
26
|
+
const matches = text.match(/(\{).+?(\})/g);
|
|
27
27
|
const { extra, ...other } = values;
|
|
28
28
|
const newValues = { extra };
|
|
29
29
|
Object.keys(other || {}).forEach((key) => Object.assign(newValues, {
|
|
30
30
|
[key]: Object.values((0, get_1.default)(other, key)),
|
|
31
31
|
}));
|
|
32
|
-
let replaceString =
|
|
33
|
-
if (matches
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
case 'date': {
|
|
49
|
-
const timestamp = (0, get_1.default)(newValues, key.split('.'));
|
|
50
|
-
if (!timestamp) {
|
|
51
|
-
replaceString = replaceString.replace(match, '');
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
const dateUTC = (0, date_fns_tz_1.utcToZonedTime)(timestamp.toDate(), 'Europe/Madrid');
|
|
55
|
-
const formatValue = typeKeyMatch[2] || 'shortDate';
|
|
56
|
-
const dateFormat = (0, date_fns_1.format)(dateUTC, (0, get_1.default)(dateLang.format, formatValue), {
|
|
57
|
-
locale: dateLang.locale,
|
|
58
|
-
});
|
|
59
|
-
replaceString = replaceString.replace(match, dateFormat);
|
|
60
|
-
}
|
|
61
|
-
break;
|
|
32
|
+
let replaceString = text;
|
|
33
|
+
if (!matches || matches.length === 0) {
|
|
34
|
+
return replaceString;
|
|
35
|
+
}
|
|
36
|
+
for (const match of matches) {
|
|
37
|
+
const value = match.slice(1, -1);
|
|
38
|
+
const typeKeyMatch = value.split(':');
|
|
39
|
+
const type = typeKeyMatch[0];
|
|
40
|
+
const key = typeKeyMatch[1];
|
|
41
|
+
const path = key.split('.');
|
|
42
|
+
switch (type) {
|
|
43
|
+
case 'instrument': {
|
|
44
|
+
const instrumentId = (0, get_1.default)(newValues, path);
|
|
45
|
+
const instrument = new Instrument_1.default(instrumentId, lang);
|
|
46
|
+
if (instrument) {
|
|
47
|
+
replaceString = replaceString.replace(match, instrument.name.toLowerCase());
|
|
62
48
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
case 'date': {
|
|
52
|
+
const timestamp = (0, get_1.default)(newValues, path);
|
|
53
|
+
if (!timestamp) {
|
|
54
|
+
replaceString = replaceString.replace(match, '');
|
|
66
55
|
}
|
|
67
|
-
|
|
68
|
-
|
|
56
|
+
else {
|
|
57
|
+
const timezonePath = path;
|
|
58
|
+
timezonePath[path.length - 1] = 'timezone';
|
|
59
|
+
const timezone = (0, get_1.default)(newValues, timezonePath) || 'Europe/Madrid';
|
|
60
|
+
const dateUTC = (0, date_fns_tz_1.utcToZonedTime)(timestamp.toDate(), timezone);
|
|
61
|
+
const formatValue = typeKeyMatch[2] || 'shortDate';
|
|
62
|
+
const dateFormat = (0, date_fns_1.format)(dateUTC, (0, get_1.default)(dateLang.format, formatValue), {
|
|
63
|
+
locale: dateLang.locale,
|
|
64
|
+
});
|
|
65
|
+
replaceString = replaceString.replace(match, dateFormat);
|
|
69
66
|
}
|
|
67
|
+
break;
|
|
70
68
|
}
|
|
71
|
-
|
|
69
|
+
case 'string': {
|
|
70
|
+
replaceString = replaceString.replace(match, (0, get_1.default)(newValues, path));
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
default: {
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
72
77
|
}
|
|
73
78
|
return replaceString;
|
|
74
79
|
};
|
package/models/Evento/basic.d.ts
CHANGED
package/models/Evento/basic.js
CHANGED
|
@@ -16,6 +16,7 @@ class EventoBasic extends lang_2.default {
|
|
|
16
16
|
displayName: this.displayName,
|
|
17
17
|
datetime: this.datetime,
|
|
18
18
|
type: this.type,
|
|
19
|
+
timezone: this.data.timezone,
|
|
19
20
|
};
|
|
20
21
|
}
|
|
21
22
|
get basicInfo() {
|
|
@@ -26,6 +27,7 @@ class EventoBasic extends lang_2.default {
|
|
|
26
27
|
datetime: this.datetime,
|
|
27
28
|
datetimeEnd: this.datetimeEnd,
|
|
28
29
|
type: this.type,
|
|
30
|
+
timezone: this.data.timezone,
|
|
29
31
|
};
|
|
30
32
|
}
|
|
31
33
|
get displayName() {
|
|
@@ -67,5 +69,8 @@ class EventoBasic extends lang_2.default {
|
|
|
67
69
|
get isHappening() {
|
|
68
70
|
return (0, date_fns_1.isPast)(this.datetime.toDate()) && (0, date_fns_1.isFuture)(this.datetimeEnd.toDate());
|
|
69
71
|
}
|
|
72
|
+
get timezone() {
|
|
73
|
+
return this.data.timezone || 'Europe/Madrid';
|
|
74
|
+
}
|
|
70
75
|
}
|
|
71
76
|
exports.default = EventoBasic;
|
package/models/Evento/index.d.ts
CHANGED
|
@@ -53,19 +53,8 @@ export default class Evento extends EventoPromoter<EventData> {
|
|
|
53
53
|
get declinedRollCallPlayers(): string[];
|
|
54
54
|
get isRollCalled(): boolean;
|
|
55
55
|
get isActiveRollCall(): boolean;
|
|
56
|
-
/** @deprecated */
|
|
57
|
-
get viewers(): Record<string, import("./types").EventViewer>;
|
|
58
|
-
/** @deprecated */
|
|
59
|
-
get listViewers(): (import("./types").EventViewer & {
|
|
60
|
-
id: string;
|
|
61
|
-
})[];
|
|
62
|
-
/** @deprecated */
|
|
63
|
-
get totalViews(): number;
|
|
64
56
|
get templateId(): string | null;
|
|
65
57
|
get repeat(): import("./types").EventRepeatType | null;
|
|
66
|
-
get timezone(): string;
|
|
67
|
-
/** @deprecated */
|
|
68
|
-
getViewer(userId: string): import("./types").EventViewer | null;
|
|
69
58
|
isPlayer: (userId: string) => boolean;
|
|
70
59
|
getPlayer: (userId: string) => EventPlayerBasicData | null;
|
|
71
60
|
isPlayerConfirmed(player: EventPlayerBasicData): boolean;
|
package/models/Evento/index.js
CHANGED
|
@@ -152,33 +152,12 @@ class Evento extends promoter_1.default {
|
|
|
152
152
|
get isActiveRollCall() {
|
|
153
153
|
return (0, date_fns_1.isPast)((0, date_fns_1.addHours)(this.datetime.toDate(), -1));
|
|
154
154
|
}
|
|
155
|
-
/** @deprecated */
|
|
156
|
-
get viewers() {
|
|
157
|
-
return this.data.viewers || {};
|
|
158
|
-
}
|
|
159
|
-
/** @deprecated */
|
|
160
|
-
get listViewers() {
|
|
161
|
-
return Object.keys(this.viewers).map((userId) => Object.assign(this.viewers[userId], { id: userId }));
|
|
162
|
-
}
|
|
163
|
-
/** @deprecated */
|
|
164
|
-
get totalViews() {
|
|
165
|
-
return this.listViewers
|
|
166
|
-
.map((viewer) => viewer.count || 0)
|
|
167
|
-
.reduce((acc, current) => acc + current);
|
|
168
|
-
}
|
|
169
155
|
get templateId() {
|
|
170
156
|
return this.data.templateId || null;
|
|
171
157
|
}
|
|
172
158
|
get repeat() {
|
|
173
159
|
return this.data.repeat || null;
|
|
174
160
|
}
|
|
175
|
-
get timezone() {
|
|
176
|
-
return this.data.timezone || 'Europe/Madrid';
|
|
177
|
-
}
|
|
178
|
-
/** @deprecated */
|
|
179
|
-
getViewer(userId) {
|
|
180
|
-
return userId in this.viewers ? this.viewers[userId] : null;
|
|
181
|
-
}
|
|
182
161
|
isPlayerConfirmed(player) {
|
|
183
162
|
return player.status === types_1.EventPlayerStatus.Confirmed;
|
|
184
163
|
}
|
package/models/Evento/tiny.d.ts
CHANGED
package/models/Evento/tiny.js
CHANGED
package/models/Evento/types.d.ts
CHANGED
|
@@ -59,6 +59,7 @@ export interface EventTinyData {
|
|
|
59
59
|
displayName: string | null;
|
|
60
60
|
datetime: Timestamp;
|
|
61
61
|
type: EventType;
|
|
62
|
+
timezone: string;
|
|
62
63
|
}
|
|
63
64
|
export interface EventBasicData extends EventTinyData {
|
|
64
65
|
locality: string | null;
|
|
@@ -94,7 +95,6 @@ export interface EventData extends EventPromoterData {
|
|
|
94
95
|
repeat: EventRepeatType | null;
|
|
95
96
|
stage: EventStage | null;
|
|
96
97
|
stageTemplateId: string | null;
|
|
97
|
-
timezone: string;
|
|
98
98
|
readonly owner: DocumentReference;
|
|
99
99
|
readonly createdAt: Timestamp;
|
|
100
100
|
readonly createdOn: EventCreatedOn;
|
package/models/Group/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DocumentReference, DocumentSnapshot } from '@google-cloud/firestore';
|
|
1
|
+
import { DocumentReference, DocumentSnapshot, Timestamp } from '@google-cloud/firestore';
|
|
2
2
|
import { PlansGroup } from '../../helpers/plans';
|
|
3
3
|
import { LanguagesTypes } from '../../lang';
|
|
4
4
|
import GroupBasic from './basic';
|
|
@@ -17,8 +17,8 @@ export default class Group extends GroupBasic<GroupData> {
|
|
|
17
17
|
get invitationEmails(): string[];
|
|
18
18
|
get shortDynamicLink(): string;
|
|
19
19
|
get admins(): string[];
|
|
20
|
-
get createdAt():
|
|
21
|
-
get deletedAt():
|
|
20
|
+
get createdAt(): Timestamp;
|
|
21
|
+
get deletedAt(): Timestamp | null;
|
|
22
22
|
get repertoryCount(): number;
|
|
23
23
|
get eventCount(): Record<import("../Evento/types").EventType, number>;
|
|
24
24
|
get performanceCount(): number;
|
|
@@ -60,10 +60,11 @@ export default class Group extends GroupBasic<GroupData> {
|
|
|
60
60
|
get stageTemplatesList(): (import("../../helpers/types").StageTemplate & {
|
|
61
61
|
id: string;
|
|
62
62
|
})[];
|
|
63
|
-
get firstAnswerAt():
|
|
63
|
+
get firstAnswerAt(): Timestamp | null;
|
|
64
64
|
get repertoireTags(): Record<string, import("./types").GroupRepertoireTag>;
|
|
65
65
|
get repertoireTagsList(): (import("./types").GroupRepertoireTag & {
|
|
66
66
|
id: string;
|
|
67
67
|
})[];
|
|
68
68
|
getRepertoireTagName(id: string): string | null;
|
|
69
|
+
get trialEndAt(): Timestamp;
|
|
69
70
|
}
|
package/models/Group/index.js
CHANGED
|
@@ -3,6 +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
|
+
const firestore_1 = require("@google-cloud/firestore");
|
|
6
7
|
const date_fns_1 = require("date-fns");
|
|
7
8
|
const lodash_1 = require("lodash");
|
|
8
9
|
const orders_1 = require("../../helpers/musicStyles/orders");
|
|
@@ -148,7 +149,7 @@ class Group extends basic_1.default {
|
|
|
148
149
|
return this.data.metadata || {};
|
|
149
150
|
}
|
|
150
151
|
get isExpiredTrial() {
|
|
151
|
-
const isOutDateTrial = (0, date_fns_1.
|
|
152
|
+
const isOutDateTrial = (0, date_fns_1.isPast)(this.trialEndAt.toDate());
|
|
152
153
|
const members = this.activePlayers.length;
|
|
153
154
|
const isAboveMembersLimitPlanFree = members > plans_1.membersPerPlan[plans_1.PlansGroup.Piano];
|
|
154
155
|
return this.status !== types_1.GroupStatus.Premium && isOutDateTrial && isAboveMembersLimitPlanFree;
|
|
@@ -174,5 +175,8 @@ class Group extends basic_1.default {
|
|
|
174
175
|
const tag = this.repertoireTags[id];
|
|
175
176
|
return tag.default ? (0, lang_1.getTranslation)(tag.title, this.lang) : tag.title;
|
|
176
177
|
}
|
|
178
|
+
get trialEndAt() {
|
|
179
|
+
return this.data.trialEndAt || firestore_1.Timestamp.fromDate((0, date_fns_1.addMonths)(this.createdAt.toDate(), 1));
|
|
180
|
+
}
|
|
177
181
|
}
|
|
178
182
|
exports.default = Group;
|
package/models/Group/types.d.ts
CHANGED
|
@@ -110,6 +110,7 @@ export interface GroupData extends GroupBasicData {
|
|
|
110
110
|
metadata: Record<string, string>;
|
|
111
111
|
firstAnswerAt: Timestamp | null;
|
|
112
112
|
repertoireTags: Record<string, GroupRepertoireTag>;
|
|
113
|
+
trialEndAt: Timestamp | null;
|
|
113
114
|
readonly owner: DocumentReference;
|
|
114
115
|
readonly createdAt: Timestamp;
|
|
115
116
|
}
|