@glissandoo/lib 1.17.8 → 1.18.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.
package/helpers/auth.d.ts CHANGED
@@ -17,10 +17,10 @@ export declare enum AuthErrors {
17
17
  NoPartnerhispAdmin = "error.auth.noPartnershipAdmin",
18
18
  Unauthenticated = "error.auth.unauthenticated"
19
19
  }
20
- export type AuthURLParams = {
20
+ export interface AuthURLParams {
21
21
  error?: string;
22
22
  return_to?: string;
23
23
  callbackFbName?: FbFunctionName;
24
24
  callbackFbParam?: string;
25
- };
25
+ }
26
26
  export declare const getAuthURL: (path: string, lang: LanguagesTypes, params?: AuthURLParams) => string;
package/helpers/auth.js CHANGED
@@ -14,11 +14,11 @@ var AuthErrors;
14
14
  })(AuthErrors = exports.AuthErrors || (exports.AuthErrors = {}));
15
15
  const getAuthURL = (path, lang, params) => {
16
16
  const url = new URL(lang === lang_1.defaultLocale ? path : [lang, path].join('/'), AUTH_HOST);
17
- if (params) {
18
- for (const param of Object.entries(params)) {
19
- url.searchParams.set(param[0], param[1]);
17
+ Object.entries(params || {}).forEach(([key, value]) => {
18
+ if (typeof value === 'string') {
19
+ url.searchParams.set(key, value);
20
20
  }
21
- }
21
+ });
22
22
  return url.toString();
23
23
  };
24
24
  exports.getAuthURL = getAuthURL;
@@ -4,7 +4,7 @@ import { LanguagesTypes } from '../../../lang';
4
4
  import EventoTiny from '../../Evento/tiny';
5
5
  import Theme from '../../Repertory/basic';
6
6
  import { FileSectionId } from './File/Section/types';
7
- import { AGroupRepertoryClaim, GroupRepertoireVisibility, GroupRepertoryData } from './types';
7
+ import { GroupRepertoireVisibility, GroupRepertoryData } from './types';
8
8
  export default class GroupRepertory extends Theme<GroupRepertoryData> {
9
9
  private lang;
10
10
  constructor(doc: firestore.DocumentSnapshot, lang?: LanguagesTypes);
@@ -55,10 +55,17 @@ export default class GroupRepertory extends Theme<GroupRepertoryData> {
55
55
  get thumbnailURL(): string | null;
56
56
  get ownerId(): string;
57
57
  get lastEventDatetime(): firestore.Timestamp | null;
58
- get claims(): Record<string, Record<string, import("./types").GroupRepertoryClaimType>>;
59
- get claimsList(): AGroupRepertoryClaim[];
60
- claimsByInstrument(instrumentId: string): Record<string, import("./types").GroupRepertoryClaimType>;
61
- getPlayersByInstrumentClaimed(instrumentId: string, onlyNoNotified?: boolean): string[];
58
+ get claims(): Partial<Record<InstrumentId, Record<string, import("./types").GroupRepertoryClaimType>>>;
59
+ get claimsList(): {
60
+ createdAt: firestore.Timestamp;
61
+ notifiedAt: firestore.Timestamp | null;
62
+ userId: string;
63
+ instrumentId: InstrumentId;
64
+ hasFile: boolean;
65
+ }[];
66
+ hasInstrumentAFile(instrumentId: InstrumentId): boolean;
67
+ claimsByInstrument(instrumentId: InstrumentId): Record<string, import("./types").GroupRepertoryClaimType>;
68
+ getPlayersByInstrumentClaimed(instrumentId: InstrumentId, onlyNoNotified?: boolean): string[];
62
69
  isInstrumentClaimed(instrumentId: string): boolean;
63
70
  isInstrumentClaimedByPlayer(instrumentId: InstrumentId, userId: string): boolean;
64
71
  /** @deprecated use sections */
@@ -9,10 +9,12 @@ const lodash_1 = require("lodash");
9
9
  const get_1 = __importDefault(require("lodash/get"));
10
10
  const orderBy_1 = __importDefault(require("lodash/orderBy"));
11
11
  const objects_1 = require("../../../helpers/objects");
12
+ const ts_extras_1 = require("../../../helpers/ts-extras");
12
13
  const lang_1 = require("../../../lang");
13
14
  const tiny_1 = __importDefault(require("../../Evento/tiny"));
14
15
  const basic_1 = __importDefault(require("../../Repertory/basic"));
15
- const types_1 = require("./types");
16
+ const types_1 = require("./File/Section/types");
17
+ const types_2 = require("./types");
16
18
  class GroupRepertory extends basic_1.default {
17
19
  constructor(doc, lang = lang_1.defaultLocale) {
18
20
  super(doc);
@@ -55,7 +57,7 @@ class GroupRepertory extends basic_1.default {
55
57
  return this.data.mainFilePath;
56
58
  }
57
59
  get visibility() {
58
- return this.data.visibility || types_1.GroupRepertoireVisibility.ByEvent;
60
+ return this.data.visibility || types_2.GroupRepertoireVisibility.ByEvent;
59
61
  }
60
62
  get votes() {
61
63
  return this.data.votes || {};
@@ -130,23 +132,24 @@ class GroupRepertory extends basic_1.default {
130
132
  return this.data.claims || {};
131
133
  }
132
134
  get claimsList() {
133
- const list = [];
134
- Object.keys(this.claims).map((instrumentId) => {
135
- Object.keys(this.claims[instrumentId] || {}).map((userId) => {
136
- list.push({
137
- userId,
138
- instrumentId: instrumentId,
139
- ...this.claims[instrumentId][userId],
140
- });
141
- });
142
- });
143
- return list;
135
+ return (0, ts_extras_1.objectEntries)(this.claims)
136
+ .map(([iId, users]) => (0, ts_extras_1.objectEntries)(users || {}).map(([userId, claim]) => ({
137
+ userId,
138
+ instrumentId: iId,
139
+ hasFile: this.hasInstrumentAFile(iId),
140
+ ...(claim || {}),
141
+ })))
142
+ .flat();
143
+ }
144
+ hasInstrumentAFile(instrumentId) {
145
+ return (this.sectionIds.includes(types_1.FileSectionIdReserved.All) ||
146
+ this.sectionIds.includes(instrumentId));
144
147
  }
145
148
  claimsByInstrument(instrumentId) {
146
149
  if (!this.isInstrumentClaimed(instrumentId)) {
147
150
  return {};
148
151
  }
149
- return instrumentId in this.claims ? this.claims[instrumentId] : {};
152
+ return instrumentId in this.claims ? this.claims[instrumentId] || {} : {};
150
153
  }
151
154
  getPlayersByInstrumentClaimed(instrumentId, onlyNoNotified = false) {
152
155
  const claimsByInstrument = this.claimsByInstrument(instrumentId);
@@ -162,7 +165,7 @@ class GroupRepertory extends basic_1.default {
162
165
  if (!this.isInstrumentClaimed(instrumentId)) {
163
166
  return false;
164
167
  }
165
- return userId in this.claims[instrumentId];
168
+ return userId in (this.claims[instrumentId] || {});
166
169
  }
167
170
  /** @deprecated use sections */
168
171
  getInstrument(id) {
@@ -37,6 +37,7 @@ export interface AGroupRepertoireScoreFilePage extends GroupRepertoireScoreFileP
37
37
  }
38
38
  type PageNumber = string;
39
39
  type FileId = string;
40
+ type UserId = string;
40
41
  export interface GroupRepertoireFileSections {
41
42
  tags?: string[];
42
43
  pages?: Record<PageNumber, GroupRepertoireScoreFilePage>;
@@ -75,7 +76,7 @@ export interface GroupRepertoryData extends ThemeBasicData {
75
76
  editedAt: Timestamp | null;
76
77
  visibility: GroupRepertoireVisibility;
77
78
  lastEventDatetime: Timestamp | null;
78
- claims: Record<string, Record<string, GroupRepertoryClaimType>>;
79
+ claims: Partial<Record<InstrumentId, Record<UserId, GroupRepertoryClaimType>>>;
79
80
  clonedFrom: DocumentReference | null;
80
81
  readonly owner: DocumentReference;
81
82
  readonly createdAt: Timestamp;
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@glissandoo/lib",
3
- "version": "1.17.8",
3
+ "version": "1.18.1",
4
4
  "description": "Glissandoo library js",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",
7
7
  "scripts": {
8
+ "tsc": "tsc",
8
9
  "build": "tsc",
9
10
  "build:watch": "tsc --watch",
10
11
  "test": "echo \"Error: no test specified\" && exit 1",