@glissandoo/lib 1.129.1 → 1.130.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.
@@ -31,6 +31,7 @@ export declare namespace UserFbFunctionsTypes {
31
31
  type JoinEventResult = void;
32
32
  interface RecoveryPasswordParams {
33
33
  email: string;
34
+ captchaToken?: string;
34
35
  }
35
36
  type RecoveryPasswordResult = void;
36
37
  }
@@ -86,7 +86,8 @@ export declare enum HttpsErrorMessages {
86
86
  GroupModuleAlreadyDisabled = "error.groupModule.alreadyDisabled",
87
87
  GroupModuleAlreadyEnabled = "error.groupModule.alreadyEnabled",
88
88
  GroupModuleNotEnabled = "error.groupModule.notEnabled",
89
- EventPayoutNotInitialized = "error.eventPayout.notInitialized"
89
+ EventPayoutNotInitialized = "error.eventPayout.notInitialized",
90
+ InvalidCaptcha = "error.captcha.noValid"
90
91
  }
91
92
  export interface HttpsErrorDetails extends Record<HttpsErrorMessages, unknown> {
92
93
  [HttpsErrorMessages.ThemesWithCustomInstrumentsToBeDeleted]: {
package/helpers/errors.js CHANGED
@@ -88,4 +88,5 @@ var HttpsErrorMessages;
88
88
  HttpsErrorMessages["GroupModuleAlreadyEnabled"] = "error.groupModule.alreadyEnabled";
89
89
  HttpsErrorMessages["GroupModuleNotEnabled"] = "error.groupModule.notEnabled";
90
90
  HttpsErrorMessages["EventPayoutNotInitialized"] = "error.eventPayout.notInitialized";
91
+ HttpsErrorMessages["InvalidCaptcha"] = "error.captcha.noValid";
91
92
  })(HttpsErrorMessages = exports.HttpsErrorMessages || (exports.HttpsErrorMessages = {}));
@@ -0,0 +1,33 @@
1
+ import { DocumentReference, Timestamp } from '@google-cloud/firestore';
2
+ import { Database } from '../../types/supabase';
3
+ import { GroupBasicData } from '../Group/types';
4
+ import { DocumentModel } from '../Model';
5
+ import { EventData } from './types';
6
+ export type EventRow = Database['public']['Tables']['event']['Row'];
7
+ /**
8
+ * Runtime constructors that `lib` cannot import directly: models must run in
9
+ * browser, React Native and Node, so the Firestore `Timestamp`/`DocumentReference`
10
+ * factories are injected by the consuming client (which owns the Firebase SDK).
11
+ */
12
+ export interface RowToEventDeps {
13
+ /** Build a Firestore Timestamp from an ISO string. */
14
+ toTimestamp: (iso: string) => Timestamp;
15
+ /** Build a Firestore DocumentReference from a collection + id. */
16
+ makeRef: (collection: string, id: string) => DocumentReference;
17
+ }
18
+ /**
19
+ * Map a raw Supabase `event` mirror row into the canonical `EventData` shape
20
+ * consumed by the `Evento` model.
21
+ *
22
+ * `promoterInfo` is not mirrored on the `event` table, so it must be supplied by
23
+ * the caller (the active group's basic data on the events tab). `location` is
24
+ * intentionally left `null`: it is not part of the list projection and the
25
+ * PostGIS column is not mapped here.
26
+ */
27
+ export declare function rowToEventData(row: EventRow, promoterInfo: GroupBasicData, deps: RowToEventDeps): EventData;
28
+ /**
29
+ * Wrap a Supabase `event` row in a synthetic `DocumentModel` so it can be fed to
30
+ * `new Evento(...)`, reusing every derived getter (playersList, isActive,
31
+ * isResponseAllowed, ...) without duplicating logic.
32
+ */
33
+ export declare function rowToEventDocumentModel(row: EventRow, promoterInfo: GroupBasicData, deps: RowToEventDeps): DocumentModel;
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.rowToEventDocumentModel = exports.rowToEventData = void 0;
4
+ const lodash_1 = require("lodash");
5
+ const types_1 = require("../../helpers/types");
6
+ const types_2 = require("./Player/types");
7
+ const emptyQuestions = {
8
+ [types_2.EventPlayerStatus.Confirmed]: [],
9
+ [types_2.EventPlayerStatus.Declined]: [],
10
+ };
11
+ /**
12
+ * Map a raw Supabase `event` mirror row into the canonical `EventData` shape
13
+ * consumed by the `Evento` model.
14
+ *
15
+ * `promoterInfo` is not mirrored on the `event` table, so it must be supplied by
16
+ * the caller (the active group's basic data on the events tab). `location` is
17
+ * intentionally left `null`: it is not part of the list projection and the
18
+ * PostGIS column is not mapped here.
19
+ */
20
+ function rowToEventData(row, promoterInfo, deps) {
21
+ const { toTimestamp, makeRef } = deps;
22
+ const tsOrNull = (iso) => (iso ? toTimestamp(iso) : null);
23
+ return {
24
+ // Tiny / basic
25
+ displayName: row.displayName,
26
+ datetime: toTimestamp(row.datetime),
27
+ type: row.type,
28
+ timezone: row.timezone || 'Europe/Madrid',
29
+ locality: row.locality,
30
+ online: row.online,
31
+ datetimeEnd: toTimestamp(row.datetimeEnd),
32
+ responseDeadlineAt: toTimestamp(row.responseDeadlineAt),
33
+ selectionMode: row.selectionMode ?? null,
34
+ // Promoter
35
+ promoter: makeRef('group', row.promoter ?? ''),
36
+ promoterInfo,
37
+ // Full event data
38
+ location: null,
39
+ coverURL: row.coverURL,
40
+ videoURL: row.videoURL,
41
+ description: row.description,
42
+ descriptionSlate: row.descriptionSlate ?? [],
43
+ playerIds: row.playerIds ?? [],
44
+ players: row.players ?? {},
45
+ repertoryIds: row.repertoryIds ?? [],
46
+ repertory: row.repertory ?? {},
47
+ relEvents: row.relEvents ?? [],
48
+ activeInvitationLink: row.activeInvitationLink,
49
+ guestInviteCode: null,
50
+ shortDynamicLink: row.shortDynamicLink,
51
+ invitationLink: row.invitationLink,
52
+ notifyAt: toTimestamp(row.notifyAt),
53
+ maxAttendance: row.maxAttendance,
54
+ deletedAt: tsOrNull(row.deletedAt),
55
+ deletedBy: row.deletedBy,
56
+ rollCalledAt: tsOrNull(row.rollCalledAt),
57
+ rollCalledBy: row.rollCalledBy,
58
+ rollCallReminderAt: tsOrNull(row.rollCallReminderAt),
59
+ rollCallHistory: (row.rollCallHistory ?? []).map((entry) => {
60
+ const item = entry;
61
+ return { changedAt: toTimestamp(item.changedAt), changedBy: item.changedBy };
62
+ }),
63
+ templateId: row.templateId,
64
+ repeat: row.repeat
65
+ ? { period: row.repeat.period, untilAt: toTimestamp(row.repeat.untilAt) }
66
+ : null,
67
+ stage: row.stage ?? null,
68
+ stageTemplateId: row.stageTemplateId,
69
+ responseDeadline: {
70
+ option: row.responseDeadline.option,
71
+ customAt: tsOrNull(row.responseDeadline.customAt),
72
+ },
73
+ selectionModeClosedAt: tsOrNull(row.selectionModeClosedAt),
74
+ sites: row.sites,
75
+ imagesPath: [],
76
+ attachmentsPath: [],
77
+ questions: row.questions ??
78
+ emptyQuestions,
79
+ reminders: [],
80
+ payout: row.payout ?? null,
81
+ owner: makeRef('user', row.owner ?? ''),
82
+ createdAt: toTimestamp(row.createdAt),
83
+ createdOn: row.createdOn ?? types_1.CreatedOn.Dashboard,
84
+ };
85
+ }
86
+ exports.rowToEventData = rowToEventData;
87
+ /**
88
+ * Wrap a Supabase `event` row in a synthetic `DocumentModel` so it can be fed to
89
+ * `new Evento(...)`, reusing every derived getter (playersList, isActive,
90
+ * isResponseAllowed, ...) without duplicating logic.
91
+ */
92
+ function rowToEventDocumentModel(row, promoterInfo, deps) {
93
+ const data = rowToEventData(row, promoterInfo, deps);
94
+ return {
95
+ id: row.id,
96
+ exists: true,
97
+ data: () => data,
98
+ ref: { id: row.id, path: `event/${row.id}` },
99
+ get: ((fieldPath) => (0, lodash_1.get)(data, fieldPath)),
100
+ };
101
+ }
102
+ exports.rowToEventDocumentModel = rowToEventDocumentModel;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glissandoo/lib",
3
- "version": "1.129.1",
3
+ "version": "1.130.1",
4
4
  "description": "Glissandoo library js",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",
@@ -44,7 +44,7 @@ type DatabaseMerged = MergeDeep<DatabaseGenerated, {
44
44
  group: Overwrite<GroupOverwrite, 'configSites' | 'socialNetworks'>;
45
45
  groupPlayer: Overwrite<GroupPlayerOverwrite, 'additionalInfo' | 'customFields' | 'badgeAccPractices' | 'badgeAccPerformances' | 'badgeStrikePractices' | 'badgeAnswerEvents' | 'badgePlayedWorks'>;
46
46
  eventPlayer: Overwrite<EventPlayerOverwrite, 'questions' | 'history'>;
47
- event: Overwrite<EventOverwrite, 'repeat' | 'stage'>;
47
+ event: Overwrite<EventOverwrite, 'repeat' | 'stage' | 'payout'>;
48
48
  offer: Overwrite<OfferOverwrite>;
49
49
  repertoire: Overwrite<RepertoireOverwrite>;
50
50
  comm: Overwrite<CommOverwrite>;
@@ -54,7 +54,7 @@ type DatabaseMerged = MergeDeep<
54
54
  | 'badgePlayedWorks'
55
55
  >;
56
56
  eventPlayer: Overwrite<EventPlayerOverwrite, 'questions' | 'history'>;
57
- event: Overwrite<EventOverwrite, 'repeat' | 'stage'>;
57
+ event: Overwrite<EventOverwrite, 'repeat' | 'stage' | 'payout'>;
58
58
  offer: Overwrite<OfferOverwrite>;
59
59
  repertoire: Overwrite<RepertoireOverwrite>;
60
60
  comm: Overwrite<CommOverwrite>;
@@ -15,6 +15,7 @@ export interface EventRollcallHistory {
15
15
  export interface EventOverwrite {
16
16
  descriptionSlate: EventData['descriptionSlate'];
17
17
  players: EventData['players'];
18
+ payout: EventData['payout'];
18
19
  repeat: EventRepeat;
19
20
  repertory: EventData['repertory'];
20
21
  responseDeadline: EventResponseDeadline;
@@ -20,6 +20,7 @@ export interface EventRollcallHistory {
20
20
  export interface EventOverwrite {
21
21
  descriptionSlate: EventData['descriptionSlate'];
22
22
  players: EventData['players'];
23
+ payout: EventData['payout'];
23
24
  repeat: EventRepeat;
24
25
  repertory: EventData['repertory'];
25
26
  responseDeadline: EventResponseDeadline;