@glissandoo/lib 1.55.4 → 1.57.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.
@@ -0,0 +1,11 @@
1
+ import * as firestore from '../types/firestore';
2
+ /** Create a DocumentSnapshot. */
3
+ export declare function makeDocumentSnapshot(
4
+ /** Key-value pairs representing data in the document, pass in `{}` to mock the snapshot of
5
+ * a document that doesn't exist.
6
+ */
7
+ data: {
8
+ [key: string]: unknown;
9
+ },
10
+ /** Full path of the reference (e.g. 'users/alovelace') */
11
+ refPath: string, project: string): firestore.DocumentSnapshot<firestore.DocumentData>;
@@ -0,0 +1,196 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.makeDocumentSnapshot = void 0;
27
+ const lodash_1 = require("lodash");
28
+ const firestore = __importStar(require("../types/firestore"));
29
+ const firebase = __importStar(require("firebase-admin"));
30
+ /** @internal */
31
+ function testApp() {
32
+ if (typeof testApp.singleton === 'undefined') {
33
+ testApp.init();
34
+ }
35
+ return testApp.singleton;
36
+ }
37
+ /** @internal */
38
+ (function (testApp) {
39
+ testApp.init = () => (testApp.singleton = new testApp.App());
40
+ class App {
41
+ constructor() {
42
+ return;
43
+ }
44
+ getApp() {
45
+ if (typeof this.appSingleton === 'undefined') {
46
+ const config = process.env.FIREBASE_CONFIG
47
+ ? JSON.parse(process.env.FIREBASE_CONFIG)
48
+ : {};
49
+ this.appSingleton = firebase.initializeApp(config,
50
+ // Give this app a name so it does not conflict with apps that user initialized.
51
+ 'firebase-functions-test');
52
+ }
53
+ return this.appSingleton;
54
+ }
55
+ deleteApp() {
56
+ if (this.appSingleton) {
57
+ void this.appSingleton.delete();
58
+ delete this.appSingleton;
59
+ }
60
+ }
61
+ }
62
+ testApp.App = App;
63
+ })(testApp || (testApp = {}));
64
+ /** @internal */
65
+ function objectToValueProto(data) {
66
+ const encodeHelper = (val) => {
67
+ if (typeof val === 'string') {
68
+ return {
69
+ stringValue: val,
70
+ };
71
+ }
72
+ if (typeof val === 'boolean') {
73
+ return {
74
+ booleanValue: val,
75
+ };
76
+ }
77
+ if (typeof val === 'number') {
78
+ if (val % 1 === 0) {
79
+ return {
80
+ integerValue: val,
81
+ };
82
+ }
83
+ return {
84
+ doubleValue: val,
85
+ };
86
+ }
87
+ if (val instanceof Date) {
88
+ return {
89
+ timestampValue: val.toISOString(),
90
+ };
91
+ }
92
+ if (val instanceof Array) {
93
+ const encodedElements = [];
94
+ for (const elem of val) {
95
+ const enc = encodeHelper(elem);
96
+ if (enc) {
97
+ encodedElements.push(enc);
98
+ }
99
+ }
100
+ return {
101
+ arrayValue: {
102
+ values: encodedElements,
103
+ },
104
+ };
105
+ }
106
+ if (val === null) {
107
+ // TODO: Look this up. This is a google.protobuf.NulLValue,
108
+ // and everything in google.protobuf has a customized JSON encoder.
109
+ // OTOH, Firestore's generated .d.ts files don't take this into
110
+ // account and have the default proto layout.
111
+ return {
112
+ nullValue: 'NULL_VALUE',
113
+ };
114
+ }
115
+ if (val instanceof Buffer || val instanceof Uint8Array) {
116
+ return {
117
+ bytesValue: val,
118
+ };
119
+ }
120
+ if (val instanceof firestore.DocumentReference) {
121
+ const projectId = (0, lodash_1.get)(val, '_referencePath.projectId');
122
+ const database = (0, lodash_1.get)(val, '_referencePath.databaseId');
123
+ const referenceValue = [
124
+ 'projects',
125
+ projectId,
126
+ 'databases',
127
+ database,
128
+ val.path,
129
+ ].join('/');
130
+ return { referenceValue };
131
+ }
132
+ if (val instanceof firestore.Timestamp) {
133
+ return {
134
+ timestampValue: val.toDate().toISOString(),
135
+ };
136
+ }
137
+ if (val instanceof firestore.GeoPoint) {
138
+ return {
139
+ geoPointValue: {
140
+ latitude: val.latitude,
141
+ longitude: val.longitude,
142
+ },
143
+ };
144
+ }
145
+ if ((0, lodash_1.isPlainObject)(val)) {
146
+ if (!val)
147
+ return;
148
+ return {
149
+ mapValue: {
150
+ fields: objectToValueProto(val),
151
+ },
152
+ };
153
+ }
154
+ throw new Error('Cannot encode to a Firestore Value');
155
+ };
156
+ return (0, lodash_1.mapValues)(data, encodeHelper);
157
+ }
158
+ function dateToTimestampProto(timeString) {
159
+ if (typeof timeString === 'undefined') {
160
+ return;
161
+ }
162
+ const date = new Date(timeString);
163
+ const seconds = Math.floor(date.getTime() / 1000);
164
+ let nanos = 0;
165
+ if (timeString.length > 20) {
166
+ const nanoString = timeString.substring(20, timeString.length - 1);
167
+ const trailingZeroes = 9 - nanoString.length;
168
+ nanos = parseInt(nanoString, 10) * Math.pow(10, trailingZeroes);
169
+ }
170
+ return { seconds, nanos };
171
+ }
172
+ /** Create a DocumentSnapshot. */
173
+ function makeDocumentSnapshot(
174
+ /** Key-value pairs representing data in the document, pass in `{}` to mock the snapshot of
175
+ * a document that doesn't exist.
176
+ */
177
+ data,
178
+ /** Full path of the reference (e.g. 'users/alovelace') */
179
+ refPath, project) {
180
+ const firestoreService = firebase.firestore(testApp().getApp());
181
+ const resource = `projects/${project}/databases/(default)/documents/${refPath}`;
182
+ const proto = (0, lodash_1.isEmpty)(data)
183
+ ? resource
184
+ : {
185
+ fields: objectToValueProto(data),
186
+ createTime: dateToTimestampProto(new Date().toISOString()),
187
+ updateTime: dateToTimestampProto(new Date().toISOString()),
188
+ name: resource,
189
+ };
190
+ const readTimeProto = dateToTimestampProto(new Date().toISOString());
191
+ /* eslint-disable */
192
+ // @ts-ignore
193
+ return firestoreService.snapshot_(proto, readTimeProto, 'json');
194
+ /* eslint-enable */
195
+ }
196
+ exports.makeDocumentSnapshot = makeDocumentSnapshot;
package/lang/ca.json CHANGED
@@ -130,6 +130,7 @@
130
130
  "instruments.ukelele": "Ukelele",
131
131
  "instruments.viola": "Viola",
132
132
  "instruments.violin": "Violí",
133
+ "instruments.unknown": "Instrument desconegut",
133
134
  "musicStyles.banda-cornetas-y-tambores": "Banda de cornetes i tambors",
134
135
  "musicStyles.banda-de-musica": "Banda de música",
135
136
  "musicStyles.batucada": "Batucada",
package/lang/de.json CHANGED
@@ -130,6 +130,7 @@
130
130
  "instruments.ukelele": "Ukulele",
131
131
  "instruments.viola": "Viola",
132
132
  "instruments.violin": "Violine",
133
+ "instruments.unknown": "Unbekanntes Instrument",
133
134
  "musicStyles.banda-cornetas-y-tambores": "Schlagzeug und Blasorchester",
134
135
  "musicStyles.banda-de-musica": "Blasorchester",
135
136
  "musicStyles.batucada": "Batukada",
package/lang/en.json CHANGED
@@ -130,6 +130,7 @@
130
130
  "instruments.ukelele": "Ukelele",
131
131
  "instruments.viola": "Viola",
132
132
  "instruments.violin": "Violin",
133
+ "instruments.unknown": "Unknown {musicType}",
133
134
  "musicStyles.banda-cornetas-y-tambores": "Drums and winds band",
134
135
  "musicStyles.banda-de-musica": "Concert band",
135
136
  "musicStyles.batucada": "Batucada",
package/lang/es.json CHANGED
@@ -130,6 +130,7 @@
130
130
  "instruments.ukelele": "Ukelele",
131
131
  "instruments.viola": "Viola",
132
132
  "instruments.violin": "Violín",
133
+ "instruments.unknown": "Instrumento desconocido",
133
134
  "musicStyles.banda-cornetas-y-tambores": "Banda de cornetas y tambores",
134
135
  "musicStyles.banda-de-musica": "Banda de música",
135
136
  "musicStyles.batucada": "Batucada",
package/lang/eu.json CHANGED
@@ -129,7 +129,8 @@
129
129
  "instruments.txistu": "Txistua",
130
130
  "instruments.ukelele": "Ukelelea",
131
131
  "instruments.viola": "Biola",
132
- "instruments.violin": "Biolina\n",
132
+ "instruments.violin": "Biolina",
133
+ "instruments.unknown": "Intrumentu ezezaguna",
133
134
  "musicStyles.banda-cornetas-y-tambores": "Danbor eta korneta banda",
134
135
  "musicStyles.banda-de-musica": "Musika banda",
135
136
  "musicStyles.batucada": "Batukada",
package/lang/gl.json CHANGED
@@ -130,6 +130,7 @@
130
130
  "instruments.ukelele": "Ukelele",
131
131
  "instruments.viola": "Viola",
132
132
  "instruments.violin": "Violín",
133
+ "instruments.unknown": "Instrumento descoñecido",
133
134
  "musicStyles.banda-cornetas-y-tambores": "Banda de cornetas e tambores",
134
135
  "musicStyles.banda-de-musica": "Banda de música",
135
136
  "musicStyles.batucada": "Batucada",
package/lang/pt.json CHANGED
@@ -130,6 +130,7 @@
130
130
  "instruments.ukelele": "Ukelele",
131
131
  "instruments.viola": "viola",
132
132
  "instruments.violin": "Violino",
133
+ "instruments.unknown": "Instrumento desconhecido",
133
134
  "musicStyles.banda-cornetas-y-tambores": "Banda de Sopros e Percussão",
134
135
  "musicStyles.banda-de-musica": "Banda",
135
136
  "musicStyles.batucada": "Batucada",
@@ -2,7 +2,7 @@ import { PlansGroup } from '../../helpers/plans';
2
2
  import { LanguagesTypes } from '../../lang';
3
3
  import { DocumentReference, DocumentSnapshot } from '../../types/firestore';
4
4
  import GroupBasic from './basic';
5
- import { GroupData, GroupStatus, SocialNetwork } from './types';
5
+ import { GroupConfigShowAttendanceToMembers, GroupData, 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;
@@ -41,7 +41,10 @@ export default class Group extends GroupBasic<GroupData> {
41
41
  get customerId(): string | null;
42
42
  get socialNetworks(): Record<SocialNetwork, string | null>;
43
43
  getSocialNetworkUrl(id: SocialNetwork): string | null;
44
- get config(): Record<import("./types").GroupConfig, boolean>;
44
+ get config(): {
45
+ includesMembersToEventsWhenJoined: boolean;
46
+ showAttendanceToMembers: GroupConfigShowAttendanceToMembers;
47
+ };
45
48
  get status(): GroupStatus;
46
49
  get planId(): PlansGroup;
47
50
  get templates(): Record<string, import("./types").GroupTemplateData>;
@@ -132,7 +132,14 @@ class Group extends basic_1.default {
132
132
  return null;
133
133
  }
134
134
  get config() {
135
- return this.data.config || {};
135
+ return {
136
+ [types_1.GroupConfigKey.IncludesMembersToEventsWhenJoined]: types_1.GroupConfigKey.IncludesMembersToEventsWhenJoined in this.data.config
137
+ ? this.data.config[types_1.GroupConfigKey.IncludesMembersToEventsWhenJoined]
138
+ : true,
139
+ [types_1.GroupConfigKey.ShowAttendanceToMembers]: types_1.GroupConfigKey.ShowAttendanceToMembers in this.data.config
140
+ ? this.data.config[types_1.GroupConfigKey.ShowAttendanceToMembers]
141
+ : types_1.GroupConfigShowAttendanceToMembers.None,
142
+ };
136
143
  }
137
144
  get status() {
138
145
  return this.data.status;
@@ -15,8 +15,15 @@ export declare enum GroupCreatedOn {
15
15
  App = "app",
16
16
  Dashboard = "dashboard"
17
17
  }
18
- export declare enum GroupConfig {
19
- IncludesMembersToEventsWhenJoined = "includesMembersToEventsWhenJoined"
18
+ export declare enum GroupConfigKey {
19
+ IncludesMembersToEventsWhenJoined = "includesMembersToEventsWhenJoined",
20
+ ShowAttendanceToMembers = "showAttendanceToMembers"
21
+ }
22
+ export declare enum GroupConfigShowAttendanceToMembers {
23
+ None = "none",
24
+ OnlyConfirmed = "onlyConfirmed",
25
+ OnlyToSection = "onlyToSection",
26
+ All = "all"
20
27
  }
21
28
  export declare enum GroupStatus {
22
29
  Premium = "premium",
@@ -84,6 +91,10 @@ export declare enum GroupRepertoireTagDefault {
84
91
  Fourth = "repertoireTags.4",
85
92
  Principal = "repertoireTags.principal"
86
93
  }
94
+ export interface GroupConfig {
95
+ [GroupConfigKey.IncludesMembersToEventsWhenJoined]: boolean;
96
+ [GroupConfigKey.ShowAttendanceToMembers]: GroupConfigShowAttendanceToMembers;
97
+ }
87
98
  export interface GroupRepertoireTag {
88
99
  title: string;
89
100
  default: boolean;
@@ -120,7 +131,7 @@ export interface GroupData extends GroupBasicData {
120
131
  description: string | null;
121
132
  deletedAt: Timestamp | null;
122
133
  socialNetworks?: Record<SocialNetwork, string | null>;
123
- config: Record<GroupConfig, boolean>;
134
+ config: GroupConfig;
124
135
  satisfactionIndex: {
125
136
  current: number;
126
137
  last: number;
@@ -1,16 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GroupRepertoireTagDefault = exports.GroupRepertoireTagReserved = exports.SocialNetwork = exports.GroupStatus = exports.GroupConfig = exports.GroupCreatedOn = void 0;
3
+ exports.GroupRepertoireTagDefault = exports.GroupRepertoireTagReserved = exports.SocialNetwork = exports.GroupStatus = exports.GroupConfigShowAttendanceToMembers = exports.GroupConfigKey = exports.GroupCreatedOn = void 0;
4
4
  var GroupCreatedOn;
5
5
  (function (GroupCreatedOn) {
6
6
  GroupCreatedOn["Web"] = "web";
7
7
  GroupCreatedOn["App"] = "app";
8
8
  GroupCreatedOn["Dashboard"] = "dashboard";
9
9
  })(GroupCreatedOn = exports.GroupCreatedOn || (exports.GroupCreatedOn = {}));
10
- var GroupConfig;
11
- (function (GroupConfig) {
12
- GroupConfig["IncludesMembersToEventsWhenJoined"] = "includesMembersToEventsWhenJoined";
13
- })(GroupConfig = exports.GroupConfig || (exports.GroupConfig = {}));
10
+ var GroupConfigKey;
11
+ (function (GroupConfigKey) {
12
+ GroupConfigKey["IncludesMembersToEventsWhenJoined"] = "includesMembersToEventsWhenJoined";
13
+ GroupConfigKey["ShowAttendanceToMembers"] = "showAttendanceToMembers";
14
+ })(GroupConfigKey = exports.GroupConfigKey || (exports.GroupConfigKey = {}));
15
+ var GroupConfigShowAttendanceToMembers;
16
+ (function (GroupConfigShowAttendanceToMembers) {
17
+ GroupConfigShowAttendanceToMembers["None"] = "none";
18
+ GroupConfigShowAttendanceToMembers["OnlyConfirmed"] = "onlyConfirmed";
19
+ GroupConfigShowAttendanceToMembers["OnlyToSection"] = "onlyToSection";
20
+ GroupConfigShowAttendanceToMembers["All"] = "all";
21
+ })(GroupConfigShowAttendanceToMembers = exports.GroupConfigShowAttendanceToMembers || (exports.GroupConfigShowAttendanceToMembers = {}));
14
22
  var GroupStatus;
15
23
  (function (GroupStatus) {
16
24
  GroupStatus["Premium"] = "premium";
@@ -17,9 +17,12 @@ class GroupInstrument extends _1.default {
17
17
  return GroupInstrument.isCustom(this.id);
18
18
  }
19
19
  get name() {
20
- return GroupInstrument.isCustom(this.id) && this.id in this.groupInstruments
21
- ? this.groupInstruments[this.id].name
22
- : super.name;
20
+ if (!GroupInstrument.isCustom(this.id))
21
+ return super.name;
22
+ if (this.id in this.groupInstruments) {
23
+ return this.groupInstruments[this.id].name;
24
+ }
25
+ return (0, lang_1.getTranslation)('instruments.unknown', this.lang) || this.id;
23
26
  }
24
27
  get icon() {
25
28
  return GroupInstrument.isCustom(this.id) && this.id in this.groupInstruments
@@ -2,7 +2,7 @@ import { InstrumentId } from '../../helpers/instruments';
2
2
  import { LanguagesTypes } from '../../lang';
3
3
  export default class Instrument {
4
4
  id: InstrumentId;
5
- private lang;
5
+ protected lang: LanguagesTypes;
6
6
  constructor(id: InstrumentId, lang?: LanguagesTypes);
7
7
  get name(): string;
8
8
  get icon(): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glissandoo/lib",
3
- "version": "1.55.4",
3
+ "version": "1.57.0",
4
4
  "description": "Glissandoo library js",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",