@glissandoo/lib 1.128.0 → 1.129.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.
@@ -1,6 +1,12 @@
1
1
  import { Descendant } from '../helpers/slate';
2
- import { CommunicationType } from '../models/Communication/types';
2
+ import { CommunicationFormat, CommunicationSurveyQuestion, CommunicationSurveyResults, CommunicationType } from '../models/Communication/types';
3
3
  export declare namespace CommunicationFbFunctionsTypes {
4
+ interface SurveyParams {
5
+ anonymous: boolean;
6
+ results: CommunicationSurveyResults;
7
+ closesAt: number | null;
8
+ questions: CommunicationSurveyQuestion[];
9
+ }
4
10
  interface PublishParams {
5
11
  commId: string;
6
12
  groupId: string;
@@ -10,6 +16,8 @@ export declare namespace CommunicationFbFunctionsTypes {
10
16
  recipients: string[];
11
17
  templateId: string | null;
12
18
  type: CommunicationType;
19
+ format?: CommunicationFormat;
20
+ survey?: SurveyParams | null;
13
21
  imagesPath: string[];
14
22
  attachmentsPath: string[];
15
23
  blockAnswers: boolean;
@@ -24,6 +32,8 @@ export declare namespace CommunicationFbFunctionsTypes {
24
32
  recipients: string[];
25
33
  templateId: string | null;
26
34
  type: CommunicationType;
35
+ format?: CommunicationFormat;
36
+ survey?: SurveyParams | null;
27
37
  imagesPath: string[];
28
38
  attachmentsPath: string[];
29
39
  blockAnswers: boolean;
@@ -34,4 +44,15 @@ export declare namespace CommunicationFbFunctionsTypes {
34
44
  groupId: string;
35
45
  }
36
46
  type RemoveResult = void;
47
+ interface SurveyRespondParams {
48
+ commId: string;
49
+ groupId: string;
50
+ answers: Record<string, string[]>;
51
+ }
52
+ type SurveyRespondResult = void;
53
+ interface SurveyCloseParams {
54
+ commId: string;
55
+ groupId: string;
56
+ }
57
+ type SurveyCloseResult = void;
37
58
  }
@@ -17,6 +17,8 @@ export declare enum FbFunctionName {
17
17
  CommunicationEdit = "communication-edit",
18
18
  CommunicationPublish = "communication-publish",
19
19
  CommunicationRemove = "communication-remove",
20
+ CommunicationSurveyClose = "communication-surveyClose",
21
+ CommunicationSurveyRespond = "communication-surveyRespond",
20
22
  CustomerAddConfirmedAdmin = "customer-addConfirmedAdmin",
21
23
  CustomerCreate = "customer-create",
22
24
  CustomerEdit = "customer-edit",
@@ -21,6 +21,8 @@ var FbFunctionName;
21
21
  FbFunctionName["CommunicationEdit"] = "communication-edit";
22
22
  FbFunctionName["CommunicationPublish"] = "communication-publish";
23
23
  FbFunctionName["CommunicationRemove"] = "communication-remove";
24
+ FbFunctionName["CommunicationSurveyClose"] = "communication-surveyClose";
25
+ FbFunctionName["CommunicationSurveyRespond"] = "communication-surveyRespond";
24
26
  FbFunctionName["CustomerAddConfirmedAdmin"] = "customer-addConfirmedAdmin";
25
27
  FbFunctionName["CustomerCreate"] = "customer-create";
26
28
  FbFunctionName["CustomerEdit"] = "customer-edit";
@@ -1,3 +1,7 @@
1
+ export declare enum ValidateUsernameReason {
2
+ InvalidFormat = "invalid-format",
3
+ AlreadyInUse = "already-in-use"
4
+ }
1
5
  export declare namespace MiscFbFunctionsTypes {
2
6
  interface ValidateUsernameParams {
3
7
  username: string;
@@ -5,6 +9,7 @@ export declare namespace MiscFbFunctionsTypes {
5
9
  interface ValidateUsernameResult {
6
10
  valid: boolean;
7
11
  message: string;
12
+ reason?: ValidateUsernameReason;
8
13
  }
9
14
  interface MiscAddSubscriberParams {
10
15
  email: string;
package/functions/misc.js CHANGED
@@ -1,2 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ValidateUsernameReason = void 0;
4
+ var ValidateUsernameReason;
5
+ (function (ValidateUsernameReason) {
6
+ ValidateUsernameReason["InvalidFormat"] = "invalid-format";
7
+ ValidateUsernameReason["AlreadyInUse"] = "already-in-use";
8
+ })(ValidateUsernameReason = exports.ValidateUsernameReason || (exports.ValidateUsernameReason = {}));
@@ -28,6 +28,8 @@ const regionByFunctions = {
28
28
  [index_1.FbFunctionName.CommunicationEdit]: GCloudRegions.UsCentral1,
29
29
  [index_1.FbFunctionName.CommunicationPublish]: GCloudRegions.UsCentral1,
30
30
  [index_1.FbFunctionName.CommunicationRemove]: GCloudRegions.UsCentral1,
31
+ [index_1.FbFunctionName.CommunicationSurveyClose]: GCloudRegions.UsCentral1,
32
+ [index_1.FbFunctionName.CommunicationSurveyRespond]: GCloudRegions.UsCentral1,
31
33
  [index_1.FbFunctionName.CustomerAddConfirmedAdmin]: GCloudRegions.EuropeWest6,
32
34
  [index_1.FbFunctionName.CustomerCreate]: GCloudRegions.EuropeWest6,
33
35
  [index_1.FbFunctionName.CustomerEdit]: GCloudRegions.EuropeWest6,
@@ -30,6 +30,8 @@ export declare enum HttpsErrorMessages {
30
30
  InvalidSuperAdmin = "error.superadmin.noValid",
31
31
  InvalidData = "error.data.noValid",
32
32
  InvalidCommunication = "error.communication.noValid",
33
+ InvalidSurveyLocked = "error.communication.surveyLocked",
34
+ InvalidServerCommunication = "error.communication.serverNotEditable",
33
35
  InvalidOffer = "error.offer.noValid",
34
36
  InvalidPartnership = "error.partnership.noValid",
35
37
  InvalidAdminPartnership = "error.partnership.noAdmin",
package/helpers/errors.js CHANGED
@@ -31,6 +31,8 @@ var HttpsErrorMessages;
31
31
  HttpsErrorMessages["InvalidSuperAdmin"] = "error.superadmin.noValid";
32
32
  HttpsErrorMessages["InvalidData"] = "error.data.noValid";
33
33
  HttpsErrorMessages["InvalidCommunication"] = "error.communication.noValid";
34
+ HttpsErrorMessages["InvalidSurveyLocked"] = "error.communication.surveyLocked";
35
+ HttpsErrorMessages["InvalidServerCommunication"] = "error.communication.serverNotEditable";
34
36
  HttpsErrorMessages["InvalidOffer"] = "error.offer.noValid";
35
37
  HttpsErrorMessages["InvalidPartnership"] = "error.partnership.noValid";
36
38
  HttpsErrorMessages["InvalidAdminPartnership"] = "error.partnership.noAdmin";
package/lang/ca.json CHANGED
@@ -24,6 +24,8 @@
24
24
  "calendarFeed.description.type": "Tipus",
25
25
  "communication.create.text": "{string:group.0.displayName} ha publicat alguna cosa nova. Dona-li una ullada!",
26
26
  "communication.create.title": "📝 Nova publicació",
27
+ "communication.createSurvey.text": "{string:group.0.displayName} ha creat una enquesta. Participa-hi!",
28
+ "communication.createSurvey.title": "📊 Nova enquesta",
27
29
  "communication.newComment.text": "{string:user.0.displayName} ha deixat un comentari en una publicació",
28
30
  "communication.newComment.title": "💬 Nou comentari",
29
31
  "event": "Esdeveniment",
@@ -472,5 +474,7 @@
472
474
  "theme.claim.new.text": "{string:user.0.displayName} ha sol·licitat la partitura de {instrument:extra.[instrumentId,customInstrumentName]} per a l'obra \"{string:extra.title}\".",
473
475
  "theme.claim.new.title": "📒 Han sol·licitat una partitura",
474
476
  "theme.claim.update.text": "Ja està disponible la partitura de {instrument:extra.[instrumentId,customInstrumentName]} per a l'obra \"{string:extra.title}\".",
475
- "theme.claim.update.title": "📥 Nova partitura de {instrument:extra.[instrumentId,customInstrumentName]}"
477
+ "theme.claim.update.title": "📥 Nova partitura de {instrument:extra.[instrumentId,customInstrumentName]}",
478
+ "communication.surveyClosingSoon.title": "⏰ L'enquesta es tanca aviat",
479
+ "communication.surveyClosingSoon.text": "L'enquesta de {string:group.0.displayName} es tanca en una hora. Vota abans que acabi!"
476
480
  }
package/lang/de.json CHANGED
@@ -24,6 +24,8 @@
24
24
  "calendarFeed.description.type": "Typ",
25
25
  "communication.create.text": "{string:group.0.displayName} hat etwas Neues veröffentlicht. Schau es dir an!",
26
26
  "communication.create.title": "📝 Neuer Beitrag",
27
+ "communication.createSurvey.text": "{string:group.0.displayName} hat eine Umfrage erstellt. Mach mit!",
28
+ "communication.createSurvey.title": "📊 Neue Umfrage",
27
29
  "communication.newComment.text": "{string:user.0.displayName} hat einen Kommentar zu einem Beitrag hinterlassen",
28
30
  "communication.newComment.title": "💬 Neuer Kommentar",
29
31
  "event": "Veranstaltung",
@@ -472,5 +474,7 @@
472
474
  "theme.claim.new.text": "{string:user.0.displayName} hat die Stimme für {instrument:extra.[instrumentId,customInstrumentName]} im Stück „{string:extra.title}“ angefragt.",
473
475
  "theme.claim.new.title": "📒 Stimme angefragt",
474
476
  "theme.claim.update.text": "Die Stimme für {instrument:extra.[instrumentId,customInstrumentName]} im Stück „{string:extra.title}“ ist jetzt verfügbar.",
475
- "theme.claim.update.title": "📥 Neue Stimme für {instrument:extra.[instrumentId,customInstrumentName]}"
477
+ "theme.claim.update.title": "📥 Neue Stimme für {instrument:extra.[instrumentId,customInstrumentName]}",
478
+ "communication.surveyClosingSoon.title": "⏰ Umfrage schließt bald",
479
+ "communication.surveyClosingSoon.text": "Die Umfrage von {string:group.0.displayName} schließt in einer Stunde. Stimme ab, bevor es zu spät ist!"
476
480
  }
package/lang/en.json CHANGED
@@ -24,6 +24,8 @@
24
24
  "calendarFeed.description.type": "Type",
25
25
  "communication.create.text": "{string:group.0.displayName} has posted something new. Check it out!",
26
26
  "communication.create.title": "📝 New post",
27
+ "communication.createSurvey.text": "{string:group.0.displayName} created a survey. Take part!",
28
+ "communication.createSurvey.title": "📊 New survey",
27
29
  "communication.newComment.text": "{string:user.0.displayName} left a comment on a post",
28
30
  "communication.newComment.title": "💬 New comment",
29
31
  "event": "Event",
@@ -472,5 +474,7 @@
472
474
  "theme.claim.new.text": "{string:user.0.displayName} has requested the sheet music for {instrument:extra.[instrumentId,customInstrumentName]} in the piece \"{string:extra.title}\".",
473
475
  "theme.claim.new.title": "📒 Sheet music requested",
474
476
  "theme.claim.update.text": "The sheet music for {instrument:extra.[instrumentId,customInstrumentName]} in the piece \"{string:extra.title}\" is now available.",
475
- "theme.claim.update.title": "📥 New sheet music for {instrument:extra.[instrumentId,customInstrumentName]}"
477
+ "theme.claim.update.title": "📥 New sheet music for {instrument:extra.[instrumentId,customInstrumentName]}",
478
+ "communication.surveyClosingSoon.title": "⏰ Survey closing soon",
479
+ "communication.surveyClosingSoon.text": "The survey from {string:group.0.displayName} closes in an hour. Vote before it's too late!"
476
480
  }
package/lang/es.json CHANGED
@@ -23,7 +23,9 @@
23
23
  "calendarFeed.description.open": "Abrir en Glissandoo",
24
24
  "calendarFeed.description.type": "Tipo",
25
25
  "communication.create.text": "{string:group.0.displayName} ha publicado algo nuevo. ¡Échale un vistazo!",
26
- "communication.create.title": "📝 Nuevo post",
26
+ "communication.create.title": "📝 Nueva publicación",
27
+ "communication.createSurvey.text": "{string:group.0.displayName} ha creado una encuesta. ¡Participa!",
28
+ "communication.createSurvey.title": "📊 Nueva encuesta",
27
29
  "communication.newComment.text": "{string:user.0.displayName} ha dejado un comentario en una publicación",
28
30
  "communication.newComment.title": "💬 Nuevo comentario",
29
31
  "event": "Evento",
@@ -472,5 +474,7 @@
472
474
  "theme.claim.new.text": "{string:user.0.displayName} ha solicitado la partitura de {instrument:extra.[instrumentId,customInstrumentName]} para la obra \"{string:extra.title}\".",
473
475
  "theme.claim.new.title": "📒 Han pedido una partitura",
474
476
  "theme.claim.update.text": "Ya está disponible la partitura de {instrument:extra.[instrumentId,customInstrumentName]} para la obra \"{string:extra.title}\".",
475
- "theme.claim.update.title": "📥 Nueva partitura de {instrument:extra.[instrumentId,customInstrumentName]}"
477
+ "theme.claim.update.title": "📥 Nueva partitura de {instrument:extra.[instrumentId,customInstrumentName]}",
478
+ "communication.surveyClosingSoon.title": "⏰ La encuesta cierra pronto",
479
+ "communication.surveyClosingSoon.text": "La encuesta de {string:group.0.displayName} cierra en una hora. ¡Vota antes de que termine!"
476
480
  }
package/lang/eu.json CHANGED
@@ -24,6 +24,8 @@
24
24
  "calendarFeed.description.type": "Mota",
25
25
  "communication.create.text": "{string:group.0.displayName} taldeak argitalpen berri bat partekatu du. Begiratu!",
26
26
  "communication.create.title": "📝 Argitalpen berria",
27
+ "communication.createSurvey.text": "{string:group.0.displayName} taldeak inkesta berri bat sortu du. Parte hartu!",
28
+ "communication.createSurvey.title": "📊 Inkesta berria",
27
29
  "communication.newComment.text": "{string:user.0.displayName} erabiltzaileak iruzkin bat utzi du argitalpen batean",
28
30
  "communication.newComment.title": "💬 Iruzkin berria",
29
31
  "event": "Ekitaldia",
@@ -472,5 +474,7 @@
472
474
  "theme.claim.new.text": "{string:user.0.displayName}-k {instrument:extra.[instrumentId,customInstrumentName]} partitura eskatu du \"{string:extra.title}\" lanerako.",
473
475
  "theme.claim.new.title": "📒 Partitura eskaera berria",
474
476
  "theme.claim.update.text": "{instrument:extra.[instrumentId,customInstrumentName]} partitura eskuragarri dago \"{string:extra.title}\" lanerako.",
475
- "theme.claim.update.title": "📥 {instrument:extra.[instrumentId,customInstrumentName]} partitura berria"
477
+ "theme.claim.update.title": "📥 {instrument:extra.[instrumentId,customInstrumentName]} partitura berria",
478
+ "communication.surveyClosingSoon.title": "⏰ Inkesta laster itxiko da",
479
+ "communication.surveyClosingSoon.text": "{string:group.0.displayName} taldearen inkesta ordubete barru itxiko da. Bozkatu berandu izan baino lehen!"
476
480
  }
package/lang/fr.json CHANGED
@@ -24,6 +24,8 @@
24
24
  "calendarFeed.description.type": "Type",
25
25
  "communication.create.text": "{string:group.0.displayName} a publié une nouvelle annonce. Allez voir !",
26
26
  "communication.create.title": "📝 Nouvelle publication",
27
+ "communication.createSurvey.text": "{string:group.0.displayName} a créé un sondage. Participez !",
28
+ "communication.createSurvey.title": "📊 Nouveau sondage",
27
29
  "communication.newComment.text": "{string:user.0.displayName} a laissé un commentaire sur une publication",
28
30
  "communication.newComment.title": "💬 Nouveau commentaire",
29
31
  "event": "Événement",
@@ -472,5 +474,7 @@
472
474
  "theme.claim.new.text": "{string:user.0.displayName} a demandé la partition pour {instrument:extra.[instrumentId,customInstrumentName]} dans l'œuvre « {string:extra.title} ».",
473
475
  "theme.claim.new.title": "📒 Partition demandée",
474
476
  "theme.claim.update.text": "La partition pour {instrument:extra.[instrumentId,customInstrumentName]} dans l'œuvre « {string:extra.title} » est maintenant disponible.",
475
- "theme.claim.update.title": "📥 Nouvelle partition disponible pour {instrument:extra.[instrumentId,customInstrumentName]}"
477
+ "theme.claim.update.title": "📥 Nouvelle partition disponible pour {instrument:extra.[instrumentId,customInstrumentName]}",
478
+ "communication.surveyClosingSoon.title": "⏰ Le sondage se termine bientôt",
479
+ "communication.surveyClosingSoon.text": "Le sondage de {string:group.0.displayName} se termine dans une heure. Vote avant qu'il ne soit trop tard !"
476
480
  }
package/lang/gl.json CHANGED
@@ -24,6 +24,8 @@
24
24
  "calendarFeed.description.type": "Tipo",
25
25
  "communication.create.text": "{string:group.0.displayName} publicou algo novo. ¡Bótalle un ollo!",
26
26
  "communication.create.title": "📝 Nova publicación",
27
+ "communication.createSurvey.text": "{string:group.0.displayName} creou unha enquisa. Participa!",
28
+ "communication.createSurvey.title": "📊 Nova enquisa",
27
29
  "communication.newComment.text": "{string:user.0.displayName} deixou un comentario nunha publicación",
28
30
  "communication.newComment.title": "💬 Novo comentario",
29
31
  "event": "Evento",
@@ -472,5 +474,7 @@
472
474
  "theme.claim.new.text": "{string:user.0.displayName} solicitou a partitura de {instrument:extra.[instrumentId,customInstrumentName]} para a obra \"{string:extra.title}\".",
473
475
  "theme.claim.new.title": "📒 Solicitouse unha partitura",
474
476
  "theme.claim.update.text": "Xa está dispoñible a partitura de {instrument:extra.[instrumentId,customInstrumentName]} para a obra \"{string:extra.title}\".",
475
- "theme.claim.update.title": "📥 Nova partitura de {instrument:extra.[instrumentId,customInstrumentName]}"
477
+ "theme.claim.update.title": "📥 Nova partitura de {instrument:extra.[instrumentId,customInstrumentName]}",
478
+ "communication.surveyClosingSoon.title": "⏰ A enquisa péchase pronto",
479
+ "communication.surveyClosingSoon.text": "A enquisa de {string:group.0.displayName} péchase nunha hora. Vota antes de que remate!"
476
480
  }
package/lang/it.json CHANGED
@@ -23,7 +23,9 @@
23
23
  "calendarFeed.description.open": "Apri in Glissandoo",
24
24
  "calendarFeed.description.type": "Tipo",
25
25
  "communication.create.text": "{string:group.0.displayName} ha pubblicato qualcosa di nuovo. Dai un'occhiata!",
26
- "communication.create.title": "📝 Nuovo post",
26
+ "communication.create.title": "📝 Nuova pubblicazione",
27
+ "communication.createSurvey.text": "{string:group.0.displayName} ha creato un sondaggio. Partecipa!",
28
+ "communication.createSurvey.title": "📊 Nuovo sondaggio",
27
29
  "communication.newComment.text": "{string:user.0.displayName} ha lasciato un commento su un post",
28
30
  "communication.newComment.title": "💬 Nuovo commento",
29
31
  "event": "Evento",
@@ -472,5 +474,7 @@
472
474
  "theme.claim.new.text": "{string:user.0.displayName} ha richiesto la partitura per {instrument:extra.[instrumentId,customInstrumentName]} del brano \"{string:extra.title}\".",
473
475
  "theme.claim.new.title": "📒 Partitura richiesta",
474
476
  "theme.claim.update.text": "La partitura per {instrument:extra.[instrumentId,customInstrumentName]} del brano \"{string:extra.title}\" è ora disponibile.",
475
- "theme.claim.update.title": "📥 Nuova partitura per {instrument:extra.[instrumentId,customInstrumentName]}"
477
+ "theme.claim.update.title": "📥 Nuova partitura per {instrument:extra.[instrumentId,customInstrumentName]}",
478
+ "communication.surveyClosingSoon.title": "⏰ Il sondaggio si chiude presto",
479
+ "communication.surveyClosingSoon.text": "Il sondaggio di {string:group.0.displayName} si chiude tra un'ora. Vota prima che sia troppo tardi!"
476
480
  }
package/lang/nl.json CHANGED
@@ -23,7 +23,9 @@
23
23
  "calendarFeed.description.open": "Openen in Glissandoo",
24
24
  "calendarFeed.description.type": "Type",
25
25
  "communication.create.text": "{string:group.0.displayName} heeft iets nieuws geplaatst. Bekijk het!",
26
- "communication.create.title": "📝 Nieuwe post",
26
+ "communication.create.title": "📝 Nieuw bericht",
27
+ "communication.createSurvey.text": "{string:group.0.displayName} heeft een enquête gemaakt. Doe mee!",
28
+ "communication.createSurvey.title": "📊 Nieuwe enquête",
27
29
  "communication.newComment.text": "{string:user.0.displayName} heeft een reactie achtergelaten op een bericht",
28
30
  "communication.newComment.title": "💬 Nieuwe reactie",
29
31
  "event": "Evenement",
@@ -472,5 +474,7 @@
472
474
  "theme.claim.new.text": "{string:user.0.displayName} heeft bladmuziek aangevraagd voor {instrument:extra.[instrumentId,customInstrumentName]} in het stuk \"{string:extra.title}\".",
473
475
  "theme.claim.new.title": "📒 Bladmuziek aangevraagd",
474
476
  "theme.claim.update.text": "De bladmuziek voor {instrument:extra.[instrumentId,customInstrumentName]} in het stuk \"{string:extra.title}\" is nu beschikbaar.",
475
- "theme.claim.update.title": "📥 Nieuwe bladmuziek voor {instrument:extra.[instrumentId,customInstrumentName]}"
477
+ "theme.claim.update.title": "📥 Nieuwe bladmuziek voor {instrument:extra.[instrumentId,customInstrumentName]}",
478
+ "communication.surveyClosingSoon.title": "⏰ Enquête sluit binnenkort",
479
+ "communication.surveyClosingSoon.text": "De enquête van {string:group.0.displayName} sluit over een uur. Stem voordat het te laat is!"
476
480
  }
package/lang/pt.json CHANGED
@@ -24,6 +24,8 @@
24
24
  "calendarFeed.description.type": "Tipo",
25
25
  "communication.create.text": "{string:group.0.displayName} publicou algo novo. Confira!",
26
26
  "communication.create.title": "📝 Nova publicação",
27
+ "communication.createSurvey.text": "{string:group.0.displayName} criou uma sondagem. Participa!",
28
+ "communication.createSurvey.title": "📊 Nova sondagem",
27
29
  "communication.newComment.text": "{string:user.0.displayName} deixou um comentário em uma publicação",
28
30
  "communication.newComment.title": "💬 Novo comentário",
29
31
  "event": "Evento",
@@ -472,5 +474,7 @@
472
474
  "theme.claim.new.text": "{string:user.0.displayName} solicitou a partitura de {instrument:extra.[instrumentId,customInstrumentName]} para a obra \"{string:extra.title}\".",
473
475
  "theme.claim.new.title": "📒 Pedido de partitura",
474
476
  "theme.claim.update.text": "A partitura de {instrument:extra.[instrumentId,customInstrumentName]} para a obra \"{string:extra.title}\" já está disponível.",
475
- "theme.claim.update.title": "📥 Nova partitura de {instrument:extra.[instrumentId,customInstrumentName]}"
477
+ "theme.claim.update.title": "📥 Nova partitura de {instrument:extra.[instrumentId,customInstrumentName]}",
478
+ "communication.surveyClosingSoon.title": "⏰ A sondagem encerra em breve",
479
+ "communication.surveyClosingSoon.text": "A sondagem de {string:group.0.displayName} encerra dentro de uma hora. Vota antes que seja tarde!"
476
480
  }
@@ -2,7 +2,7 @@ import { DocumentReference } from '@google-cloud/firestore';
2
2
  import { LanguagesTypes } from '../../lang';
3
3
  import { DocumentModel } from '../Model';
4
4
  import ModelWithLang from '../Model/lang';
5
- import { CommunicationData, CommunicationType } from './types';
5
+ import { CommunicationData, CommunicationFormat, CommunicationType } from './types';
6
6
  export default class Communication extends ModelWithLang<CommunicationData> {
7
7
  constructor(doc: DocumentModel, lang?: LanguagesTypes);
8
8
  get title(): string;
@@ -23,6 +23,19 @@ export default class Communication extends ModelWithLang<CommunicationData> {
23
23
  get type(): CommunicationType;
24
24
  get isPrivate(): boolean;
25
25
  get isPublic(): boolean;
26
+ get format(): CommunicationFormat;
27
+ get isSurvey(): boolean;
28
+ get isPost(): boolean;
29
+ get survey(): import("./types").CommunicationSurveyConfig | null;
30
+ get surveyQuestions(): import("./types").CommunicationSurveyQuestion[];
31
+ get surveyResultsVisibility(): import("./types").CommunicationSurveyResults | null;
32
+ get surveyClosesAt(): FirebaseFirestore.Timestamp | null;
33
+ get isSurveyClosed(): boolean;
34
+ get surveyResponsesCount(): number;
35
+ get pendingRecipients(): string[];
36
+ get hasSurveyVotes(): boolean;
37
+ get surveyResults(): Record<string, Record<string, string[]>>;
38
+ getSurveyAnswers: (userId: string) => Record<string, string[]> | null;
26
39
  get attachmentsPath(): string[];
27
40
  get imagesPath(): string[];
28
41
  get deletedAt(): FirebaseFirestore.Timestamp | null;
@@ -11,6 +11,10 @@ const types_1 = require("./types");
11
11
  class Communication extends lang_2.default {
12
12
  constructor(doc, lang = lang_1.defaultLocale) {
13
13
  super(doc, lang);
14
+ this.getSurveyAnswers = (userId) => {
15
+ const recipient = this.getRecipient(userId);
16
+ return recipient ? recipient.surveyAnswers || null : null;
17
+ };
14
18
  this.getRecipient = (userId) => {
15
19
  return userId in this.recipientsInfo ? this.recipientsInfo[userId] : null;
16
20
  };
@@ -63,6 +67,63 @@ class Communication extends lang_2.default {
63
67
  get isPublic() {
64
68
  return this.data.type === types_1.CommunicationType.Public;
65
69
  }
70
+ get format() {
71
+ return this.data.format || types_1.CommunicationFormat.Post;
72
+ }
73
+ get isSurvey() {
74
+ return this.format === types_1.CommunicationFormat.Survey;
75
+ }
76
+ get isPost() {
77
+ return this.format === types_1.CommunicationFormat.Post;
78
+ }
79
+ get survey() {
80
+ return this.data.survey || null;
81
+ }
82
+ get surveyQuestions() {
83
+ return this.survey ? (0, lodash_1.sortBy)(this.survey.questions, 'order') : [];
84
+ }
85
+ get surveyResultsVisibility() {
86
+ return this.survey ? this.survey.results : null;
87
+ }
88
+ get surveyClosesAt() {
89
+ return this.survey ? this.survey.closesAt : null;
90
+ }
91
+ get isSurveyClosed() {
92
+ const closesAt = this.surveyClosesAt;
93
+ return !!closesAt && closesAt.toMillis() < Date.now();
94
+ }
95
+ get surveyResponsesCount() {
96
+ return this.listRecipients.filter((recipient) => !!recipient.answeredAt).length;
97
+ }
98
+ get pendingRecipients() {
99
+ return this.recipients.filter((userId) => !this.getRecipient(userId)?.answeredAt);
100
+ }
101
+ get hasSurveyVotes() {
102
+ return this.surveyResponsesCount > 0;
103
+ }
104
+ get surveyResults() {
105
+ const counts = {};
106
+ for (const question of this.surveyQuestions) {
107
+ counts[question.id] = {};
108
+ for (const answer of question.answers) {
109
+ counts[question.id][answer.id] = [];
110
+ }
111
+ }
112
+ for (const recipient of this.listRecipients) {
113
+ const answers = recipient.surveyAnswers;
114
+ if (!answers) {
115
+ continue;
116
+ }
117
+ for (const [questionId, optionIds] of Object.entries(answers)) {
118
+ for (const optionId of optionIds) {
119
+ if (counts[questionId] && counts[questionId][optionId]) {
120
+ counts[questionId][optionId].push(recipient.id);
121
+ }
122
+ }
123
+ }
124
+ }
125
+ return counts;
126
+ }
66
127
  get attachmentsPath() {
67
128
  return this.data.attachmentsPath || [];
68
129
  }
@@ -12,6 +12,14 @@ export declare enum CommunicationType {
12
12
  Private = "user",
13
13
  Public = "group"
14
14
  }
15
+ export declare enum CommunicationFormat {
16
+ Post = "post",
17
+ Survey = "survey"
18
+ }
19
+ export declare enum CommunicationSurveyResults {
20
+ Admins = "admins",
21
+ Everyone = "everyone"
22
+ }
15
23
  export declare enum CommunicationReactions {
16
24
  OK = "\uD83D\uDC4D",
17
25
  Claps = "\uD83D\uDC4F",
@@ -48,12 +56,32 @@ export interface CommunicationRecipientData {
48
56
  lastViewedAt: Timestamp | null;
49
57
  countViews: number;
50
58
  reaction: CommunicationReactions | null;
59
+ surveyAnswers: Record<string, string[]> | null;
60
+ answeredAt: Timestamp | null;
61
+ }
62
+ export interface CommunicationSurveyQuestion {
63
+ id: string;
64
+ title: string;
65
+ order: number;
66
+ multiselect: boolean;
67
+ answers: {
68
+ id: string;
69
+ text: string;
70
+ }[];
71
+ }
72
+ export interface CommunicationSurveyConfig {
73
+ anonymous: boolean;
74
+ results: CommunicationSurveyResults;
75
+ closesAt: Timestamp | null;
76
+ questions: CommunicationSurveyQuestion[];
51
77
  }
52
78
  export interface CommunicationData {
53
79
  title: string;
54
80
  message: Descendant[];
55
81
  messageMd: string;
56
82
  type: CommunicationType;
83
+ format: CommunicationFormat;
84
+ survey: CommunicationSurveyConfig | null;
57
85
  readonly promoter: DocumentReference;
58
86
  promoterInfo: GroupTinyData;
59
87
  readonly owner: DocumentReference;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CommunicationReactions = exports.CommunicationType = exports.CommHistoryAction = void 0;
3
+ exports.CommunicationReactions = exports.CommunicationSurveyResults = exports.CommunicationFormat = exports.CommunicationType = exports.CommHistoryAction = void 0;
4
4
  var CommHistoryAction;
5
5
  (function (CommHistoryAction) {
6
6
  CommHistoryAction["Created"] = "created";
@@ -12,6 +12,16 @@ var CommunicationType;
12
12
  CommunicationType["Private"] = "user";
13
13
  CommunicationType["Public"] = "group";
14
14
  })(CommunicationType = exports.CommunicationType || (exports.CommunicationType = {}));
15
+ var CommunicationFormat;
16
+ (function (CommunicationFormat) {
17
+ CommunicationFormat["Post"] = "post";
18
+ CommunicationFormat["Survey"] = "survey";
19
+ })(CommunicationFormat = exports.CommunicationFormat || (exports.CommunicationFormat = {}));
20
+ var CommunicationSurveyResults;
21
+ (function (CommunicationSurveyResults) {
22
+ CommunicationSurveyResults["Admins"] = "admins";
23
+ CommunicationSurveyResults["Everyone"] = "everyone";
24
+ })(CommunicationSurveyResults = exports.CommunicationSurveyResults || (exports.CommunicationSurveyResults = {}));
15
25
  var CommunicationReactions;
16
26
  (function (CommunicationReactions) {
17
27
  CommunicationReactions["OK"] = "\uD83D\uDC4D";
@@ -17,6 +17,8 @@ export declare enum NotificationActions {
17
17
  BadgePlayedWorksFirstLevel = "badgePlayedWorks.firstLevel",
18
18
  BadgePlayedWorksUpLevel = "badgePlayedWorks.upLevel",
19
19
  CommunicationCreate = "communication.create",
20
+ CommunicationCreateSurvey = "communication.createSurvey",
21
+ CommunicationSurveyClosingSoon = "communication.surveyClosingSoon",
20
22
  CommunicationNewComment = "communication.newComment",
21
23
  EventGuestJoined = "event.guest.joined",
22
24
  GroupDelete = "group.delete",
@@ -14,6 +14,8 @@ var NotificationActions;
14
14
  NotificationActions["BadgePlayedWorksFirstLevel"] = "badgePlayedWorks.firstLevel";
15
15
  NotificationActions["BadgePlayedWorksUpLevel"] = "badgePlayedWorks.upLevel";
16
16
  NotificationActions["CommunicationCreate"] = "communication.create";
17
+ NotificationActions["CommunicationCreateSurvey"] = "communication.createSurvey";
18
+ NotificationActions["CommunicationSurveyClosingSoon"] = "communication.surveyClosingSoon";
17
19
  NotificationActions["CommunicationNewComment"] = "communication.newComment";
18
20
  NotificationActions["EventGuestJoined"] = "event.guest.joined";
19
21
  NotificationActions["GroupDelete"] = "group.delete";
@@ -241,7 +243,10 @@ exports.notificationByFilter = {
241
243
  NotificationActions.PracticeAssistanceDecline,
242
244
  NotificationActions.PracticeAssistanceDeclineByAdmin,
243
245
  ],
244
- [NotificationActionsFilter.CommunicationCreated]: [NotificationActions.CommunicationCreate],
246
+ [NotificationActionsFilter.CommunicationCreated]: [
247
+ NotificationActions.CommunicationCreate,
248
+ NotificationActions.CommunicationCreateSurvey,
249
+ ],
245
250
  [NotificationActionsFilter.CommunicationComment]: [NotificationActions.CommunicationNewComment],
246
251
  [NotificationActionsFilter.BadgeNew]: [
247
252
  NotificationActions.BadgeAccPerformancesFirstLevel,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glissandoo/lib",
3
- "version": "1.128.0",
3
+ "version": "1.129.1",
4
4
  "description": "Glissandoo library js",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",