@glissandoo/lib 1.13.1 → 1.14.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.
@@ -91,6 +91,7 @@ export declare enum FbFunctionName {
91
91
  PartnershipPlanOnUpdate = "partnershipPlan-onUpdate",
92
92
  PartnershipPlanRemove = "partnershipPlan-remove",
93
93
  PartnershipRemoveAdmin = "partnership-removeAdmin",
94
+ PartnershipStripeSession = "partnership-stripeSession",
94
95
  ReminderEvening = "reminder-evening",
95
96
  ReminderMorning = "reminder-morning",
96
97
  ReminderRollCall = "reminder-rollCall",
@@ -103,5 +104,6 @@ export declare enum FbFunctionName {
103
104
  UserOnSignUp = "user-onSignUp",
104
105
  UserOnUpdate = "user-onUpdate",
105
106
  UserRegister = "user-register",
106
- WebhookLemonway = "webhook-lemonway"
107
+ WebhookLemonway = "webhook-lemonway",
108
+ WebhookStripe = "webhook-stripe"
107
109
  }
@@ -95,6 +95,7 @@ var FbFunctionName;
95
95
  FbFunctionName["PartnershipPlanOnUpdate"] = "partnershipPlan-onUpdate";
96
96
  FbFunctionName["PartnershipPlanRemove"] = "partnershipPlan-remove";
97
97
  FbFunctionName["PartnershipRemoveAdmin"] = "partnership-removeAdmin";
98
+ FbFunctionName["PartnershipStripeSession"] = "partnership-stripeSession";
98
99
  FbFunctionName["ReminderEvening"] = "reminder-evening";
99
100
  FbFunctionName["ReminderMorning"] = "reminder-morning";
100
101
  FbFunctionName["ReminderRollCall"] = "reminder-rollCall";
@@ -108,4 +109,5 @@ var FbFunctionName;
108
109
  FbFunctionName["UserOnUpdate"] = "user-onUpdate";
109
110
  FbFunctionName["UserRegister"] = "user-register";
110
111
  FbFunctionName["WebhookLemonway"] = "webhook-lemonway";
112
+ FbFunctionName["WebhookStripe"] = "webhook-stripe";
111
113
  })(FbFunctionName = exports.FbFunctionName || (exports.FbFunctionName = {}));
@@ -1,3 +1,4 @@
1
+ import { PlanPeriod, PlansGroup } from '../helpers/plans';
1
2
  import { BasicAddressData } from '../models/Partner/types';
2
3
  export declare namespace PartnershipFbFunctionsTypes {
3
4
  interface CreateParams {
@@ -27,4 +28,13 @@ export declare namespace PartnershipFbFunctionsTypes {
27
28
  partnershipId: string;
28
29
  }
29
30
  type GetBalanceResult = number;
31
+ interface StripeSessionParams {
32
+ partnershipId: string;
33
+ groupId: string;
34
+ planId: PlansGroup;
35
+ planPeriod: PlanPeriod;
36
+ }
37
+ interface StripeSessionResult {
38
+ url: string;
39
+ }
30
40
  }
@@ -0,0 +1,12 @@
1
+ import { PlanPeriod, PlansGroup } from '../helpers/plans';
2
+ export declare namespace PaymentsFbFunctionsTypes {
3
+ interface StripeSessionParams {
4
+ partnershipId: string;
5
+ groupId: string;
6
+ planId: PlansGroup;
7
+ planPeriod: PlanPeriod;
8
+ }
9
+ interface StripeSessionResult {
10
+ url: string;
11
+ }
12
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -96,6 +96,7 @@ const regionByFunctions = {
96
96
  [index_1.FbFunctionName.PartnershipOnUpdate]: GCloudRegions.EuropeWest6,
97
97
  [index_1.FbFunctionName.PartnershipAddConfirmedAdmin]: GCloudRegions.EuropeWest6,
98
98
  [index_1.FbFunctionName.PartnershipRemoveAdmin]: GCloudRegions.EuropeWest6,
99
+ [index_1.FbFunctionName.PartnershipStripeSession]: GCloudRegions.EuropeWest6,
99
100
  [index_1.FbFunctionName.PartnershipGetMandateRequest]: GCloudRegions.EuropeWest6,
100
101
  [index_1.FbFunctionName.PartnershipOnMandateCreated]: GCloudRegions.EuropeWest6,
101
102
  [index_1.FbFunctionName.PartnershipPlanAdd]: GCloudRegions.EuropeWest6,
@@ -115,6 +116,7 @@ const regionByFunctions = {
115
116
  [index_1.FbFunctionName.ReminderRollCall]: GCloudRegions.EuropeWest1,
116
117
  [index_1.FbFunctionName.SubscriptionPaymentSchedule]: GCloudRegions.EuropeWest6,
117
118
  [index_1.FbFunctionName.WebhookLemonway]: GCloudRegions.EuropeWest6,
119
+ [index_1.FbFunctionName.WebhookStripe]: GCloudRegions.EuropeWest6,
118
120
  };
119
121
  const getFunctionRegion = (fn) => regionByFunctions[fn] || defaultRegion;
120
122
  exports.getFunctionRegion = getFunctionRegion;
@@ -0,0 +1,12 @@
1
+ import { PlanPeriod, PlansGroup } from '../helpers/plans';
2
+ export declare namespace StripeFbFunctionsTypes {
3
+ interface SessionParams {
4
+ partnershipId: string;
5
+ groupId: string;
6
+ planId: PlansGroup;
7
+ planPeriod: PlanPeriod;
8
+ }
9
+ interface SessionResult {
10
+ url: string;
11
+ }
12
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/helpers/auth.d.ts CHANGED
@@ -1,10 +1,11 @@
1
1
  import { FbFunctionName } from '../functions';
2
2
  import { LanguagesTypes } from '../lang';
3
3
  import { GroupPlayerRole } from '../models/Group/Player/types';
4
+ import { PartnershipRoles } from '../models/Partnership/types';
4
5
  export interface AuthUserClaims {
5
6
  groups?: Record<string, GroupPlayerRole>;
6
7
  federation?: string;
7
- partnership?: string;
8
+ partnerships?: Record<string, PartnershipRoles>;
8
9
  superAdmin?: boolean;
9
10
  besm?: boolean;
10
11
  }
@@ -6,4 +6,9 @@ export declare enum PlansGroup {
6
6
  Fortissimo = "fortissimo",
7
7
  Tutti = "tutti"
8
8
  }
9
+ export declare enum PlanPeriod {
10
+ Yearly = "yearly",
11
+ Monthly = "monthly"
12
+ }
9
13
  export declare const membersPerPlan: Record<PlansGroup, number>;
14
+ export declare const pricesPerPlan: Record<PlanPeriod, Record<PlansGroup, number>>;
package/helpers/plans.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.membersPerPlan = exports.PlansGroup = void 0;
3
+ exports.pricesPerPlan = exports.membersPerPlan = exports.PlanPeriod = exports.PlansGroup = void 0;
4
4
  var PlansGroup;
5
5
  (function (PlansGroup) {
6
6
  PlansGroup["Piano"] = "piano";
@@ -10,6 +10,11 @@ var PlansGroup;
10
10
  PlansGroup["Fortissimo"] = "fortissimo";
11
11
  PlansGroup["Tutti"] = "tutti";
12
12
  })(PlansGroup = exports.PlansGroup || (exports.PlansGroup = {}));
13
+ var PlanPeriod;
14
+ (function (PlanPeriod) {
15
+ PlanPeriod["Yearly"] = "yearly";
16
+ PlanPeriod["Monthly"] = "monthly";
17
+ })(PlanPeriod = exports.PlanPeriod || (exports.PlanPeriod = {}));
13
18
  exports.membersPerPlan = {
14
19
  [PlansGroup.Piano]: 20,
15
20
  [PlansGroup.MezzoPiano]: 40,
@@ -18,3 +23,21 @@ exports.membersPerPlan = {
18
23
  [PlansGroup.Fortissimo]: 100,
19
24
  [PlansGroup.Tutti]: 1000,
20
25
  };
26
+ exports.pricesPerPlan = {
27
+ [PlanPeriod.Monthly]: {
28
+ [PlansGroup.Piano]: 0,
29
+ [PlansGroup.MezzoPiano]: 9.9,
30
+ [PlansGroup.MezzoForte]: 14.9,
31
+ [PlansGroup.Forte]: 19.9,
32
+ [PlansGroup.Fortissimo]: 24.9,
33
+ [PlansGroup.Tutti]: 29.9,
34
+ },
35
+ [PlanPeriod.Yearly]: {
36
+ [PlansGroup.Piano]: 0,
37
+ [PlansGroup.MezzoPiano]: 99,
38
+ [PlansGroup.MezzoForte]: 149,
39
+ [PlansGroup.Forte]: 199,
40
+ [PlansGroup.Fortissimo]: 249,
41
+ [PlansGroup.Tutti]: 299,
42
+ },
43
+ };
package/lang/index.d.ts CHANGED
@@ -9,6 +9,7 @@ export declare enum LanguagesTypes {
9
9
  }
10
10
  export declare type MainLanguagesTypes = LanguagesTypes.ES | LanguagesTypes.EN;
11
11
  export declare const mainLangs: Record<LanguagesTypes, MainLanguagesTypes>;
12
+ export declare const langByCoLang: Record<LanguagesTypes, LanguagesTypes>;
12
13
  declare const languageProvider: {
13
14
  es: {
14
15
  messages: {
package/lang/index.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getTranslation = exports.getDateLang = exports.defaultLocale = exports.mainLangs = exports.LanguagesTypes = void 0;
6
+ exports.getTranslation = exports.getDateLang = exports.defaultLocale = exports.langByCoLang = exports.mainLangs = exports.LanguagesTypes = void 0;
7
7
  const ca_1 = __importDefault(require("date-fns/locale/ca"));
8
8
  const de_1 = __importDefault(require("date-fns/locale/de"));
9
9
  const en_US_1 = __importDefault(require("date-fns/locale/en-US"));
@@ -38,6 +38,15 @@ exports.mainLangs = {
38
38
  [LanguagesTypes.DE]: LanguagesTypes.EN,
39
39
  [LanguagesTypes.PT]: LanguagesTypes.EN,
40
40
  };
41
+ exports.langByCoLang = {
42
+ [LanguagesTypes.ES]: LanguagesTypes.ES,
43
+ [LanguagesTypes.CA]: LanguagesTypes.ES,
44
+ [LanguagesTypes.GL]: LanguagesTypes.ES,
45
+ [LanguagesTypes.EU]: LanguagesTypes.ES,
46
+ [LanguagesTypes.EN]: LanguagesTypes.EN,
47
+ [LanguagesTypes.DE]: LanguagesTypes.DE,
48
+ [LanguagesTypes.PT]: LanguagesTypes.PT,
49
+ };
41
50
  const languageProvider = {
42
51
  es: {
43
52
  messages: es_json_1.default,
@@ -1,4 +1,5 @@
1
1
  import { DocumentReference, DocumentSnapshot } from '@google-cloud/firestore';
2
+ import { PlansGroup } from '../../helpers/plans';
2
3
  import { LanguagesTypes } from '../../lang';
3
4
  import GroupBasic from './basic';
4
5
  import { GroupData, GroupStatus, SocialNetwork } from './types';
@@ -38,6 +39,7 @@ export default class Group extends GroupBasic<GroupData> {
38
39
  get config(): Record<import("./types").GroupConfig, boolean>;
39
40
  get templates(): Record<string, import("./types").GroupTemplateData>;
40
41
  get status(): GroupStatus;
42
+ get planId(): PlansGroup;
41
43
  get templatesList(): (import("./types").GroupTemplateData & {
42
44
  id: string;
43
45
  })[];
@@ -131,6 +131,9 @@ class Group extends basic_1.default {
131
131
  get status() {
132
132
  return this.data.status;
133
133
  }
134
+ get planId() {
135
+ return this.data.planId;
136
+ }
134
137
  get templatesList() {
135
138
  return Object.keys(this.templates).map((templateId) => Object.assign({}, this.templates[templateId], { id: templateId }));
136
139
  }
@@ -1,5 +1,6 @@
1
1
  import { DocumentReference, GeoPoint, Timestamp } from '@google-cloud/firestore';
2
2
  import { MusicStyleType } from '../../helpers/musicStyles';
3
+ import { PlansGroup } from '../../helpers/plans';
3
4
  import { StageTemplate } from '../../helpers/types';
4
5
  import { EventType } from '../Evento/types';
5
6
  import { PlayerBasicData } from '../Player/types';
@@ -82,6 +83,7 @@ export interface GroupData extends GroupBasicData {
82
83
  last: number;
83
84
  };
84
85
  status: GroupStatus;
86
+ planId: PlansGroup;
85
87
  partnershipId: string | null;
86
88
  repertoryCount: number;
87
89
  eventCount: Record<EventType, number>;
@@ -1,4 +1,5 @@
1
1
  import { DocumentSnapshot } from '@google-cloud/firestore';
2
+ import { PlansGroup } from '../../../helpers/plans';
2
3
  import { LanguagesTypes } from '../../../lang';
3
4
  import GroupBasic from '../../Group/basic';
4
5
  import { PartnershipGroupData } from './types';
@@ -6,5 +7,13 @@ export default class PartnershipGroup extends GroupBasic<PartnershipGroupData> {
6
7
  constructor(doc: DocumentSnapshot, lang?: LanguagesTypes);
7
8
  get linkedAt(): FirebaseFirestore.Timestamp;
8
9
  get linkedBy(): FirebaseFirestore.DocumentReference<FirebaseFirestore.DocumentData>;
10
+ get upgradedAt(): FirebaseFirestore.Timestamp | null;
11
+ get upgradedBy(): FirebaseFirestore.DocumentReference<FirebaseFirestore.DocumentData> | null;
12
+ get planId(): PlansGroup;
13
+ get planPeriod(): import("../../../helpers/plans").PlanPeriod | null;
14
+ get planStripeId(): string | null;
15
+ get subscriptionStripeId(): string | null;
9
16
  get partnershipId(): string;
17
+ get deletedAt(): FirebaseFirestore.Timestamp | null;
18
+ get isActive(): boolean;
10
19
  }
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const get_1 = __importDefault(require("lodash/get"));
7
+ const plans_1 = require("../../../helpers/plans");
7
8
  const lang_1 = require("../../../lang");
8
9
  const basic_1 = __importDefault(require("../../Group/basic"));
9
10
  class PartnershipGroup extends basic_1.default {
@@ -16,8 +17,32 @@ class PartnershipGroup extends basic_1.default {
16
17
  get linkedBy() {
17
18
  return this.data.linkedBy;
18
19
  }
20
+ get upgradedAt() {
21
+ return this.data.upgradedAt || null;
22
+ }
23
+ get upgradedBy() {
24
+ return this.data.upgradedBy || null;
25
+ }
26
+ get planId() {
27
+ return this.data.planId || plans_1.PlansGroup.Piano;
28
+ }
29
+ get planPeriod() {
30
+ return this.data.planPeriod || null;
31
+ }
32
+ get planStripeId() {
33
+ return this.data.planStripeId || null;
34
+ }
35
+ get subscriptionStripeId() {
36
+ return this.data.subscriptionStripeId || null;
37
+ }
19
38
  get partnershipId() {
20
39
  return get_1.default(this.ref, 'parent.parent.id');
21
40
  }
41
+ get deletedAt() {
42
+ return this.data.deletedAt || null;
43
+ }
44
+ get isActive() {
45
+ return this.exists && this.deletedAt === null;
46
+ }
22
47
  }
23
48
  exports.default = PartnershipGroup;
@@ -1,6 +1,14 @@
1
1
  import { DocumentReference, Timestamp } from '@google-cloud/firestore';
2
+ import { PlanPeriod, PlansGroup } from '../../../helpers/plans';
2
3
  import { GroupBasicData } from '../../Group/types';
3
4
  export interface PartnershipGroupData extends GroupBasicData {
5
+ upgradedAt: Timestamp | null;
6
+ upgradedBy: DocumentReference | null;
7
+ planId: PlansGroup;
8
+ planPeriod: PlanPeriod | null;
9
+ planStripeId: string | null;
10
+ subscriptionStripeId: string | null;
11
+ deletedAt: Timestamp | null;
4
12
  readonly linkedBy: DocumentReference;
5
13
  readonly linkedAt: Timestamp;
6
14
  }
@@ -15,4 +15,9 @@ export default class Partnership extends PartnershipBasic<PartnershipData> {
15
15
  get isActive(): boolean;
16
16
  get federationIds(): string[];
17
17
  get gocardlessCustomerId(): string | null;
18
+ get stripeCustomerId(): string | null;
19
+ get stripeTaxIds(): {
20
+ type: string;
21
+ value: string;
22
+ }[];
18
23
  }
@@ -41,5 +41,11 @@ class Partnership extends basic_1.default {
41
41
  get gocardlessCustomerId() {
42
42
  return this.data.gocardlessCustomerId || null;
43
43
  }
44
+ get stripeCustomerId() {
45
+ return this.data.stripeCustomerId || null;
46
+ }
47
+ get stripeTaxIds() {
48
+ return this.data.stripeTaxIds || [];
49
+ }
44
50
  }
45
51
  exports.default = Partnership;
@@ -1,6 +1,9 @@
1
1
  import { Timestamp } from '@google-cloud/firestore';
2
2
  import { AdminItem } from '../../helpers/types';
3
3
  import { BasicAddressData } from '../Partner/types';
4
+ export declare enum PartnershipRoles {
5
+ Admin = "admin"
6
+ }
4
7
  export declare enum PartnershipStatus {
5
8
  Verified = "verified",
6
9
  PendingVerification = "pendingVerification",
@@ -33,5 +36,10 @@ export interface PartnershipData extends PartnershipBasicData {
33
36
  deletedAt: Timestamp | null;
34
37
  federationIds: string[];
35
38
  gocardlessCustomerId: string | null;
39
+ stripeCustomerId: string | null;
40
+ stripeTaxIds: {
41
+ type: string;
42
+ value: string;
43
+ }[];
36
44
  readonly createdAt: Timestamp;
37
45
  }
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PartnershipStatus = void 0;
3
+ exports.PartnershipStatus = exports.PartnershipRoles = void 0;
4
+ var PartnershipRoles;
5
+ (function (PartnershipRoles) {
6
+ PartnershipRoles["Admin"] = "admin";
7
+ })(PartnershipRoles = exports.PartnershipRoles || (exports.PartnershipRoles = {}));
4
8
  var PartnershipStatus;
5
9
  (function (PartnershipStatus) {
6
10
  PartnershipStatus["Verified"] = "verified";
@@ -13,7 +13,7 @@ export default class User extends UserBasic<UserData> {
13
13
  get role(): UserRole;
14
14
  get isSuperAdmin(): boolean;
15
15
  get description(): string | null;
16
- get partnershipId(): string | null;
16
+ get partnershipIds(): string[];
17
17
  get federationId(): string | null;
18
18
  get pushToken(): string | null;
19
19
  get tokens(): string[];
@@ -41,8 +41,8 @@ class User extends basic_1.default {
41
41
  get description() {
42
42
  return this.data.description || null;
43
43
  }
44
- get partnershipId() {
45
- return this.data.partnershipId || null;
44
+ get partnershipIds() {
45
+ return this.data.partnershipIds || [];
46
46
  }
47
47
  get federationId() {
48
48
  return this.data.federationId || null;
@@ -55,7 +55,7 @@ export interface UserData extends UserBasicData {
55
55
  pushToken: string | null;
56
56
  tokens: string[];
57
57
  deletedAt: Timestamp | null;
58
- partnershipId: string | null;
58
+ partnershipIds: string[];
59
59
  federationId: string | null;
60
60
  groups: string[];
61
61
  groups_admin: string[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glissandoo/lib",
3
- "version": "1.13.1",
3
+ "version": "1.14.0",
4
4
  "description": "Glissandoo library js",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",