@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.
- package/functions/communication.d.ts +31 -0
- package/functions/communication.js +2 -0
- package/functions/event.d.ts +113 -0
- package/functions/event.js +18 -0
- package/functions/eventPlayer.d.ts +20 -0
- package/functions/eventPlayer.js +13 -0
- package/functions/eventRepertory.d.ts +9 -0
- package/functions/eventRepertory.js +2 -0
- package/functions/federation.d.ts +23 -0
- package/functions/federation.js +2 -0
- package/functions/federationPartnership.d.ts +34 -0
- package/functions/federationPartnership.js +2 -0
- package/functions/group.d.ts +32 -0
- package/functions/group.js +2 -0
- package/functions/groupPlayer.d.ts +37 -0
- package/functions/groupPlayer.js +2 -0
- package/functions/groupRepertory.d.ts +54 -0
- package/functions/groupRepertory.js +2 -0
- package/functions/index.d.ts +73 -0
- package/functions/index.js +77 -0
- package/functions/misc.d.ts +9 -0
- package/functions/misc.js +2 -0
- package/functions/notification.d.ts +4 -0
- package/functions/notification.js +2 -0
- package/functions/partner.d.ts +63 -0
- package/functions/partner.js +2 -0
- package/functions/partnership.d.ts +23 -0
- package/functions/partnership.js +2 -0
- package/functions/partnershipGroup.d.ts +12 -0
- package/functions/partnershipGroup.js +2 -0
- package/functions/partnershipPlan.d.ts +23 -0
- package/functions/partnershipPlan.js +2 -0
- package/functions/regions.d.ts +6 -0
- package/functions/regions.js +85 -0
- package/functions/subscription.d.ts +20 -0
- package/functions/subscription.js +2 -0
- package/functions/user.d.ts +19 -0
- package/functions/user.js +2 -0
- package/helpers/appScenes.d.ts +45 -0
- package/helpers/appScenes.js +49 -0
- package/helpers/badges.d.ts +21 -0
- package/helpers/badges.js +162 -0
- package/helpers/collections.d.ts +28 -0
- package/helpers/collections.js +32 -0
- package/helpers/instruments/index.d.ts +67 -0
- package/helpers/instruments/index.js +145 -0
- package/helpers/musicStyles/index.d.ts +9 -0
- package/helpers/musicStyles/index.js +16 -0
- package/helpers/musicStyles/orders.d.ts +4 -0
- package/helpers/musicStyles/orders.js +128 -0
- package/helpers/notifications.d.ts +40 -0
- package/helpers/notifications.js +120 -0
- package/helpers/payments.d.ts +2 -0
- package/helpers/payments.js +9 -0
- package/helpers/utils.d.ts +6 -0
- package/helpers/utils.js +99 -0
- package/index.d.ts +0 -0
- package/index.js +1 -0
- package/lang/ca.json +194 -0
- package/lang/de.json +194 -0
- package/lang/en.json +194 -0
- package/lang/es.json +194 -0
- package/lang/gl.json +194 -0
- package/lang/index.d.ts +1078 -0
- package/lang/index.js +101 -0
- package/models/Communication/index.d.ts +47 -0
- package/models/Communication/index.js +138 -0
- package/models/Communication/types.d.ts +53 -0
- package/models/Communication/types.js +13 -0
- package/models/Counters/index.d.ts +7 -0
- package/models/Counters/index.js +15 -0
- package/models/Counters/types.d.ts +3 -0
- package/models/Counters/types.js +2 -0
- package/models/Evento/Player/index.d.ts +17 -0
- package/models/Evento/Player/index.js +45 -0
- package/models/Evento/Player/types.d.ts +15 -0
- package/models/Evento/Player/types.js +8 -0
- package/models/Evento/Repertory/index.d.ts +9 -0
- package/models/Evento/Repertory/index.js +22 -0
- package/models/Evento/Repertory/types.d.ts +5 -0
- package/models/Evento/Repertory/types.js +2 -0
- package/models/Evento/basic.d.ts +22 -0
- package/models/Evento/basic.js +72 -0
- package/models/Evento/index.d.ts +66 -0
- package/models/Evento/index.js +178 -0
- package/models/Evento/promoter.d.ts +11 -0
- package/models/Evento/promoter.js +24 -0
- package/models/Evento/tiny.d.ts +13 -0
- package/models/Evento/tiny.js +32 -0
- package/models/Evento/types.d.ts +76 -0
- package/models/Evento/types.js +22 -0
- package/models/Federation/Partnership/index.d.ts +12 -0
- package/models/Federation/Partnership/index.js +31 -0
- package/models/Federation/Partnership/types.d.ts +8 -0
- package/models/Federation/Partnership/types.js +2 -0
- package/models/Federation/index.d.ts +20 -0
- package/models/Federation/index.js +54 -0
- package/models/Federation/types.d.ts +16 -0
- package/models/Federation/types.js +2 -0
- package/models/Group/Analytics/index.d.ts +11 -0
- package/models/Group/Analytics/index.js +29 -0
- package/models/Group/Analytics/types.d.ts +20 -0
- package/models/Group/Analytics/types.js +13 -0
- package/models/Group/Event/index.d.ts +15 -0
- package/models/Group/Event/index.js +38 -0
- package/models/Group/Event/types.d.ts +11 -0
- package/models/Group/Event/types.js +2 -0
- package/models/Group/Player/Event/index.d.ts +17 -0
- package/models/Group/Player/Event/index.js +42 -0
- package/models/Group/Player/Event/types.d.ts +8 -0
- package/models/Group/Player/Event/types.js +2 -0
- package/models/Group/Player/Log/index.d.ts +12 -0
- package/models/Group/Player/Log/index.js +24 -0
- package/models/Group/Player/Log/types.d.ts +11 -0
- package/models/Group/Player/Log/types.js +2 -0
- package/models/Group/Player/index.d.ts +55 -0
- package/models/Group/Player/index.js +221 -0
- package/models/Group/Player/types.d.ts +43 -0
- package/models/Group/Player/types.js +9 -0
- package/models/Group/Repertory/index.d.ts +67 -0
- package/models/Group/Repertory/index.js +149 -0
- package/models/Group/Repertory/types.d.ts +43 -0
- package/models/Group/Repertory/types.js +2 -0
- package/models/Group/basic.d.ts +17 -0
- package/models/Group/basic.js +51 -0
- package/models/Group/index.d.ts +43 -0
- package/models/Group/index.js +115 -0
- package/models/Group/types.d.ts +68 -0
- package/models/Group/types.js +21 -0
- package/models/Instrument/index.d.ts +9 -0
- package/models/Instrument/index.js +17 -0
- package/models/Metrics/index.d.ts +17 -0
- package/models/Metrics/index.js +47 -0
- package/models/Metrics/types.d.ts +12 -0
- package/models/Metrics/types.js +2 -0
- package/models/Model.d.ts +10 -0
- package/models/Model.js +21 -0
- package/models/MusicStyle/index.d.ts +8 -0
- package/models/MusicStyle/index.js +13 -0
- package/models/Notification/index.d.ts +12 -0
- package/models/Notification/index.js +26 -0
- package/models/Notification/types.d.ts +71 -0
- package/models/Notification/types.js +68 -0
- package/models/Partner/basic.d.ts +14 -0
- package/models/Partner/basic.js +43 -0
- package/models/Partner/index.d.ts +16 -0
- package/models/Partner/index.js +48 -0
- package/models/Partner/tiny.d.ts +9 -0
- package/models/Partner/tiny.js +24 -0
- package/models/Partner/types.d.ts +43 -0
- package/models/Partner/types.js +9 -0
- package/models/Partnership/Group/index.d.ts +8 -0
- package/models/Partnership/Group/index.js +17 -0
- package/models/Partnership/Group/types.d.ts +2 -0
- package/models/Partnership/Group/types.js +2 -0
- package/models/Partnership/Partner/Subscription/index.d.ts +19 -0
- package/models/Partnership/Partner/Subscription/index.js +56 -0
- package/models/Partnership/Partner/Subscription/types.d.ts +21 -0
- package/models/Partnership/Partner/Subscription/types.js +9 -0
- package/models/Partnership/Partner/index.d.ts +9 -0
- package/models/Partnership/Partner/index.js +22 -0
- package/models/Partnership/Partner/types.d.ts +5 -0
- package/models/Partnership/Partner/types.js +2 -0
- package/models/Partnership/Payment/index.d.ts +8 -0
- package/models/Partnership/Payment/index.js +18 -0
- package/models/Partnership/Payment/types.d.ts +6 -0
- package/models/Partnership/Payment/types.js +2 -0
- package/models/Partnership/Plan/basic.d.ts +19 -0
- package/models/Partnership/Plan/basic.js +65 -0
- package/models/Partnership/Plan/index.d.ts +12 -0
- package/models/Partnership/Plan/index.js +31 -0
- package/models/Partnership/Plan/types.d.ts +23 -0
- package/models/Partnership/Plan/types.js +10 -0
- package/models/Partnership/basic.d.ts +17 -0
- package/models/Partnership/basic.js +58 -0
- package/models/Partnership/index.d.ts +18 -0
- package/models/Partnership/index.js +55 -0
- package/models/Partnership/types.d.ts +37 -0
- package/models/Partnership/types.js +9 -0
- package/models/Payment/basic.d.ts +17 -0
- package/models/Payment/basic.js +53 -0
- package/models/Payment/index.d.ts +13 -0
- package/models/Payment/index.js +33 -0
- package/models/Payment/types.d.ts +32 -0
- package/models/Payment/types.js +17 -0
- package/models/Player/basic.d.ts +10 -0
- package/models/Player/basic.js +27 -0
- package/models/Player/types.d.ts +8 -0
- package/models/Player/types.js +2 -0
- package/models/Repertory/basic.d.ts +11 -0
- package/models/Repertory/basic.js +32 -0
- package/models/Repertory/types.d.ts +21 -0
- package/models/Repertory/types.js +2 -0
- package/models/User/Group/index.d.ts +15 -0
- package/models/User/Group/index.js +36 -0
- package/models/User/Group/types.d.ts +10 -0
- package/models/User/Group/types.js +2 -0
- package/models/User/Notification/index.d.ts +25 -0
- package/models/User/Notification/index.js +73 -0
- package/models/User/Notification/types.d.ts +25 -0
- package/models/User/Notification/types.js +2 -0
- package/models/User/basic.d.ts +13 -0
- package/models/User/basic.js +35 -0
- package/models/User/index.d.ts +46 -0
- package/models/User/index.js +119 -0
- package/models/User/types.d.ts +68 -0
- package/models/User/types.js +26 -0
- package/package.json +39 -0
|
@@ -0,0 +1,36 @@
|
|
|
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 get_1 = __importDefault(require("lodash/get"));
|
|
7
|
+
const lang_1 = require("../../../lang");
|
|
8
|
+
const basic_1 = __importDefault(require("../../Group/basic"));
|
|
9
|
+
const types_1 = require("../../Group/Player/types");
|
|
10
|
+
class UserGroup extends basic_1.default {
|
|
11
|
+
constructor(doc, lang = lang_1.defaultLocale) {
|
|
12
|
+
super(doc, lang);
|
|
13
|
+
}
|
|
14
|
+
get groupId() {
|
|
15
|
+
return get_1.default(this.ref, 'parent.parent.id');
|
|
16
|
+
}
|
|
17
|
+
get mainInstrument() {
|
|
18
|
+
return this.data.mainInstrument;
|
|
19
|
+
}
|
|
20
|
+
get instrument() {
|
|
21
|
+
return lang_1.getTranslation(`instruments.${this.mainInstrument}`, this.lang);
|
|
22
|
+
}
|
|
23
|
+
get instruments() {
|
|
24
|
+
return this.data.instruments || [];
|
|
25
|
+
}
|
|
26
|
+
get role() {
|
|
27
|
+
return this.data.role;
|
|
28
|
+
}
|
|
29
|
+
get isAdmin() {
|
|
30
|
+
return this.data.role === types_1.GroupPlayerRole.Admin;
|
|
31
|
+
}
|
|
32
|
+
get joinedAt() {
|
|
33
|
+
return this.data.joinedAt;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.default = UserGroup;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Timestamp } from '@google-cloud/firestore';
|
|
2
|
+
import { InstrumentId } from '../../../helpers/instruments';
|
|
3
|
+
import { GroupPlayerRole } from '../../Group/Player/types';
|
|
4
|
+
import { GroupBasicData } from '../../Group/types';
|
|
5
|
+
export interface UserGroupData extends GroupBasicData {
|
|
6
|
+
mainInstrument: InstrumentId;
|
|
7
|
+
instruments: InstrumentId[];
|
|
8
|
+
role: GroupPlayerRole;
|
|
9
|
+
joinedAt: Timestamp;
|
|
10
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as firestore from '@google-cloud/firestore';
|
|
2
|
+
import { LanguagesTypes } from '../../../lang';
|
|
3
|
+
import Model from '../../Model';
|
|
4
|
+
import { UserNotificationData } from './types';
|
|
5
|
+
export default class Notification extends Model<UserNotificationData> {
|
|
6
|
+
private lang;
|
|
7
|
+
constructor(doc: firestore.DocumentSnapshot, lang?: LanguagesTypes);
|
|
8
|
+
private getTranslationByAction;
|
|
9
|
+
protected get references(): firestore.DocumentReference<firestore.DocumentData>[];
|
|
10
|
+
get photoURL(): string;
|
|
11
|
+
get meta(): import("./types").MetaNotificationData;
|
|
12
|
+
get action(): import("../../Notification/types").NotificationActions;
|
|
13
|
+
get cleanPhotoURL(): string;
|
|
14
|
+
get isAvatar(): boolean;
|
|
15
|
+
get avatar(): import("../types").UserTinyData | null;
|
|
16
|
+
get title(): string;
|
|
17
|
+
get text(): string;
|
|
18
|
+
get scene(): string;
|
|
19
|
+
get propsScene(): Record<string, string>;
|
|
20
|
+
get url(): string;
|
|
21
|
+
get createdAt(): firestore.Timestamp;
|
|
22
|
+
get timestamp(): number;
|
|
23
|
+
get sendedAt(): firestore.Timestamp | null;
|
|
24
|
+
get readedAt(): firestore.Timestamp | null;
|
|
25
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
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 utils_1 = require("../../../helpers/utils");
|
|
8
|
+
const lang_1 = require("../../../lang");
|
|
9
|
+
const Model_1 = __importDefault(require("../../Model"));
|
|
10
|
+
class Notification extends Model_1.default {
|
|
11
|
+
constructor(doc, lang = lang_1.defaultLocale) {
|
|
12
|
+
super(doc);
|
|
13
|
+
this.getTranslationByAction = (key) => {
|
|
14
|
+
const translation = lang_1.getTranslation(`${this.action}.${key}`, this.lang);
|
|
15
|
+
return utils_1.replaceKeysNotification(translation, this.meta, this.lang);
|
|
16
|
+
};
|
|
17
|
+
this.lang = lang;
|
|
18
|
+
}
|
|
19
|
+
// Uso para consultas
|
|
20
|
+
get references() {
|
|
21
|
+
return this.data.references || [];
|
|
22
|
+
}
|
|
23
|
+
get photoURL() {
|
|
24
|
+
return this.data.photoURL;
|
|
25
|
+
}
|
|
26
|
+
get meta() {
|
|
27
|
+
return this.data.meta || {};
|
|
28
|
+
}
|
|
29
|
+
get action() {
|
|
30
|
+
return this.data.action;
|
|
31
|
+
}
|
|
32
|
+
get cleanPhotoURL() {
|
|
33
|
+
return this.isAvatar ? utils_1.replaceVarsBrackets(this.photoURL, this.meta) : this.photoURL;
|
|
34
|
+
}
|
|
35
|
+
get isAvatar() {
|
|
36
|
+
return this.photoURL.slice(0, 1) === '[' && this.photoURL.slice(-1) === ']';
|
|
37
|
+
}
|
|
38
|
+
get avatar() {
|
|
39
|
+
if (!this.isAvatar) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
const params = this.photoURL.substr(1).slice(0, -1).split('.');
|
|
43
|
+
return lodash_1.get(this.meta, [params[0], params[1]]) || null;
|
|
44
|
+
}
|
|
45
|
+
get title() {
|
|
46
|
+
return this.getTranslationByAction('title');
|
|
47
|
+
}
|
|
48
|
+
get text() {
|
|
49
|
+
return this.getTranslationByAction('text');
|
|
50
|
+
}
|
|
51
|
+
get scene() {
|
|
52
|
+
return this.data.scene;
|
|
53
|
+
}
|
|
54
|
+
get propsScene() {
|
|
55
|
+
return this.data.propsScene || {};
|
|
56
|
+
}
|
|
57
|
+
get url() {
|
|
58
|
+
return this.data.url;
|
|
59
|
+
}
|
|
60
|
+
get createdAt() {
|
|
61
|
+
return this.data.createdAt;
|
|
62
|
+
}
|
|
63
|
+
get timestamp() {
|
|
64
|
+
return this.data.timestamp;
|
|
65
|
+
}
|
|
66
|
+
get sendedAt() {
|
|
67
|
+
return this.data.sendedAt;
|
|
68
|
+
}
|
|
69
|
+
get readedAt() {
|
|
70
|
+
return this.data.readedAt || null;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.default = Notification;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { DocumentReference, Timestamp } from '@google-cloud/firestore';
|
|
2
|
+
import { EventTinyData } from '../../Evento/types';
|
|
3
|
+
import { GroupTinyData } from '../../Group/types';
|
|
4
|
+
import { NotificationActions } from '../../Notification/types';
|
|
5
|
+
import { UserTinyData } from '../types';
|
|
6
|
+
export declare type EntityTinyData = UserTinyData | GroupTinyData;
|
|
7
|
+
export interface MetaNotificationData {
|
|
8
|
+
user?: Record<string, UserTinyData>;
|
|
9
|
+
group?: Record<string, GroupTinyData>;
|
|
10
|
+
event?: Record<string, EventTinyData>;
|
|
11
|
+
extra?: Record<string, unknown>;
|
|
12
|
+
}
|
|
13
|
+
export interface UserNotificationData {
|
|
14
|
+
readedAt: Timestamp | null;
|
|
15
|
+
sendedAt: Timestamp | null;
|
|
16
|
+
meta: MetaNotificationData;
|
|
17
|
+
readonly photoURL: string;
|
|
18
|
+
readonly scene: string;
|
|
19
|
+
readonly propsScene: Record<string, string>;
|
|
20
|
+
readonly url: string;
|
|
21
|
+
readonly references: DocumentReference[];
|
|
22
|
+
readonly createdAt: Timestamp;
|
|
23
|
+
readonly timestamp: number;
|
|
24
|
+
readonly action: NotificationActions;
|
|
25
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as firestore from '@google-cloud/firestore';
|
|
2
|
+
import { LanguagesTypes } from '../../lang';
|
|
3
|
+
import Model from '../Model';
|
|
4
|
+
import { UserBasicData, UserTinyData } from './types';
|
|
5
|
+
export default class UserBasic<D> extends Model<D & UserBasicData> {
|
|
6
|
+
protected lang: LanguagesTypes;
|
|
7
|
+
constructor(doc: firestore.DocumentSnapshot, lang: LanguagesTypes);
|
|
8
|
+
get tinyInfo(): UserTinyData;
|
|
9
|
+
get basicInfo(): UserBasicData;
|
|
10
|
+
get displayName(): string;
|
|
11
|
+
get username(): string;
|
|
12
|
+
get photoURL(): string;
|
|
13
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
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 UserBasic extends Model_1.default {
|
|
8
|
+
constructor(doc, lang) {
|
|
9
|
+
super(doc);
|
|
10
|
+
this.lang = lang;
|
|
11
|
+
}
|
|
12
|
+
get tinyInfo() {
|
|
13
|
+
return {
|
|
14
|
+
displayName: this.displayName,
|
|
15
|
+
photoURL: this.photoURL,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
get basicInfo() {
|
|
19
|
+
return {
|
|
20
|
+
displayName: this.displayName,
|
|
21
|
+
photoURL: this.photoURL,
|
|
22
|
+
username: this.username,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
get displayName() {
|
|
26
|
+
return this.data.displayName;
|
|
27
|
+
}
|
|
28
|
+
get username() {
|
|
29
|
+
return this.data.username;
|
|
30
|
+
}
|
|
31
|
+
get photoURL() {
|
|
32
|
+
return this.data.photoURL;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.default = UserBasic;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { DocumentSnapshot } from '@google-cloud/firestore';
|
|
2
|
+
import UserBasic from './basic';
|
|
3
|
+
import { UserAppConfig, UserData, UserRole } from './types';
|
|
4
|
+
export default class User extends UserBasic<UserData> {
|
|
5
|
+
constructor(doc: DocumentSnapshot);
|
|
6
|
+
get name(): string;
|
|
7
|
+
get lastName(): string;
|
|
8
|
+
get locality(): string | null;
|
|
9
|
+
get location(): FirebaseFirestore.GeoPoint | null;
|
|
10
|
+
get instruments(): string[];
|
|
11
|
+
get email(): string;
|
|
12
|
+
get hasRegistrationComplete(): boolean;
|
|
13
|
+
get role(): UserRole;
|
|
14
|
+
get isSuperAdmin(): boolean;
|
|
15
|
+
get description(): string | null;
|
|
16
|
+
get partnershipId(): string | null;
|
|
17
|
+
get federationId(): string | null;
|
|
18
|
+
get pushToken(): string | null;
|
|
19
|
+
get tokens(): string[];
|
|
20
|
+
get notificationBadge(): number;
|
|
21
|
+
get language(): import("../../lang").LanguagesTypes;
|
|
22
|
+
get createdAt(): FirebaseFirestore.Timestamp;
|
|
23
|
+
get intercomId(): string | null;
|
|
24
|
+
get adminGroups(): string[];
|
|
25
|
+
get isAdmin(): boolean;
|
|
26
|
+
get birthDate(): FirebaseFirestore.Timestamp | null;
|
|
27
|
+
private get devices();
|
|
28
|
+
get devicesList(): (import("./types").DeviceInfo & {
|
|
29
|
+
id: string;
|
|
30
|
+
})[];
|
|
31
|
+
get hasDevices(): boolean;
|
|
32
|
+
get device(): (import("./types").DeviceInfo & {
|
|
33
|
+
id: string;
|
|
34
|
+
}) | null;
|
|
35
|
+
get disabledNotifications(): Record<string, boolean>;
|
|
36
|
+
get activeDisabledNotifications(): string[];
|
|
37
|
+
get isActive(): boolean;
|
|
38
|
+
get deletedAt(): FirebaseFirestore.Timestamp | null;
|
|
39
|
+
get isDeleted(): boolean;
|
|
40
|
+
get appConfig(): {
|
|
41
|
+
default_group_id: string | null;
|
|
42
|
+
default_events_filter: import("./types").UserEventsFilter;
|
|
43
|
+
};
|
|
44
|
+
getAppConfig(value: UserAppConfig): string | import("./types").UserEventsFilter | null;
|
|
45
|
+
get registerVia(): import("./types").UserRegisterVia;
|
|
46
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
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 orderBy_1 = __importDefault(require("lodash/orderBy"));
|
|
8
|
+
const lang_1 = require("../../lang");
|
|
9
|
+
const basic_1 = __importDefault(require("./basic"));
|
|
10
|
+
const types_1 = require("./types");
|
|
11
|
+
class User extends basic_1.default {
|
|
12
|
+
constructor(doc) {
|
|
13
|
+
super(doc, doc.get('language') || lang_1.defaultLocale);
|
|
14
|
+
}
|
|
15
|
+
get name() {
|
|
16
|
+
return this.data.name;
|
|
17
|
+
}
|
|
18
|
+
get lastName() {
|
|
19
|
+
return this.data.lastname;
|
|
20
|
+
}
|
|
21
|
+
get locality() {
|
|
22
|
+
return this.data.locality;
|
|
23
|
+
}
|
|
24
|
+
get location() {
|
|
25
|
+
return this.data.location;
|
|
26
|
+
}
|
|
27
|
+
get instruments() {
|
|
28
|
+
return this.data.instruments || [];
|
|
29
|
+
}
|
|
30
|
+
get email() {
|
|
31
|
+
return this.data.email;
|
|
32
|
+
}
|
|
33
|
+
get hasRegistrationComplete() {
|
|
34
|
+
return lodash_1.isString(this.displayName) && lodash_1.isString(this.photoURL) && lodash_1.isString(this.email);
|
|
35
|
+
}
|
|
36
|
+
get role() {
|
|
37
|
+
return this.data.role;
|
|
38
|
+
}
|
|
39
|
+
get isSuperAdmin() {
|
|
40
|
+
return this.role === types_1.UserRole.SuperAdmin;
|
|
41
|
+
}
|
|
42
|
+
get description() {
|
|
43
|
+
return this.data.description || null;
|
|
44
|
+
}
|
|
45
|
+
get partnershipId() {
|
|
46
|
+
return this.data.partnershipId || null;
|
|
47
|
+
}
|
|
48
|
+
get federationId() {
|
|
49
|
+
return this.data.federationId || null;
|
|
50
|
+
}
|
|
51
|
+
get pushToken() {
|
|
52
|
+
return this.data.pushToken;
|
|
53
|
+
}
|
|
54
|
+
get tokens() {
|
|
55
|
+
return this.data.tokens || [];
|
|
56
|
+
}
|
|
57
|
+
get notificationBadge() {
|
|
58
|
+
return this.data.notifications || 0;
|
|
59
|
+
}
|
|
60
|
+
get language() {
|
|
61
|
+
return this.data.language || lang_1.defaultLocale;
|
|
62
|
+
}
|
|
63
|
+
get createdAt() {
|
|
64
|
+
return this.data.createdAt;
|
|
65
|
+
}
|
|
66
|
+
get intercomId() {
|
|
67
|
+
return this.data.intercom_id || null;
|
|
68
|
+
}
|
|
69
|
+
get adminGroups() {
|
|
70
|
+
return this.data.groups_admin || [];
|
|
71
|
+
}
|
|
72
|
+
get isAdmin() {
|
|
73
|
+
return this.adminGroups.length > 0;
|
|
74
|
+
}
|
|
75
|
+
get birthDate() {
|
|
76
|
+
return this.data.birthDate;
|
|
77
|
+
}
|
|
78
|
+
get devices() {
|
|
79
|
+
return this.data.devices || {};
|
|
80
|
+
}
|
|
81
|
+
get devicesList() {
|
|
82
|
+
const list = Object.keys(this.devices).map((id) => Object.assign(this.devices[id], { id }));
|
|
83
|
+
return orderBy_1.default(list, (device) => device.last_seen_at.toDate(), ['desc']);
|
|
84
|
+
}
|
|
85
|
+
get hasDevices() {
|
|
86
|
+
return this.devicesList.length > 0;
|
|
87
|
+
}
|
|
88
|
+
get device() {
|
|
89
|
+
if (this.hasDevices) {
|
|
90
|
+
return this.devicesList[0];
|
|
91
|
+
}
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
get disabledNotifications() {
|
|
95
|
+
return this.data.disabledNotifications || {};
|
|
96
|
+
}
|
|
97
|
+
get activeDisabledNotifications() {
|
|
98
|
+
return Object.keys(this.disabledNotifications).filter((key) => this.disabledNotifications[key] === true);
|
|
99
|
+
}
|
|
100
|
+
get isActive() {
|
|
101
|
+
return !this.isDeleted && this.hasRegistrationComplete;
|
|
102
|
+
}
|
|
103
|
+
get deletedAt() {
|
|
104
|
+
return this.data.deletedAt || null;
|
|
105
|
+
}
|
|
106
|
+
get isDeleted() {
|
|
107
|
+
return !this.exists || !lodash_1.isNull(this.deletedAt);
|
|
108
|
+
}
|
|
109
|
+
get appConfig() {
|
|
110
|
+
return this.data.appConfig || {};
|
|
111
|
+
}
|
|
112
|
+
getAppConfig(value) {
|
|
113
|
+
return this.data.appConfig[value];
|
|
114
|
+
}
|
|
115
|
+
get registerVia() {
|
|
116
|
+
return this.data.registerVia || null;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
exports.default = User;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { GeoPoint, Timestamp } from '@google-cloud/firestore';
|
|
2
|
+
import { LanguagesTypes } from '../../lang';
|
|
3
|
+
export declare enum UserRole {
|
|
4
|
+
SuperAdmin = "admin",
|
|
5
|
+
User = "user"
|
|
6
|
+
}
|
|
7
|
+
export declare enum UserRegisterVia {
|
|
8
|
+
Web = "web",
|
|
9
|
+
App = "app"
|
|
10
|
+
}
|
|
11
|
+
export declare enum UserAppConfig {
|
|
12
|
+
DefaultGroupId = "default_group_id",
|
|
13
|
+
DefaultEventsFilter = "default_events_filter"
|
|
14
|
+
}
|
|
15
|
+
export declare enum UserEventsFilter {
|
|
16
|
+
Month = 1,
|
|
17
|
+
Trimonth = 3,
|
|
18
|
+
SemiAnnual = 6,
|
|
19
|
+
Annual = 12,
|
|
20
|
+
Always = 1000
|
|
21
|
+
}
|
|
22
|
+
export interface DeviceInfo {
|
|
23
|
+
app_name: string | null;
|
|
24
|
+
app_version: string | null;
|
|
25
|
+
device: string | null;
|
|
26
|
+
os_name: string | null;
|
|
27
|
+
os_version: string | null;
|
|
28
|
+
is_tablet: boolean;
|
|
29
|
+
last_seen_at: Timestamp;
|
|
30
|
+
}
|
|
31
|
+
export interface UserTinyData {
|
|
32
|
+
displayName: string;
|
|
33
|
+
photoURL: string;
|
|
34
|
+
}
|
|
35
|
+
export interface UserBasicData extends UserTinyData {
|
|
36
|
+
username: string;
|
|
37
|
+
}
|
|
38
|
+
export interface UserData extends UserBasicData {
|
|
39
|
+
name: string;
|
|
40
|
+
lastname: string;
|
|
41
|
+
email: string;
|
|
42
|
+
instruments: string[];
|
|
43
|
+
role: UserRole;
|
|
44
|
+
language: LanguagesTypes;
|
|
45
|
+
intercom_id: string | null;
|
|
46
|
+
description: string | null;
|
|
47
|
+
createdAt: Timestamp;
|
|
48
|
+
locality: string | null;
|
|
49
|
+
location: GeoPoint | null;
|
|
50
|
+
notifications: number;
|
|
51
|
+
pushToken: string | null;
|
|
52
|
+
tokens: string[];
|
|
53
|
+
deletedAt: Timestamp | null;
|
|
54
|
+
partnershipId: string | null;
|
|
55
|
+
federationId: string | null;
|
|
56
|
+
groups_admin: string[];
|
|
57
|
+
birthDate: Timestamp | null;
|
|
58
|
+
devices: Record<string, DeviceInfo> | null;
|
|
59
|
+
disabledNotifications: Record<string, boolean> | null;
|
|
60
|
+
appConfig: {
|
|
61
|
+
[UserAppConfig.DefaultGroupId]: string | null;
|
|
62
|
+
[UserAppConfig.DefaultEventsFilter]: UserEventsFilter;
|
|
63
|
+
};
|
|
64
|
+
registerVia: UserRegisterVia;
|
|
65
|
+
}
|
|
66
|
+
export interface AUserBasicData extends UserBasicData {
|
|
67
|
+
id: string;
|
|
68
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UserEventsFilter = exports.UserAppConfig = exports.UserRegisterVia = exports.UserRole = void 0;
|
|
4
|
+
var UserRole;
|
|
5
|
+
(function (UserRole) {
|
|
6
|
+
UserRole["SuperAdmin"] = "admin";
|
|
7
|
+
UserRole["User"] = "user";
|
|
8
|
+
})(UserRole = exports.UserRole || (exports.UserRole = {}));
|
|
9
|
+
var UserRegisterVia;
|
|
10
|
+
(function (UserRegisterVia) {
|
|
11
|
+
UserRegisterVia["Web"] = "web";
|
|
12
|
+
UserRegisterVia["App"] = "app";
|
|
13
|
+
})(UserRegisterVia = exports.UserRegisterVia || (exports.UserRegisterVia = {}));
|
|
14
|
+
var UserAppConfig;
|
|
15
|
+
(function (UserAppConfig) {
|
|
16
|
+
UserAppConfig["DefaultGroupId"] = "default_group_id";
|
|
17
|
+
UserAppConfig["DefaultEventsFilter"] = "default_events_filter";
|
|
18
|
+
})(UserAppConfig = exports.UserAppConfig || (exports.UserAppConfig = {}));
|
|
19
|
+
var UserEventsFilter;
|
|
20
|
+
(function (UserEventsFilter) {
|
|
21
|
+
UserEventsFilter[UserEventsFilter["Month"] = 1] = "Month";
|
|
22
|
+
UserEventsFilter[UserEventsFilter["Trimonth"] = 3] = "Trimonth";
|
|
23
|
+
UserEventsFilter[UserEventsFilter["SemiAnnual"] = 6] = "SemiAnnual";
|
|
24
|
+
UserEventsFilter[UserEventsFilter["Annual"] = 12] = "Annual";
|
|
25
|
+
UserEventsFilter[UserEventsFilter["Always"] = 1000] = "Always";
|
|
26
|
+
})(UserEventsFilter = exports.UserEventsFilter || (exports.UserEventsFilter = {}));
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@glissandoo/lib",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Glissandoo library js",
|
|
5
|
+
"main": "./index.js",
|
|
6
|
+
"types": "./index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"build:watch": "tsc --watch",
|
|
10
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
11
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
12
|
+
"lint": "eslint --ext .ts ./src",
|
|
13
|
+
"prepare": "npm run build",
|
|
14
|
+
"preversion": "npm run lint",
|
|
15
|
+
"version": "npm run format && git add -A src",
|
|
16
|
+
"postversion": "git push && git push --tags",
|
|
17
|
+
"publish": "./publish.sh",
|
|
18
|
+
"publish:beta": "npm publish --tag beta"
|
|
19
|
+
},
|
|
20
|
+
"author": "Glissandoo",
|
|
21
|
+
"license": "ISC",
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@google-cloud/firestore": "^4.8.1",
|
|
24
|
+
"date-fns": "^2.20.3",
|
|
25
|
+
"date-fns-tz": "^1.1.3",
|
|
26
|
+
"lodash": "^4.17.21"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/lodash": "^4.14.168",
|
|
30
|
+
"@types/node": "^12.19.13",
|
|
31
|
+
"@types/slate": "^0.47.8",
|
|
32
|
+
"@typescript-eslint/eslint-plugin": "^4.22.0",
|
|
33
|
+
"@typescript-eslint/parser": "^4.22.0",
|
|
34
|
+
"eslint": "^7.24.0",
|
|
35
|
+
"eslint-config-prettier": "^8.2.0",
|
|
36
|
+
"prettier": "^2.2.1",
|
|
37
|
+
"typescript": "4.2.4"
|
|
38
|
+
}
|
|
39
|
+
}
|