@glissandoo/lib 1.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 (208) hide show
  1. package/functions/communication.d.ts +31 -0
  2. package/functions/communication.js +2 -0
  3. package/functions/event.d.ts +113 -0
  4. package/functions/event.js +18 -0
  5. package/functions/eventPlayer.d.ts +20 -0
  6. package/functions/eventPlayer.js +13 -0
  7. package/functions/eventRepertory.d.ts +9 -0
  8. package/functions/eventRepertory.js +2 -0
  9. package/functions/federation.d.ts +23 -0
  10. package/functions/federation.js +2 -0
  11. package/functions/federationPartnership.d.ts +34 -0
  12. package/functions/federationPartnership.js +2 -0
  13. package/functions/group.d.ts +32 -0
  14. package/functions/group.js +2 -0
  15. package/functions/groupPlayer.d.ts +37 -0
  16. package/functions/groupPlayer.js +2 -0
  17. package/functions/groupRepertory.d.ts +54 -0
  18. package/functions/groupRepertory.js +2 -0
  19. package/functions/index.d.ts +73 -0
  20. package/functions/index.js +77 -0
  21. package/functions/misc.d.ts +9 -0
  22. package/functions/misc.js +2 -0
  23. package/functions/notification.d.ts +4 -0
  24. package/functions/notification.js +2 -0
  25. package/functions/partner.d.ts +63 -0
  26. package/functions/partner.js +2 -0
  27. package/functions/partnership.d.ts +23 -0
  28. package/functions/partnership.js +2 -0
  29. package/functions/partnershipGroup.d.ts +12 -0
  30. package/functions/partnershipGroup.js +2 -0
  31. package/functions/partnershipPlan.d.ts +23 -0
  32. package/functions/partnershipPlan.js +2 -0
  33. package/functions/regions.d.ts +6 -0
  34. package/functions/regions.js +85 -0
  35. package/functions/subscription.d.ts +20 -0
  36. package/functions/subscription.js +2 -0
  37. package/functions/user.d.ts +19 -0
  38. package/functions/user.js +2 -0
  39. package/helpers/appScenes.d.ts +45 -0
  40. package/helpers/appScenes.js +49 -0
  41. package/helpers/badges.d.ts +21 -0
  42. package/helpers/badges.js +162 -0
  43. package/helpers/collections.d.ts +28 -0
  44. package/helpers/collections.js +32 -0
  45. package/helpers/instruments/index.d.ts +67 -0
  46. package/helpers/instruments/index.js +145 -0
  47. package/helpers/musicStyles/index.d.ts +9 -0
  48. package/helpers/musicStyles/index.js +16 -0
  49. package/helpers/musicStyles/orders.d.ts +4 -0
  50. package/helpers/musicStyles/orders.js +128 -0
  51. package/helpers/notifications.d.ts +40 -0
  52. package/helpers/notifications.js +120 -0
  53. package/helpers/payments.d.ts +2 -0
  54. package/helpers/payments.js +9 -0
  55. package/helpers/utils.d.ts +6 -0
  56. package/helpers/utils.js +99 -0
  57. package/index.d.ts +0 -0
  58. package/index.js +1 -0
  59. package/lang/ca.json +194 -0
  60. package/lang/de.json +194 -0
  61. package/lang/en.json +194 -0
  62. package/lang/es.json +194 -0
  63. package/lang/gl.json +194 -0
  64. package/lang/index.d.ts +1078 -0
  65. package/lang/index.js +101 -0
  66. package/models/Communication/index.d.ts +47 -0
  67. package/models/Communication/index.js +138 -0
  68. package/models/Communication/types.d.ts +53 -0
  69. package/models/Communication/types.js +13 -0
  70. package/models/Counters/index.d.ts +7 -0
  71. package/models/Counters/index.js +15 -0
  72. package/models/Counters/types.d.ts +3 -0
  73. package/models/Counters/types.js +2 -0
  74. package/models/Evento/Player/index.d.ts +17 -0
  75. package/models/Evento/Player/index.js +45 -0
  76. package/models/Evento/Player/types.d.ts +15 -0
  77. package/models/Evento/Player/types.js +8 -0
  78. package/models/Evento/Repertory/index.d.ts +9 -0
  79. package/models/Evento/Repertory/index.js +22 -0
  80. package/models/Evento/Repertory/types.d.ts +5 -0
  81. package/models/Evento/Repertory/types.js +2 -0
  82. package/models/Evento/basic.d.ts +22 -0
  83. package/models/Evento/basic.js +72 -0
  84. package/models/Evento/index.d.ts +66 -0
  85. package/models/Evento/index.js +178 -0
  86. package/models/Evento/promoter.d.ts +11 -0
  87. package/models/Evento/promoter.js +24 -0
  88. package/models/Evento/tiny.d.ts +13 -0
  89. package/models/Evento/tiny.js +32 -0
  90. package/models/Evento/types.d.ts +76 -0
  91. package/models/Evento/types.js +22 -0
  92. package/models/Federation/Partnership/index.d.ts +12 -0
  93. package/models/Federation/Partnership/index.js +31 -0
  94. package/models/Federation/Partnership/types.d.ts +8 -0
  95. package/models/Federation/Partnership/types.js +2 -0
  96. package/models/Federation/index.d.ts +20 -0
  97. package/models/Federation/index.js +54 -0
  98. package/models/Federation/types.d.ts +16 -0
  99. package/models/Federation/types.js +2 -0
  100. package/models/Group/Analytics/index.d.ts +11 -0
  101. package/models/Group/Analytics/index.js +29 -0
  102. package/models/Group/Analytics/types.d.ts +20 -0
  103. package/models/Group/Analytics/types.js +13 -0
  104. package/models/Group/Event/index.d.ts +15 -0
  105. package/models/Group/Event/index.js +38 -0
  106. package/models/Group/Event/types.d.ts +11 -0
  107. package/models/Group/Event/types.js +2 -0
  108. package/models/Group/Player/Event/index.d.ts +17 -0
  109. package/models/Group/Player/Event/index.js +42 -0
  110. package/models/Group/Player/Event/types.d.ts +8 -0
  111. package/models/Group/Player/Event/types.js +2 -0
  112. package/models/Group/Player/Log/index.d.ts +12 -0
  113. package/models/Group/Player/Log/index.js +24 -0
  114. package/models/Group/Player/Log/types.d.ts +11 -0
  115. package/models/Group/Player/Log/types.js +2 -0
  116. package/models/Group/Player/index.d.ts +55 -0
  117. package/models/Group/Player/index.js +221 -0
  118. package/models/Group/Player/types.d.ts +43 -0
  119. package/models/Group/Player/types.js +9 -0
  120. package/models/Group/Repertory/index.d.ts +67 -0
  121. package/models/Group/Repertory/index.js +149 -0
  122. package/models/Group/Repertory/types.d.ts +43 -0
  123. package/models/Group/Repertory/types.js +2 -0
  124. package/models/Group/basic.d.ts +17 -0
  125. package/models/Group/basic.js +51 -0
  126. package/models/Group/index.d.ts +43 -0
  127. package/models/Group/index.js +115 -0
  128. package/models/Group/types.d.ts +68 -0
  129. package/models/Group/types.js +21 -0
  130. package/models/Instrument/index.d.ts +9 -0
  131. package/models/Instrument/index.js +17 -0
  132. package/models/Metrics/index.d.ts +17 -0
  133. package/models/Metrics/index.js +47 -0
  134. package/models/Metrics/types.d.ts +12 -0
  135. package/models/Metrics/types.js +2 -0
  136. package/models/Model.d.ts +10 -0
  137. package/models/Model.js +21 -0
  138. package/models/MusicStyle/index.d.ts +8 -0
  139. package/models/MusicStyle/index.js +13 -0
  140. package/models/Notification/index.d.ts +12 -0
  141. package/models/Notification/index.js +26 -0
  142. package/models/Notification/types.d.ts +71 -0
  143. package/models/Notification/types.js +68 -0
  144. package/models/Partner/basic.d.ts +14 -0
  145. package/models/Partner/basic.js +43 -0
  146. package/models/Partner/index.d.ts +16 -0
  147. package/models/Partner/index.js +48 -0
  148. package/models/Partner/tiny.d.ts +9 -0
  149. package/models/Partner/tiny.js +24 -0
  150. package/models/Partner/types.d.ts +43 -0
  151. package/models/Partner/types.js +9 -0
  152. package/models/Partnership/Group/index.d.ts +8 -0
  153. package/models/Partnership/Group/index.js +17 -0
  154. package/models/Partnership/Group/types.d.ts +2 -0
  155. package/models/Partnership/Group/types.js +2 -0
  156. package/models/Partnership/Partner/Subscription/index.d.ts +19 -0
  157. package/models/Partnership/Partner/Subscription/index.js +56 -0
  158. package/models/Partnership/Partner/Subscription/types.d.ts +21 -0
  159. package/models/Partnership/Partner/Subscription/types.js +9 -0
  160. package/models/Partnership/Partner/index.d.ts +9 -0
  161. package/models/Partnership/Partner/index.js +22 -0
  162. package/models/Partnership/Partner/types.d.ts +5 -0
  163. package/models/Partnership/Partner/types.js +2 -0
  164. package/models/Partnership/Payment/index.d.ts +8 -0
  165. package/models/Partnership/Payment/index.js +18 -0
  166. package/models/Partnership/Payment/types.d.ts +6 -0
  167. package/models/Partnership/Payment/types.js +2 -0
  168. package/models/Partnership/Plan/basic.d.ts +19 -0
  169. package/models/Partnership/Plan/basic.js +65 -0
  170. package/models/Partnership/Plan/index.d.ts +12 -0
  171. package/models/Partnership/Plan/index.js +31 -0
  172. package/models/Partnership/Plan/types.d.ts +23 -0
  173. package/models/Partnership/Plan/types.js +10 -0
  174. package/models/Partnership/basic.d.ts +17 -0
  175. package/models/Partnership/basic.js +58 -0
  176. package/models/Partnership/index.d.ts +18 -0
  177. package/models/Partnership/index.js +55 -0
  178. package/models/Partnership/types.d.ts +37 -0
  179. package/models/Partnership/types.js +9 -0
  180. package/models/Payment/basic.d.ts +17 -0
  181. package/models/Payment/basic.js +53 -0
  182. package/models/Payment/index.d.ts +13 -0
  183. package/models/Payment/index.js +33 -0
  184. package/models/Payment/types.d.ts +32 -0
  185. package/models/Payment/types.js +17 -0
  186. package/models/Player/basic.d.ts +10 -0
  187. package/models/Player/basic.js +27 -0
  188. package/models/Player/types.d.ts +8 -0
  189. package/models/Player/types.js +2 -0
  190. package/models/Repertory/basic.d.ts +11 -0
  191. package/models/Repertory/basic.js +32 -0
  192. package/models/Repertory/types.d.ts +21 -0
  193. package/models/Repertory/types.js +2 -0
  194. package/models/User/Group/index.d.ts +15 -0
  195. package/models/User/Group/index.js +36 -0
  196. package/models/User/Group/types.d.ts +10 -0
  197. package/models/User/Group/types.js +2 -0
  198. package/models/User/Notification/index.d.ts +25 -0
  199. package/models/User/Notification/index.js +73 -0
  200. package/models/User/Notification/types.d.ts +25 -0
  201. package/models/User/Notification/types.js +2 -0
  202. package/models/User/basic.d.ts +13 -0
  203. package/models/User/basic.js +35 -0
  204. package/models/User/index.d.ts +46 -0
  205. package/models/User/index.js +119 -0
  206. package/models/User/types.d.ts +68 -0
  207. package/models/User/types.js +26 -0
  208. package/package.json +39 -0
@@ -0,0 +1,149 @@
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 endOfDay_1 = __importDefault(require("date-fns/endOfDay"));
7
+ const isFuture_1 = __importDefault(require("date-fns/isFuture"));
8
+ const get_1 = __importDefault(require("lodash/get"));
9
+ const orderBy_1 = __importDefault(require("lodash/orderBy"));
10
+ const basic_1 = __importDefault(require("../../Repertory/basic"));
11
+ class GroupRepertory extends basic_1.default {
12
+ constructor(doc) {
13
+ super(doc);
14
+ }
15
+ get groupId() {
16
+ return get_1.default(this.ref, 'parent.parent.id');
17
+ }
18
+ get tagsAlgolia() {
19
+ return this.data.tagsAlgolia || [];
20
+ }
21
+ get instruments() {
22
+ const instruments = this.data.instruments || [];
23
+ return instruments.map((instrument) => (Object.assign(Object.assign({}, instrument), { filesPath: instrument.filesPath })));
24
+ }
25
+ get mainFilePath() {
26
+ return this.data.mainFilePath;
27
+ }
28
+ get events() {
29
+ return this.data.events || [];
30
+ }
31
+ get eventsTL() {
32
+ return this.data.eventsTL || {};
33
+ }
34
+ get eventsList() {
35
+ return Object.keys(this.eventsTL).map((id) => Object.assign(this.eventsTL[id], { id }));
36
+ }
37
+ /** @deprecated use getNextEvents */
38
+ get nextEvents() {
39
+ return this.getEventsByOrder().filter((ev) => isFuture_1.default(ev.datetime.toDate()));
40
+ }
41
+ /** @deprecated use getNextEvent */
42
+ get nextEvent() {
43
+ if (this.nextEvents.length === 0) {
44
+ return null;
45
+ }
46
+ return this.nextEvents[this.nextEvents.length - 1];
47
+ }
48
+ get scoresByInstruments() {
49
+ return this.data.scoresByInstruments || false;
50
+ }
51
+ get editedAt() {
52
+ return this.data.editedAt;
53
+ }
54
+ get createdAt() {
55
+ return this.data.createdAt;
56
+ }
57
+ get audios() {
58
+ return this.data.audios || [];
59
+ }
60
+ get identifyAt() {
61
+ return this.data.identifyAt;
62
+ }
63
+ get isIdentify() {
64
+ return this.identifyAt !== null || this.identifyAt !== undefined;
65
+ }
66
+ get isActive() {
67
+ return this.exists;
68
+ }
69
+ get thumbnailURL() {
70
+ return this.data.thumbnailURL || null;
71
+ }
72
+ get ownerId() {
73
+ return this.data.owner.id;
74
+ }
75
+ /** @deprecated */
76
+ get viewers() {
77
+ return this.data.viewers || {};
78
+ }
79
+ /** @deprecated */
80
+ get listViewers() {
81
+ return Object.keys(this.viewers).map((userId) => Object.assign(this.viewers[userId], { id: userId }));
82
+ }
83
+ /** @deprecated */
84
+ get totalViews() {
85
+ return this.listViewers
86
+ .map((viewer) => viewer.count || 0)
87
+ .reduce((acc, current) => acc + current);
88
+ }
89
+ get claims() {
90
+ return this.data.claims || {};
91
+ }
92
+ get claimsList() {
93
+ const list = [];
94
+ Object.keys(this.claims).map((instrumentId) => {
95
+ Object.keys(this.claims[instrumentId] || {}).map((userId) => {
96
+ list.push(Object.assign({ userId, instrumentId: instrumentId }, this.claims[instrumentId][userId]));
97
+ });
98
+ });
99
+ return list;
100
+ }
101
+ claimsByInstrument(instrumentId) {
102
+ if (!this.isInstrumentClaimed(instrumentId)) {
103
+ return {};
104
+ }
105
+ return instrumentId in this.claims ? this.claims[instrumentId] : {};
106
+ }
107
+ getPlayersByInstrumentClaimed(instrumentId, onlyNoNotified = false) {
108
+ const claimsByInstrument = this.claimsByInstrument(instrumentId);
109
+ if (!onlyNoNotified) {
110
+ return Object.keys(claimsByInstrument);
111
+ }
112
+ return Object.keys(claimsByInstrument).filter((userId) => !claimsByInstrument[userId].notifiedAt);
113
+ }
114
+ isInstrumentClaimed(instrumentId) {
115
+ return instrumentId in this.claims;
116
+ }
117
+ isInstrumentClaimedByPlayer(instrumentId, userId) {
118
+ if (!this.isInstrumentClaimed(instrumentId)) {
119
+ return false;
120
+ }
121
+ return userId in this.claims[instrumentId];
122
+ }
123
+ /** @deprecated */
124
+ getViewer(userId) {
125
+ return userId in this.viewers ? this.viewers[userId] : null;
126
+ }
127
+ getInstrument(id) {
128
+ return this.instruments.find((i) => i.id === id);
129
+ }
130
+ getNextEvents(endDay = false) {
131
+ return this.getEventsByOrder().filter((ev) => {
132
+ if (endDay) {
133
+ return isFuture_1.default(endOfDay_1.default(ev.datetime.toDate()));
134
+ }
135
+ return isFuture_1.default(ev.datetime.toDate());
136
+ });
137
+ }
138
+ getNextEvent(endDay = false) {
139
+ const events = this.getNextEvents(endDay);
140
+ if (events.length === 0) {
141
+ return null;
142
+ }
143
+ return events[events.length - 1];
144
+ }
145
+ getEventsByOrder(order = 'desc') {
146
+ return orderBy_1.default(this.eventsList, (e) => e.datetime.toDate(), [order]);
147
+ }
148
+ }
149
+ exports.default = GroupRepertory;
@@ -0,0 +1,43 @@
1
+ import { DocumentReference, Timestamp } from '@google-cloud/firestore';
2
+ import { InstrumentId } from '../../../helpers/instruments';
3
+ import { EventTinyData } from '../../Evento/types';
4
+ import { ThemeBasicData } from '../../Repertory/types';
5
+ export interface AGroupRepertoryClaim extends GroupRepertoryClaimType {
6
+ userId: string;
7
+ instrumentId: InstrumentId;
8
+ }
9
+ export interface GroupRepertoryViewer {
10
+ viewedAt: Timestamp;
11
+ lastViewedAt: Timestamp;
12
+ count: number;
13
+ }
14
+ export interface GroupRepertoryClaimType {
15
+ createdAt: Timestamp;
16
+ notifiedAt: Timestamp | null;
17
+ }
18
+ export interface GroupRepertoryTagAlgoliaData {
19
+ query: string;
20
+ objectID: string | null;
21
+ }
22
+ export interface GroupRepertoryInstrumentItemData {
23
+ id: InstrumentId;
24
+ pages: number[];
25
+ filesPath?: string[];
26
+ }
27
+ export interface GroupRepertoryData extends ThemeBasicData {
28
+ events: string[];
29
+ eventsTL: Record<string, EventTinyData>;
30
+ tagsAlgolia: GroupRepertoryTagAlgoliaData[];
31
+ mainFilePath: string | null;
32
+ scoresByInstruments: boolean;
33
+ instruments: GroupRepertoryInstrumentItemData[];
34
+ audios: string[];
35
+ thumbnailURL: string | null;
36
+ identifyAt: Timestamp | null;
37
+ editedAt: Timestamp | null;
38
+ /** @deprecated */
39
+ viewers: Record<string, GroupRepertoryViewer>;
40
+ claims: Record<string, Record<string, GroupRepertoryClaimType>>;
41
+ readonly owner: DocumentReference;
42
+ readonly createdAt: Timestamp;
43
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,17 @@
1
+ import { DocumentSnapshot } from '@google-cloud/firestore';
2
+ import { LanguagesTypes } from '../../lang';
3
+ import Model from '../Model';
4
+ import { GroupBasicData, GroupTinyData } from './types';
5
+ export default class GroupBasic<D> extends Model<D & GroupBasicData> {
6
+ protected lang: LanguagesTypes;
7
+ constructor(doc: DocumentSnapshot, lang: LanguagesTypes);
8
+ get tinyInfo(): GroupTinyData;
9
+ get basicInfo(): GroupBasicData;
10
+ get displayName(): string;
11
+ get photoURL(): string;
12
+ get locality(): string;
13
+ get location(): FirebaseFirestore.GeoPoint;
14
+ get username(): string;
15
+ get musicStyle(): import("../../helpers/musicStyles").MusicStyleId;
16
+ get musicStyleString(): string;
17
+ }
@@ -0,0 +1,51 @@
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 Model_1 = __importDefault(require("../Model"));
8
+ class GroupBasic extends Model_1.default {
9
+ constructor(doc, lang) {
10
+ super(doc);
11
+ this.lang = lang;
12
+ }
13
+ get tinyInfo() {
14
+ return {
15
+ displayName: this.displayName,
16
+ photoURL: this.photoURL,
17
+ };
18
+ }
19
+ get basicInfo() {
20
+ return {
21
+ displayName: this.displayName,
22
+ photoURL: this.photoURL,
23
+ username: this.username,
24
+ locality: this.locality,
25
+ location: this.location,
26
+ musicStyle: this.musicStyle,
27
+ };
28
+ }
29
+ get displayName() {
30
+ return this.data.displayName;
31
+ }
32
+ get photoURL() {
33
+ return this.data.photoURL;
34
+ }
35
+ get locality() {
36
+ return this.data.locality;
37
+ }
38
+ get location() {
39
+ return this.data.location;
40
+ }
41
+ get username() {
42
+ return this.data.username;
43
+ }
44
+ get musicStyle() {
45
+ return this.data.musicStyle;
46
+ }
47
+ get musicStyleString() {
48
+ return lang_1.getTranslation(`musicStyles.${this.musicStyle}`, this.lang);
49
+ }
50
+ }
51
+ exports.default = GroupBasic;
@@ -0,0 +1,43 @@
1
+ import { DocumentReference, DocumentSnapshot } from '@google-cloud/firestore';
2
+ import { LanguagesTypes } from '../../lang';
3
+ import GroupBasic from './basic';
4
+ import { GroupData, SocialNetwork } from './types';
5
+ export default class Group extends GroupBasic<GroupData> {
6
+ constructor(doc: DocumentSnapshot, lang?: LanguagesTypes);
7
+ get owner(): DocumentReference;
8
+ get playerIds(): string[];
9
+ get players(): Record<string, import("../Player/types").PlayerBasicData>;
10
+ get playersCount(): number;
11
+ get description(): string | null;
12
+ get addresses(): import("./types").GroupAddressData[];
13
+ get addressDefault(): import("./types").GroupAddressData | undefined;
14
+ get activeInvitationLink(): boolean;
15
+ get invitationLink(): string | null;
16
+ get shortDynamicLink(): string | null;
17
+ get admins(): string[];
18
+ get createdAt(): FirebaseFirestore.Timestamp;
19
+ get deletedAt(): FirebaseFirestore.Timestamp | null;
20
+ get activePlayers(): string[];
21
+ get playersList(): (import("../Player/types").PlayerBasicData & {
22
+ id: string;
23
+ })[];
24
+ get isActive(): boolean;
25
+ get isDeleted(): boolean;
26
+ get intercomId(): string | null;
27
+ get partnershipId(): string | null;
28
+ get socialNetworks(): Record<SocialNetwork, string | null>;
29
+ getSocialNetworkUrl(id: SocialNetwork): string | null;
30
+ get config(): Record<import("./types").GroupConfig, boolean>;
31
+ get templates(): Record<string, import("./types").GroupTemplateData>;
32
+ get status(): import("./types").GroupStatus;
33
+ get templatesList(): (import("./types").GroupTemplateData & {
34
+ id: string;
35
+ })[];
36
+ get satisfactionIndex(): {
37
+ current: number;
38
+ last: number;
39
+ };
40
+ getPlayer: (userId: string) => import("../Player/types").PlayerBasicData | null;
41
+ isAdmin: (userId: string) => boolean;
42
+ isPlayer: (userId: string) => boolean;
43
+ }
@@ -0,0 +1,115 @@
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 lodash_1 = require("lodash");
7
+ const orders_1 = require("../../helpers/musicStyles/orders");
8
+ const lang_1 = require("../../lang");
9
+ const basic_1 = __importDefault(require("./basic"));
10
+ const types_1 = require("./types");
11
+ class Group extends basic_1.default {
12
+ constructor(doc, lang = lang_1.defaultLocale) {
13
+ super(doc, lang);
14
+ this.getPlayer = (userId) => {
15
+ return userId in this.players ? this.players[userId] : null;
16
+ };
17
+ this.isAdmin = (userId) => {
18
+ return this.admins.includes(userId);
19
+ };
20
+ this.isPlayer = (userId) => {
21
+ return this.playerIds.includes(userId);
22
+ };
23
+ }
24
+ get owner() {
25
+ return this.data.owner;
26
+ }
27
+ get playerIds() {
28
+ return this.data.playerIds || [];
29
+ }
30
+ get players() {
31
+ return this.data.players || {};
32
+ }
33
+ get playersCount() {
34
+ return this.playerIds.length;
35
+ }
36
+ get description() {
37
+ return this.data.description || null;
38
+ }
39
+ get addresses() {
40
+ return this.data.addresses || [];
41
+ }
42
+ get addressDefault() {
43
+ return this.addresses.find((a) => a.default === true);
44
+ }
45
+ get activeInvitationLink() {
46
+ return this.data.activeInvitationLink || false;
47
+ }
48
+ get invitationLink() {
49
+ return this.data.invitationLink;
50
+ }
51
+ get shortDynamicLink() {
52
+ return this.data.shortDynamicLink;
53
+ }
54
+ get admins() {
55
+ return this.data.administrators || [];
56
+ }
57
+ get createdAt() {
58
+ return this.data.createdAt;
59
+ }
60
+ get deletedAt() {
61
+ return this.data.deletedAt || null;
62
+ }
63
+ get activePlayers() {
64
+ return Object.keys(this.players);
65
+ }
66
+ get playersList() {
67
+ const players = this.activePlayers.map((playerId) => Object.assign({}, this.players[playerId], { id: playerId }));
68
+ return orders_1.orderByMusicStyle(players, 'mainInstrument', this.musicStyle);
69
+ }
70
+ get isActive() {
71
+ return this.exists && !this.deletedAt;
72
+ }
73
+ get isDeleted() {
74
+ return !this.exists || !lodash_1.isNull(this.deletedAt);
75
+ }
76
+ get intercomId() {
77
+ return this.data.intercom_id || null;
78
+ }
79
+ get partnershipId() {
80
+ return this.data.partnershipId || null;
81
+ }
82
+ get socialNetworks() {
83
+ if (this.data.socialNetworks) {
84
+ return this.data.socialNetworks;
85
+ }
86
+ return {
87
+ [types_1.SocialNetwork.Facebook]: null,
88
+ [types_1.SocialNetwork.Twitter]: null,
89
+ [types_1.SocialNetwork.Instagram]: null,
90
+ [types_1.SocialNetwork.YouTube]: null,
91
+ };
92
+ }
93
+ getSocialNetworkUrl(id) {
94
+ if (id in this.socialNetworks) {
95
+ return this.socialNetworks[id];
96
+ }
97
+ return null;
98
+ }
99
+ get config() {
100
+ return this.data.config || {};
101
+ }
102
+ get templates() {
103
+ return this.data.templates || {};
104
+ }
105
+ get status() {
106
+ return this.data.status;
107
+ }
108
+ get templatesList() {
109
+ return Object.keys(this.templates).map((templateId) => Object.assign({}, this.templates[templateId], { id: templateId }));
110
+ }
111
+ get satisfactionIndex() {
112
+ return this.data.satisfactionIndex || { current: 0, last: 0 };
113
+ }
114
+ }
115
+ exports.default = Group;
@@ -0,0 +1,68 @@
1
+ import { DocumentReference, GeoPoint, Timestamp } from '@google-cloud/firestore';
2
+ import { MusicStyleId } from '../../helpers/musicStyles';
3
+ import { PlayerBasicData } from '../Player/types';
4
+ export declare enum GroupConfig {
5
+ IncludesMembersToEventsWhenJoined = "includesMembersToEventsWhenJoined"
6
+ }
7
+ export declare enum GroupStatus {
8
+ Premium = "premium",
9
+ Trial = "trial",
10
+ Inactive = "inactive",
11
+ Deleted = "deleted"
12
+ }
13
+ export declare enum SocialNetwork {
14
+ Facebook = "facebook",
15
+ Twitter = "twitter",
16
+ Instagram = "instagram",
17
+ YouTube = "youtube"
18
+ }
19
+ export interface GroupAddressData {
20
+ address: string;
21
+ location: GeoPoint | null;
22
+ default: boolean;
23
+ }
24
+ export interface GroupTemplateData {
25
+ title: string;
26
+ playerIds: string[];
27
+ createdAt: Timestamp;
28
+ owner: string;
29
+ }
30
+ export interface AGroupTemplateData extends GroupTemplateData {
31
+ id: string;
32
+ }
33
+ export interface AGroupBasicData extends GroupBasicData {
34
+ id: string;
35
+ }
36
+ export interface GroupTinyData {
37
+ displayName: string;
38
+ photoURL: string;
39
+ }
40
+ export interface GroupBasicData extends GroupTinyData {
41
+ username: string;
42
+ musicStyle: MusicStyleId;
43
+ locality: string;
44
+ location: GeoPoint;
45
+ }
46
+ export interface GroupData extends GroupBasicData {
47
+ owner: DocumentReference;
48
+ playerIds: string[];
49
+ players: Record<string, PlayerBasicData>;
50
+ templates: Record<string, GroupTemplateData>;
51
+ administrators: string[];
52
+ addresses: GroupAddressData[];
53
+ activeInvitationLink: boolean;
54
+ invitationLink: string | null;
55
+ shortDynamicLink: string | null;
56
+ intercom_id: string | null;
57
+ description: string | null;
58
+ createdAt: Timestamp;
59
+ deletedAt: Timestamp | null;
60
+ socialNetworks?: Record<SocialNetwork, string | null>;
61
+ config: Record<GroupConfig, boolean>;
62
+ satisfactionIndex: {
63
+ current: number;
64
+ last: number;
65
+ };
66
+ status: GroupStatus;
67
+ partnershipId: string | null;
68
+ }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SocialNetwork = exports.GroupStatus = exports.GroupConfig = void 0;
4
+ var GroupConfig;
5
+ (function (GroupConfig) {
6
+ GroupConfig["IncludesMembersToEventsWhenJoined"] = "includesMembersToEventsWhenJoined";
7
+ })(GroupConfig = exports.GroupConfig || (exports.GroupConfig = {}));
8
+ var GroupStatus;
9
+ (function (GroupStatus) {
10
+ GroupStatus["Premium"] = "premium";
11
+ GroupStatus["Trial"] = "trial";
12
+ GroupStatus["Inactive"] = "inactive";
13
+ GroupStatus["Deleted"] = "deleted";
14
+ })(GroupStatus = exports.GroupStatus || (exports.GroupStatus = {}));
15
+ var SocialNetwork;
16
+ (function (SocialNetwork) {
17
+ SocialNetwork["Facebook"] = "facebook";
18
+ SocialNetwork["Twitter"] = "twitter";
19
+ SocialNetwork["Instagram"] = "instagram";
20
+ SocialNetwork["YouTube"] = "youtube";
21
+ })(SocialNetwork = exports.SocialNetwork || (exports.SocialNetwork = {}));
@@ -0,0 +1,9 @@
1
+ import { InstrumentId } from '../../helpers/instruments';
2
+ import { LanguagesTypes } from '../../lang';
3
+ export default class Instrument {
4
+ id: InstrumentId;
5
+ private lang;
6
+ constructor(id: InstrumentId, lang?: LanguagesTypes);
7
+ get name(): string;
8
+ get icon(): string;
9
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const instruments_1 = require("../../helpers/instruments");
4
+ const lang_1 = require("../../lang");
5
+ class Instrument {
6
+ constructor(id, lang = lang_1.defaultLocale) {
7
+ this.id = id;
8
+ this.lang = lang;
9
+ }
10
+ get name() {
11
+ return lang_1.getTranslation(`instruments.${this.id}`, this.lang);
12
+ }
13
+ get icon() {
14
+ return instruments_1.InstrumentIcons[this.id] || 'warning';
15
+ }
16
+ }
17
+ exports.default = Instrument;
@@ -0,0 +1,17 @@
1
+ import * as firestore from '@google-cloud/firestore';
2
+ import Model from '../Model';
3
+ import { AllowCollections, EntityTypes, MetricsData } from './types';
4
+ export default class Metrics extends Model<MetricsData> {
5
+ private defaultEntity;
6
+ constructor(doc: firestore.DocumentSnapshot);
7
+ getEntity: (entity: AllowCollections) => EntityTypes;
8
+ get users(): EntityTypes;
9
+ get groups(): EntityTypes;
10
+ get events(): EntityTypes;
11
+ get communications(): EntityTypes;
12
+ get repertory(): EntityTypes;
13
+ get partnerships(): EntityTypes;
14
+ get partners(): EntityTypes;
15
+ get date(): firestore.Timestamp;
16
+ get createdAt(): firestore.Timestamp;
17
+ }
@@ -0,0 +1,47 @@
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 Model_1 = __importDefault(require("../Model"));
7
+ class Metrics extends Model_1.default {
8
+ constructor(doc) {
9
+ super(doc);
10
+ this.defaultEntity = {
11
+ acc: 0,
12
+ count: 0,
13
+ total: 0,
14
+ };
15
+ this.getEntity = (entity) => {
16
+ return this.data[entity] || this.defaultEntity;
17
+ };
18
+ }
19
+ get users() {
20
+ return this.data.user || this.defaultEntity;
21
+ }
22
+ get groups() {
23
+ return this.data.group || this.defaultEntity;
24
+ }
25
+ get events() {
26
+ return this.data.event || this.defaultEntity;
27
+ }
28
+ get communications() {
29
+ return this.data.communication || this.defaultEntity;
30
+ }
31
+ get repertory() {
32
+ return this.data.repertory || this.defaultEntity;
33
+ }
34
+ get partnerships() {
35
+ return this.data.partnership || this.defaultEntity;
36
+ }
37
+ get partners() {
38
+ return this.data.partner || this.defaultEntity;
39
+ }
40
+ get date() {
41
+ return this.data.date;
42
+ }
43
+ get createdAt() {
44
+ return this.data.createdAt;
45
+ }
46
+ }
47
+ exports.default = Metrics;
@@ -0,0 +1,12 @@
1
+ import { Timestamp } from '@google-cloud/firestore';
2
+ import { CollectionNames } from '../../helpers/collections';
3
+ export declare type AllowCollections = CollectionNames.User | CollectionNames.Group | CollectionNames.Event | CollectionNames.Communication | CollectionNames.GroupRepertory | CollectionNames.Partner | CollectionNames.Partnership;
4
+ export interface EntityTypes {
5
+ total: number;
6
+ acc: number;
7
+ count: number;
8
+ }
9
+ export interface MetricsData extends Record<AllowCollections, EntityTypes> {
10
+ date: Timestamp;
11
+ createdAt: Timestamp;
12
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,10 @@
1
+ import * as firestore from '@google-cloud/firestore';
2
+ export default class Model<D> {
3
+ id: string;
4
+ ref: firestore.DocumentReference;
5
+ exists: boolean;
6
+ private _data;
7
+ constructor(doc: firestore.DocumentSnapshot);
8
+ get data(): D;
9
+ protected get(name: string): any;
10
+ }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class Model {
4
+ constructor(doc) {
5
+ this.id = doc.id;
6
+ this._data = doc.data();
7
+ this.ref = doc.ref;
8
+ this.exists = doc.exists;
9
+ }
10
+ get data() {
11
+ return this._data;
12
+ }
13
+ get(name) {
14
+ if (!this._data || !this._data[name]) {
15
+ return null;
16
+ }
17
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
18
+ return this._data[name];
19
+ }
20
+ }
21
+ exports.default = Model;
@@ -0,0 +1,8 @@
1
+ import { MusicStyleId } from '../../helpers/musicStyles';
2
+ import { LanguagesTypes } from '../../lang';
3
+ export default class MusicStyle {
4
+ id: MusicStyleId;
5
+ private lang;
6
+ constructor(id: MusicStyleId, lang?: LanguagesTypes);
7
+ get name(): string;
8
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const lang_1 = require("../../lang");
4
+ class MusicStyle {
5
+ constructor(id, lang = lang_1.defaultLocale) {
6
+ this.id = id;
7
+ this.lang = lang;
8
+ }
9
+ get name() {
10
+ return lang_1.getTranslation(`musicStyles.${this.id}`, this.lang);
11
+ }
12
+ }
13
+ exports.default = MusicStyle;