@glissandoo/lib 1.130.0 → 1.130.2

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,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.130.0",
3
+ "version": "1.130.2",
4
4
  "description": "Glissandoo library js",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",
@@ -238,6 +238,7 @@ export type Database = {
238
238
  notifyAt: string;
239
239
  online: boolean;
240
240
  owner: string | null;
241
+ payout: Json | null;
241
242
  playerIds: string[];
242
243
  players: Json;
243
244
  promoter: string | null;
@@ -286,6 +287,7 @@ export type Database = {
286
287
  notifyAt: string;
287
288
  online: boolean;
288
289
  owner?: string | null;
290
+ payout?: Json | null;
289
291
  playerIds: string[];
290
292
  players: Json;
291
293
  promoter?: string | null;
@@ -334,6 +336,7 @@ export type Database = {
334
336
  notifyAt?: string;
335
337
  online?: boolean;
336
338
  owner?: string | null;
339
+ payout?: Json | null;
337
340
  playerIds?: string[];
338
341
  players?: Json;
339
342
  promoter?: string | null;
@@ -1871,6 +1874,17 @@ export type Database = {
1871
1874
  };
1872
1875
  Returns: string;
1873
1876
  };
1877
+ listIncompleteEventPlayerMirrors: {
1878
+ Args: {
1879
+ p_after?: string;
1880
+ p_limit?: number;
1881
+ };
1882
+ Returns: {
1883
+ eventId: string;
1884
+ expectedCount: number;
1885
+ mirroredCount: number;
1886
+ }[];
1887
+ };
1874
1888
  listPublicApiRepertoire: {
1875
1889
  Args: {
1876
1890
  p_can_manage: boolean;
@@ -239,6 +239,7 @@ export type Database = {
239
239
  notifyAt: string;
240
240
  online: boolean;
241
241
  owner: string | null;
242
+ payout: Json | null;
242
243
  playerIds: string[];
243
244
  players: Json;
244
245
  promoter: string | null;
@@ -287,6 +288,7 @@ export type Database = {
287
288
  notifyAt: string;
288
289
  online: boolean;
289
290
  owner?: string | null;
291
+ payout?: Json | null;
290
292
  playerIds: string[];
291
293
  players: Json;
292
294
  promoter?: string | null;
@@ -335,6 +337,7 @@ export type Database = {
335
337
  notifyAt?: string;
336
338
  online?: boolean;
337
339
  owner?: string | null;
340
+ payout?: Json | null;
338
341
  playerIds?: string[];
339
342
  players?: Json;
340
343
  promoter?: string | null;
@@ -1872,6 +1875,14 @@ export type Database = {
1872
1875
  }[];
1873
1876
  };
1874
1877
  immutable_unaccent: { Args: { '': string }; Returns: string };
1878
+ listIncompleteEventPlayerMirrors: {
1879
+ Args: { p_after?: string; p_limit?: number };
1880
+ Returns: {
1881
+ eventId: string;
1882
+ expectedCount: number;
1883
+ mirroredCount: number;
1884
+ }[];
1885
+ };
1875
1886
  listPublicApiRepertoire: {
1876
1887
  Args: {
1877
1888
  p_can_manage: boolean;
@@ -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;