@glissandoo/lib 1.40.2 → 1.42.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.
Files changed (39) hide show
  1. package/functions/customer.d.ts +71 -0
  2. package/functions/customer.js +2 -0
  3. package/functions/customerGroup.d.ts +21 -0
  4. package/functions/customerGroup.js +2 -0
  5. package/functions/index.d.ts +17 -9
  6. package/functions/index.js +17 -9
  7. package/functions/partnership.d.ts +0 -46
  8. package/functions/partnershipGroup.d.ts +0 -9
  9. package/functions/regions.js +14 -6
  10. package/helpers/auth.d.ts +2 -0
  11. package/helpers/collections.d.ts +2 -0
  12. package/helpers/collections.js +2 -0
  13. package/helpers/errors.d.ts +3 -0
  14. package/helpers/errors.js +3 -0
  15. package/helpers/objects.d.ts +2 -2
  16. package/models/Customer/Group/index.d.ts +19 -0
  17. package/models/Customer/Group/index.js +48 -0
  18. package/models/Customer/Group/types.d.ts +15 -0
  19. package/models/Customer/Group/types.js +2 -0
  20. package/models/Customer/basic.d.ts +14 -0
  21. package/models/Customer/basic.js +46 -0
  22. package/models/Customer/index.d.ts +24 -0
  23. package/models/Customer/index.js +56 -0
  24. package/models/Customer/types.d.ts +28 -0
  25. package/models/Customer/types.js +7 -0
  26. package/models/Group/index.d.ts +5 -0
  27. package/models/Group/index.js +9 -0
  28. package/models/Group/types.d.ts +9 -0
  29. package/models/Metrics/types.d.ts +1 -1
  30. package/models/Partnership/Group/index.d.ts +8 -0
  31. package/models/Partnership/Group/index.js +8 -0
  32. package/models/Partnership/Group/types.d.ts +8 -0
  33. package/models/Partnership/index.d.ts +6 -1
  34. package/models/Partnership/index.js +7 -0
  35. package/models/Partnership/types.d.ts +4 -0
  36. package/models/User/index.d.ts +1 -0
  37. package/models/User/index.js +3 -0
  38. package/models/User/types.d.ts +1 -9
  39. package/package.json +1 -1
@@ -0,0 +1,71 @@
1
+ import { PlanPeriod, PlansGroup } from '../helpers/plans';
2
+ export declare namespace CustomerFbFunctionsTypes {
3
+ interface PublishParams {
4
+ customerId: string;
5
+ country: string;
6
+ displayName: string;
7
+ howDidYouHearAboutUs: string;
8
+ CIF: string | null;
9
+ }
10
+ type PublishResult = void;
11
+ interface CreateParams {
12
+ customerId: string;
13
+ displayName: string;
14
+ }
15
+ type CreateResult = void;
16
+ interface EditParams {
17
+ customerId: string;
18
+ howDidYouHearAboutUs: string;
19
+ gocardlessCustomerId: string;
20
+ }
21
+ type EditResult = void;
22
+ interface RemoveParams {
23
+ customerId: string;
24
+ }
25
+ type RemoveResult = void;
26
+ interface AddConfirmedAdminParams {
27
+ customerId: string;
28
+ userId: string;
29
+ }
30
+ type AddConfirmedAdminResult = void;
31
+ interface RemoveAdminParams {
32
+ customerId: string;
33
+ email: string;
34
+ }
35
+ type RemoveAdminResult = void;
36
+ interface GetGocardlessMandateParams {
37
+ customerId: string;
38
+ }
39
+ interface GetGocardlessMandateResult {
40
+ url: string;
41
+ }
42
+ interface StripeSessionParams {
43
+ customerId: string;
44
+ groupId: string;
45
+ planId: PlansGroup;
46
+ planPeriod: PlanPeriod;
47
+ }
48
+ interface StripeSessionResult {
49
+ url: string;
50
+ }
51
+ interface StripeBillingPortalParams {
52
+ customerId: string;
53
+ }
54
+ interface StripeBillingPortalResult {
55
+ url: string;
56
+ }
57
+ interface GetInvoicesParams {
58
+ customerId: string;
59
+ }
60
+ interface InvoiceItem {
61
+ id: string;
62
+ amount: number;
63
+ currency: string;
64
+ created: number;
65
+ number: string;
66
+ link: string | null;
67
+ }
68
+ interface GetInvoicesResult {
69
+ invoices: InvoiceItem[];
70
+ }
71
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,21 @@
1
+ import { PlanPeriod, PlansGroup } from '../helpers/plans';
2
+ export declare namespace CustomerGroupFbFunctionsTypes {
3
+ interface AddParams {
4
+ customerId: string;
5
+ groupId: string;
6
+ }
7
+ type AddResult = void;
8
+ interface SetPlanParams {
9
+ customerId: string;
10
+ groupId: string;
11
+ planId: PlansGroup;
12
+ planPeriod: PlanPeriod;
13
+ planDiscount: string | null;
14
+ }
15
+ type SetPlanResult = void;
16
+ interface RemoveParams {
17
+ customerId: string;
18
+ groupId: string;
19
+ }
20
+ type RemoveResult = void;
21
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,6 +1,19 @@
1
1
  export declare enum FbFunctionName {
2
2
  Auth = "auth",
3
- FederationGetConfederation = "federation-getConfederation",
3
+ CustomerAddConfirmedAdmin = "customer-addConfirmedAdmin",
4
+ CustomerPublish = "customer-publish",
5
+ CustomerCreate = "customer-create",
6
+ CustomerRemove = "customer-remove",
7
+ CustomerEdit = "customer-edit",
8
+ CustomerGetInvoices = "customer-getInvoices",
9
+ CustomerGetGocardlessMandate = "customer-getGocardlessMandate",
10
+ CustomerOnUpdate = "customer-onUpdate",
11
+ CustomerRemoveAdmin = "customer-removeAdmin",
12
+ CustomerStripeSession = "customer-stripeSession",
13
+ CustomerStripeBillingPortal = "customer-stripeBillingPortal",
14
+ CustomerGroupAdd = "customerGroup-add",
15
+ CustomerGroupSetPlan = "customerGroup-setPlan",
16
+ CustomerGroupRemove = "customerGroup-remove",
4
17
  CommunicationCommentPublish = "communicationComment-publish",
5
18
  CommunicationEdit = "communication-edit",
6
19
  CommunicationPublish = "communication-publish",
@@ -23,6 +36,7 @@ export declare enum FbFunctionName {
23
36
  EventSetRollcall = "event-setRollCall",
24
37
  FederationAddConfirmedAdmin = "federation-addConfirmedAdmin",
25
38
  FederationAddPendingAdmin = "federation-addPendingAdmin",
39
+ FederationGetConfederation = "federation-getConfederation",
26
40
  FederationConfirmAdmin = "federation-confirmAdmin",
27
41
  FederationCreate = "federation-create",
28
42
  FederationEdit = "federation-edit",
@@ -74,19 +88,13 @@ export declare enum FbFunctionName {
74
88
  MiscValidateUsername = "misc-validateUsername",
75
89
  NotificationMarkAllAsReaded = "notification-markAllAsReaded",
76
90
  PartnershipAddConfirmedAdmin = "partnership-addConfirmedAdmin",
77
- PartnershipPublish = "partnership-publish",
78
91
  PartnershipCreate = "partnership-create",
79
92
  PartnershipRemove = "partnership-remove",
80
93
  PartnershipEdit = "partnership-edit",
81
- PartnershipGetInvoices = "partnership-getInvoices",
82
- PartnershipGetGocardlessMandate = "partnership-getGocardlessMandate",
83
- PartnershipGroupAdd = "partnershipGroup-add",
84
- PartnershipGroupSetPlan = "partnershipGroup-setPlan",
85
- PartnershipGroupRemove = "partnershipGroup-remove",
86
94
  PartnershipOnUpdate = "partnership-onUpdate",
87
95
  PartnershipRemoveAdmin = "partnership-removeAdmin",
88
- PartnershipStripeSession = "partnership-stripeSession",
89
- PartnershipStripeBillingPortal = "partnership-stripeBillingPortal",
96
+ PartnershipGroupAdd = "partnershipGroup-add",
97
+ PartnershipGroupRemove = "partnershipGroup-remove",
90
98
  ReminderEvening = "reminder-evening",
91
99
  ReminderMorning = "reminder-morning",
92
100
  ReminderRollCall = "reminder-rollCall",
@@ -4,7 +4,20 @@ exports.FbFunctionName = void 0;
4
4
  var FbFunctionName;
5
5
  (function (FbFunctionName) {
6
6
  FbFunctionName["Auth"] = "auth";
7
- FbFunctionName["FederationGetConfederation"] = "federation-getConfederation";
7
+ FbFunctionName["CustomerAddConfirmedAdmin"] = "customer-addConfirmedAdmin";
8
+ FbFunctionName["CustomerPublish"] = "customer-publish";
9
+ FbFunctionName["CustomerCreate"] = "customer-create";
10
+ FbFunctionName["CustomerRemove"] = "customer-remove";
11
+ FbFunctionName["CustomerEdit"] = "customer-edit";
12
+ FbFunctionName["CustomerGetInvoices"] = "customer-getInvoices";
13
+ FbFunctionName["CustomerGetGocardlessMandate"] = "customer-getGocardlessMandate";
14
+ FbFunctionName["CustomerOnUpdate"] = "customer-onUpdate";
15
+ FbFunctionName["CustomerRemoveAdmin"] = "customer-removeAdmin";
16
+ FbFunctionName["CustomerStripeSession"] = "customer-stripeSession";
17
+ FbFunctionName["CustomerStripeBillingPortal"] = "customer-stripeBillingPortal";
18
+ FbFunctionName["CustomerGroupAdd"] = "customerGroup-add";
19
+ FbFunctionName["CustomerGroupSetPlan"] = "customerGroup-setPlan";
20
+ FbFunctionName["CustomerGroupRemove"] = "customerGroup-remove";
8
21
  FbFunctionName["CommunicationCommentPublish"] = "communicationComment-publish";
9
22
  FbFunctionName["CommunicationEdit"] = "communication-edit";
10
23
  FbFunctionName["CommunicationPublish"] = "communication-publish";
@@ -27,6 +40,7 @@ var FbFunctionName;
27
40
  FbFunctionName["EventSetRollcall"] = "event-setRollCall";
28
41
  FbFunctionName["FederationAddConfirmedAdmin"] = "federation-addConfirmedAdmin";
29
42
  FbFunctionName["FederationAddPendingAdmin"] = "federation-addPendingAdmin";
43
+ FbFunctionName["FederationGetConfederation"] = "federation-getConfederation";
30
44
  FbFunctionName["FederationConfirmAdmin"] = "federation-confirmAdmin";
31
45
  FbFunctionName["FederationCreate"] = "federation-create";
32
46
  FbFunctionName["FederationEdit"] = "federation-edit";
@@ -78,19 +92,13 @@ var FbFunctionName;
78
92
  FbFunctionName["MiscValidateUsername"] = "misc-validateUsername";
79
93
  FbFunctionName["NotificationMarkAllAsReaded"] = "notification-markAllAsReaded";
80
94
  FbFunctionName["PartnershipAddConfirmedAdmin"] = "partnership-addConfirmedAdmin";
81
- FbFunctionName["PartnershipPublish"] = "partnership-publish";
82
95
  FbFunctionName["PartnershipCreate"] = "partnership-create";
83
96
  FbFunctionName["PartnershipRemove"] = "partnership-remove";
84
97
  FbFunctionName["PartnershipEdit"] = "partnership-edit";
85
- FbFunctionName["PartnershipGetInvoices"] = "partnership-getInvoices";
86
- FbFunctionName["PartnershipGetGocardlessMandate"] = "partnership-getGocardlessMandate";
87
- FbFunctionName["PartnershipGroupAdd"] = "partnershipGroup-add";
88
- FbFunctionName["PartnershipGroupSetPlan"] = "partnershipGroup-setPlan";
89
- FbFunctionName["PartnershipGroupRemove"] = "partnershipGroup-remove";
90
98
  FbFunctionName["PartnershipOnUpdate"] = "partnership-onUpdate";
91
99
  FbFunctionName["PartnershipRemoveAdmin"] = "partnership-removeAdmin";
92
- FbFunctionName["PartnershipStripeSession"] = "partnership-stripeSession";
93
- FbFunctionName["PartnershipStripeBillingPortal"] = "partnership-stripeBillingPortal";
100
+ FbFunctionName["PartnershipGroupAdd"] = "partnershipGroup-add";
101
+ FbFunctionName["PartnershipGroupRemove"] = "partnershipGroup-remove";
94
102
  FbFunctionName["ReminderEvening"] = "reminder-evening";
95
103
  FbFunctionName["ReminderMorning"] = "reminder-morning";
96
104
  FbFunctionName["ReminderRollCall"] = "reminder-rollCall";
@@ -1,13 +1,4 @@
1
- import { PlanPeriod, PlansGroup } from '../helpers/plans';
2
1
  export declare namespace PartnershipFbFunctionsTypes {
3
- interface PublishParams {
4
- partnershipId: string;
5
- country: string;
6
- displayName: string;
7
- howDidYouHearAboutUs: string;
8
- CIF: string | null;
9
- }
10
- type PublishResult = void;
11
2
  interface CreateParams {
12
3
  partnershipId: string;
13
4
  displayName: string;
@@ -15,8 +6,6 @@ export declare namespace PartnershipFbFunctionsTypes {
15
6
  type CreateResult = void;
16
7
  interface EditParams {
17
8
  partnershipId: string;
18
- howDidYouHearAboutUs: string;
19
- gocardlessCustomerId: string;
20
9
  }
21
10
  type EditResult = void;
22
11
  interface RemoveParams {
@@ -33,39 +22,4 @@ export declare namespace PartnershipFbFunctionsTypes {
33
22
  email: string;
34
23
  }
35
24
  type RemoveAdminResult = void;
36
- interface GetGocardlessMandateParams {
37
- partnershipId: string;
38
- }
39
- interface GetGocardlessMandateResult {
40
- url: string;
41
- }
42
- interface StripeSessionParams {
43
- partnershipId: string;
44
- groupId: string;
45
- planId: PlansGroup;
46
- planPeriod: PlanPeriod;
47
- }
48
- interface StripeSessionResult {
49
- url: string;
50
- }
51
- interface StripeBillingPortalParams {
52
- partnershipId: string;
53
- }
54
- interface StripeBillingPortalResult {
55
- url: string;
56
- }
57
- interface GetInvoicesParams {
58
- partnershipId: string;
59
- }
60
- interface InvoiceItem {
61
- id: string;
62
- amount: number;
63
- currency: string;
64
- created: number;
65
- number: string;
66
- link: string | null;
67
- }
68
- interface GetInvoicesResult {
69
- invoices: InvoiceItem[];
70
- }
71
25
  }
@@ -1,18 +1,9 @@
1
- import { PlanPeriod, PlansGroup } from '../helpers/plans';
2
1
  export declare namespace PartnershipGroupFbFunctionsTypes {
3
2
  interface AddParams {
4
3
  partnershipId: string;
5
4
  groupId: string;
6
5
  }
7
6
  type AddResult = void;
8
- interface SetPlanParams {
9
- partnershipId: string;
10
- groupId: string;
11
- planId: PlansGroup;
12
- planPeriod: PlanPeriod;
13
- planDiscount: string | null;
14
- }
15
- type SetPlanResult = void;
16
7
  interface RemoveParams {
17
8
  partnershipId: string;
18
9
  groupId: string;
@@ -16,6 +16,20 @@ const regionByFunctions = {
16
16
  [index_1.FbFunctionName.UserRemove]: GCloudRegions.EuropeWest6,
17
17
  [index_1.FbFunctionName.UserOnLogin]: GCloudRegions.EuropeWest6,
18
18
  [index_1.FbFunctionName.UserOnSignUp]: GCloudRegions.EuropeWest6,
19
+ [index_1.FbFunctionName.CustomerAddConfirmedAdmin]: GCloudRegions.EuropeWest6,
20
+ [index_1.FbFunctionName.CustomerPublish]: GCloudRegions.EuropeWest6,
21
+ [index_1.FbFunctionName.CustomerCreate]: GCloudRegions.EuropeWest6,
22
+ [index_1.FbFunctionName.CustomerRemove]: GCloudRegions.EuropeWest6,
23
+ [index_1.FbFunctionName.CustomerEdit]: GCloudRegions.EuropeWest6,
24
+ [index_1.FbFunctionName.CustomerGetInvoices]: GCloudRegions.EuropeWest6,
25
+ [index_1.FbFunctionName.CustomerGetGocardlessMandate]: GCloudRegions.EuropeWest6,
26
+ [index_1.FbFunctionName.CustomerOnUpdate]: GCloudRegions.EuropeWest6,
27
+ [index_1.FbFunctionName.CustomerRemoveAdmin]: GCloudRegions.EuropeWest6,
28
+ [index_1.FbFunctionName.CustomerStripeSession]: GCloudRegions.EuropeWest6,
29
+ [index_1.FbFunctionName.CustomerStripeBillingPortal]: GCloudRegions.EuropeWest6,
30
+ [index_1.FbFunctionName.CustomerGroupAdd]: GCloudRegions.EuropeWest6,
31
+ [index_1.FbFunctionName.CustomerGroupSetPlan]: GCloudRegions.EuropeWest6,
32
+ [index_1.FbFunctionName.CustomerGroupRemove]: GCloudRegions.EuropeWest6,
19
33
  [index_1.FbFunctionName.JWTGenerate]: GCloudRegions.EuropeWest6,
20
34
  [index_1.FbFunctionName.GroupPublish]: GCloudRegions.EuropeWest6,
21
35
  [index_1.FbFunctionName.GroupEdit]: GCloudRegions.EuropeWest6,
@@ -84,19 +98,13 @@ const regionByFunctions = {
84
98
  [index_1.FbFunctionName.FederationGetConfederation]: GCloudRegions.EuropeWest6,
85
99
  [index_1.FbFunctionName.MiscValidateUsername]: GCloudRegions.UsCentral1,
86
100
  [index_1.FbFunctionName.NotificationMarkAllAsReaded]: GCloudRegions.UsCentral1,
87
- [index_1.FbFunctionName.PartnershipPublish]: GCloudRegions.EuropeWest6,
88
101
  [index_1.FbFunctionName.PartnershipCreate]: GCloudRegions.EuropeWest6,
89
102
  [index_1.FbFunctionName.PartnershipEdit]: GCloudRegions.EuropeWest6,
90
103
  [index_1.FbFunctionName.PartnershipRemove]: GCloudRegions.EuropeWest6,
91
104
  [index_1.FbFunctionName.PartnershipOnUpdate]: GCloudRegions.EuropeWest6,
92
105
  [index_1.FbFunctionName.PartnershipAddConfirmedAdmin]: GCloudRegions.EuropeWest6,
93
106
  [index_1.FbFunctionName.PartnershipRemoveAdmin]: GCloudRegions.EuropeWest6,
94
- [index_1.FbFunctionName.PartnershipStripeSession]: GCloudRegions.EuropeWest6,
95
- [index_1.FbFunctionName.PartnershipStripeBillingPortal]: GCloudRegions.EuropeWest6,
96
- [index_1.FbFunctionName.PartnershipGetInvoices]: GCloudRegions.EuropeWest6,
97
- [index_1.FbFunctionName.PartnershipGetGocardlessMandate]: GCloudRegions.EuropeWest6,
98
107
  [index_1.FbFunctionName.PartnershipGroupAdd]: GCloudRegions.EuropeWest6,
99
- [index_1.FbFunctionName.PartnershipGroupSetPlan]: GCloudRegions.EuropeWest6,
100
108
  [index_1.FbFunctionName.PartnershipGroupRemove]: GCloudRegions.EuropeWest6,
101
109
  [index_1.FbFunctionName.MiscAddSubscriber]: GCloudRegions.EuropeWest6,
102
110
  [index_1.FbFunctionName.Auth]: GCloudRegions.UsCentral1,
package/helpers/auth.d.ts CHANGED
@@ -1,11 +1,13 @@
1
1
  import { FbFunctionName } from '../functions';
2
2
  import { LanguagesTypes } from '../lang';
3
+ import { CustomerRoles } from '../models/Customer/types';
3
4
  import { GroupPlayerRole } from '../models/Group/Player/types';
4
5
  import { PartnershipRoles } from '../models/Partnership/types';
5
6
  export interface AuthUserClaims {
6
7
  groups?: Record<string, GroupPlayerRole>;
7
8
  federation?: string;
8
9
  partnerships?: Record<string, PartnershipRoles>;
10
+ customers?: Record<string, CustomerRoles>;
9
11
  superAdmin?: boolean;
10
12
  besm?: boolean;
11
13
  }
@@ -1,6 +1,8 @@
1
1
  export declare enum CollectionNames {
2
2
  Communication = "communication",
3
3
  CommunicationComments = "comments",
4
+ Customer = "customer",
5
+ CustomerGroups = "groups",
4
6
  Notification = "notification",
5
7
  User = "user",
6
8
  UserGroups = "groups",
@@ -5,6 +5,8 @@ var CollectionNames;
5
5
  (function (CollectionNames) {
6
6
  CollectionNames["Communication"] = "communication";
7
7
  CollectionNames["CommunicationComments"] = "comments";
8
+ CollectionNames["Customer"] = "customer";
9
+ CollectionNames["CustomerGroups"] = "groups";
8
10
  CollectionNames["Notification"] = "notification";
9
11
  CollectionNames["User"] = "user";
10
12
  CollectionNames["UserGroups"] = "groups";
@@ -27,6 +27,9 @@ export declare enum HttpsErrorMessages {
27
27
  InvalidAdminFederation = "error.federation.noAdmin",
28
28
  InvalidFederation = "error.federation.noActive",
29
29
  InvalidInstrument = "error.instrument.noValid",
30
+ InvalidCustomer = "error.customer.noValid",
31
+ InvalidCustomerGroup = "error.customerGroup.noValid",
32
+ InvalidCustomerAdmin = "error.customer.noAdmin",
30
33
  AdminAlreadyExists = "error.admin.alreadyExists",
31
34
  AdminDoesNotExists = "error.admin.notExists",
32
35
  FederationErrorMailerSend = "error.federation.mailNotSent",
package/helpers/errors.js CHANGED
@@ -31,6 +31,9 @@ var HttpsErrorMessages;
31
31
  HttpsErrorMessages["InvalidAdminFederation"] = "error.federation.noAdmin";
32
32
  HttpsErrorMessages["InvalidFederation"] = "error.federation.noActive";
33
33
  HttpsErrorMessages["InvalidInstrument"] = "error.instrument.noValid";
34
+ HttpsErrorMessages["InvalidCustomer"] = "error.customer.noValid";
35
+ HttpsErrorMessages["InvalidCustomerGroup"] = "error.customerGroup.noValid";
36
+ HttpsErrorMessages["InvalidCustomerAdmin"] = "error.customer.noAdmin";
34
37
  HttpsErrorMessages["AdminAlreadyExists"] = "error.admin.alreadyExists";
35
38
  HttpsErrorMessages["AdminDoesNotExists"] = "error.admin.notExists";
36
39
  HttpsErrorMessages["FederationErrorMailerSend"] = "error.federation.mailNotSent";
@@ -1,5 +1,5 @@
1
- export declare const mapToArray: <V>(obj: Record<string, V>) => (V & {
2
- id: string;
1
+ export declare const mapToArray: <K extends string, V, O extends Record<K, V>>(obj: O) => (O[`${Exclude<keyof O, symbol>}`] & {
2
+ id: keyof O;
3
3
  })[];
4
4
  export declare const map: <KIn extends string, VIn, KOut extends string, VOut>(obj: Record<KIn, VIn>, fn: (key: `${KIn}`, value: VIn, index?: number) => [KOut, VOut]) => Record<KOut, VOut>;
5
5
  export declare const filter: <K extends string, V>(obj: Record<K, V>, fn: (key: `${Exclude<K, symbol>}`, value: V, index?: number) => unknown) => Record<`${Exclude<K, symbol>}`, V>;
@@ -0,0 +1,19 @@
1
+ import { PlansGroup } from '../../../helpers/plans';
2
+ import { LanguagesTypes } from '../../../lang';
3
+ import { DocumentSnapshot } from '../../../types/firestore';
4
+ import GroupBasic from '../../Group/basic';
5
+ import { CustomerGroupData } from './types';
6
+ export default class CustomerGroup extends GroupBasic<CustomerGroupData> {
7
+ constructor(doc: DocumentSnapshot, lang?: LanguagesTypes);
8
+ get linkedAt(): import("../../../types/firestore").Timestamp;
9
+ get linkedBy(): import("../../../types/firestore").DocumentReference<import("../../../types/firestore").DocumentData>;
10
+ get upgradedAt(): import("../../../types/firestore").Timestamp | null;
11
+ get upgradedBy(): import("../../../types/firestore").DocumentReference<import("../../../types/firestore").DocumentData> | null;
12
+ get upgradedMethod(): string | null;
13
+ get planId(): PlansGroup;
14
+ get planPeriod(): import("../../../helpers/plans").PlanPeriod | null;
15
+ get planDiscount(): string | null;
16
+ get planStripeId(): string | null;
17
+ get subscriptionStripeId(): string | null;
18
+ get customerId(): string;
19
+ }
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const get_1 = __importDefault(require("lodash/get"));
7
+ const plans_1 = require("../../../helpers/plans");
8
+ const lang_1 = require("../../../lang");
9
+ const basic_1 = __importDefault(require("../../Group/basic"));
10
+ class CustomerGroup extends basic_1.default {
11
+ constructor(doc, lang = lang_1.defaultLocale) {
12
+ super(doc, lang);
13
+ }
14
+ get linkedAt() {
15
+ return this.data.linkedAt;
16
+ }
17
+ get linkedBy() {
18
+ return this.data.linkedBy;
19
+ }
20
+ get upgradedAt() {
21
+ return this.data.upgradedAt || null;
22
+ }
23
+ get upgradedBy() {
24
+ return this.data.upgradedBy || null;
25
+ }
26
+ get upgradedMethod() {
27
+ return this.data.upgradedMethod || null;
28
+ }
29
+ get planId() {
30
+ return this.data.planId || plans_1.PlansGroup.Piano;
31
+ }
32
+ get planPeriod() {
33
+ return this.data.planPeriod || null;
34
+ }
35
+ get planDiscount() {
36
+ return this.data.planDiscount || null;
37
+ }
38
+ get planStripeId() {
39
+ return this.data.planStripeId || null;
40
+ }
41
+ get subscriptionStripeId() {
42
+ return this.data.subscriptionStripeId || null;
43
+ }
44
+ get customerId() {
45
+ return (0, get_1.default)(this.ref, ['parent', 'parent', 'id']);
46
+ }
47
+ }
48
+ exports.default = CustomerGroup;
@@ -0,0 +1,15 @@
1
+ import { PlanPeriod, PlansGroup } from '../../../helpers/plans';
2
+ import { DocumentReference, Timestamp } from '../../../types/firestore';
3
+ import { GroupBasicData } from '../../Group/types';
4
+ export interface CustomerGroupData extends GroupBasicData {
5
+ upgradedAt: Timestamp | null;
6
+ upgradedBy: DocumentReference | null;
7
+ upgradedMethod: string | null;
8
+ planId: PlansGroup;
9
+ planPeriod: PlanPeriod | null;
10
+ planDiscount: string | null;
11
+ planStripeId: string | null;
12
+ subscriptionStripeId: string | null;
13
+ readonly linkedBy: DocumentReference;
14
+ readonly linkedAt: Timestamp;
15
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,14 @@
1
+ import { DocumentSnapshot } from '../../types/firestore';
2
+ import Model from '../Model';
3
+ import { CustomerBasicData } from './types';
4
+ export default class CustomerBasic<D> extends Model<D & CustomerBasicData> {
5
+ constructor(doc: DocumentSnapshot);
6
+ get basicInfo(): CustomerBasicData;
7
+ get displayName(): string;
8
+ get email(): string;
9
+ get address(): import("../Partner/types").BasicAddressData;
10
+ get displayAddress(): string;
11
+ get phone(): string | null;
12
+ get groupIds(): string[];
13
+ get CIF(): string | null;
14
+ }
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const lodash_1 = require("lodash");
7
+ const Model_1 = __importDefault(require("../Model"));
8
+ class CustomerBasic extends Model_1.default {
9
+ constructor(doc) {
10
+ super(doc);
11
+ }
12
+ get basicInfo() {
13
+ return {
14
+ displayName: this.displayName,
15
+ email: this.email,
16
+ phone: this.phone,
17
+ address: this.address,
18
+ CIF: this.CIF,
19
+ groupIds: this.groupIds,
20
+ };
21
+ }
22
+ get displayName() {
23
+ return this.data.displayName;
24
+ }
25
+ get email() {
26
+ return this.data.email;
27
+ }
28
+ get address() {
29
+ return this.data.address || {};
30
+ }
31
+ get displayAddress() {
32
+ const { street, city, postalCode, province, country } = this.address;
33
+ const fields = [street, postalCode, city, province, country];
34
+ return fields.filter((field) => (0, lodash_1.isString)(field)).join(', ');
35
+ }
36
+ get phone() {
37
+ return this.data.phone;
38
+ }
39
+ get groupIds() {
40
+ return this.data.groupIds || [];
41
+ }
42
+ get CIF() {
43
+ return this.data.CIF || null;
44
+ }
45
+ }
46
+ exports.default = CustomerBasic;
@@ -0,0 +1,24 @@
1
+ import { AdminItemStatus } from '../../helpers/types';
2
+ import { DocumentSnapshot } from '../../types/firestore';
3
+ import CustomerBasic from './basic';
4
+ import { CustomerData } from './types';
5
+ export default class Customer extends CustomerBasic<CustomerData> {
6
+ constructor(doc: DocumentSnapshot);
7
+ get admins(): string[];
8
+ get adminList(): import("../../helpers/types").AdminItem[];
9
+ adminListByStatus(status: AdminItemStatus): import("../../helpers/types").AdminItem[];
10
+ isAdmin(userId: string): boolean;
11
+ get createdAt(): import("../../types/firestore").Timestamp;
12
+ private get deletedAt();
13
+ get isDeleted(): boolean;
14
+ get isActive(): boolean;
15
+ get gocardlessId(): string | null;
16
+ get stripeId(): string | null;
17
+ get stripeTaxIds(): {
18
+ type: string;
19
+ value: string;
20
+ }[];
21
+ get howDidYouHearAboutUs(): string | null;
22
+ get groupIds(): string[];
23
+ get glissandooAdminUrl(): string;
24
+ }
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const collections_1 = require("../../helpers/collections");
7
+ const glissandooAdmin_1 = require("../../helpers/glissandooAdmin");
8
+ const basic_1 = __importDefault(require("./basic"));
9
+ class Customer extends basic_1.default {
10
+ constructor(doc) {
11
+ super(doc);
12
+ }
13
+ get admins() {
14
+ return this.data.administrators || [];
15
+ }
16
+ get adminList() {
17
+ return this.data.administratorsList || [];
18
+ }
19
+ adminListByStatus(status) {
20
+ return this.adminList.filter((item) => item.status === status);
21
+ }
22
+ isAdmin(userId) {
23
+ return this.admins.includes(userId);
24
+ }
25
+ get createdAt() {
26
+ return this.data.createdAt;
27
+ }
28
+ get deletedAt() {
29
+ return this.data.deletedAt || null;
30
+ }
31
+ get isDeleted() {
32
+ return this.deletedAt !== null;
33
+ }
34
+ get isActive() {
35
+ return this.exists && !this.deletedAt;
36
+ }
37
+ get gocardlessId() {
38
+ return this.data.gocardlessId || null;
39
+ }
40
+ get stripeId() {
41
+ return this.data.stripeId || null;
42
+ }
43
+ get stripeTaxIds() {
44
+ return this.data.stripeTaxIds || [];
45
+ }
46
+ get howDidYouHearAboutUs() {
47
+ return this.data.howDidYouHearAboutUs || null;
48
+ }
49
+ get groupIds() {
50
+ return this.data.groupIds || [];
51
+ }
52
+ get glissandooAdminUrl() {
53
+ return (0, glissandooAdmin_1.getGlissandooAdminEntityURL)(collections_1.CollectionNames.Partnership, this.id);
54
+ }
55
+ }
56
+ exports.default = Customer;
@@ -0,0 +1,28 @@
1
+ import { AdminItem } from '../../helpers/types';
2
+ import { DocumentReference, Timestamp } from '../../types/firestore';
3
+ import { BasicAddressData } from '../Partner/types';
4
+ export declare enum CustomerRoles {
5
+ Admin = "admin"
6
+ }
7
+ export interface CustomerBasicData {
8
+ displayName: string;
9
+ email: string;
10
+ phone: string | null;
11
+ address: BasicAddressData;
12
+ CIF: string | null;
13
+ groupIds: string[];
14
+ }
15
+ export interface CustomerData extends CustomerBasicData {
16
+ administrators: string[];
17
+ administratorsList: AdminItem[];
18
+ deletedAt: Timestamp | null;
19
+ gocardlessId: string | null;
20
+ stripeId: string | null;
21
+ stripeTaxIds: {
22
+ type: string;
23
+ value: string;
24
+ }[];
25
+ howDidYouHearAboutUs: string | null;
26
+ readonly createdAt: Timestamp;
27
+ readonly createdBy: DocumentReference;
28
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CustomerRoles = void 0;
4
+ var CustomerRoles;
5
+ (function (CustomerRoles) {
6
+ CustomerRoles["Admin"] = "admin";
7
+ })(CustomerRoles = exports.CustomerRoles || (exports.CustomerRoles = {}));
@@ -38,6 +38,7 @@ export default class Group extends GroupBasic<GroupData> {
38
38
  get isDeleted(): boolean;
39
39
  get intercomId(): string | null;
40
40
  get partnershipId(): string | null;
41
+ get customerId(): string | null;
41
42
  get socialNetworks(): Record<SocialNetwork, string | null>;
42
43
  getSocialNetworkUrl(id: SocialNetwork): string | null;
43
44
  get config(): Record<import("./types").GroupConfig, boolean>;
@@ -69,4 +70,8 @@ export default class Group extends GroupBasic<GroupData> {
69
70
  get trialEndAt(): Date;
70
71
  get glissandooAdminUrl(): string;
71
72
  get createdOn(): import("./types").GroupCreatedOn;
73
+ get instruments(): Partial<Record<import("../../helpers/instruments").InstrumentId, import("./types").GroupInstrument>>;
74
+ get instrumentsList(): (import("./types").GroupInstrument & {
75
+ id: import("../../helpers/instruments").InstrumentId;
76
+ })[];
72
77
  }
@@ -111,6 +111,9 @@ class Group extends basic_1.default {
111
111
  get partnershipId() {
112
112
  return this.data.partnershipId || null;
113
113
  }
114
+ get customerId() {
115
+ return this.data.customerId || null;
116
+ }
114
117
  get socialNetworks() {
115
118
  if (this.data.socialNetworks) {
116
119
  return this.data.socialNetworks;
@@ -188,5 +191,11 @@ class Group extends basic_1.default {
188
191
  get createdOn() {
189
192
  return this.data.createdOn;
190
193
  }
194
+ get instruments() {
195
+ return this.data.instruments;
196
+ }
197
+ get instrumentsList() {
198
+ return (0, objects_1.mapToArray)(this.instruments).sort((a, b) => a.order - b.order);
199
+ }
191
200
  }
192
201
  exports.default = Group;
@@ -1,3 +1,4 @@
1
+ import { InstrumentId } from '../../helpers/instruments';
1
2
  import { MusicStyleType } from '../../helpers/musicStyles';
2
3
  import { PlansGroup } from '../../helpers/plans';
3
4
  import { StageTemplate } from '../../helpers/types';
@@ -85,6 +86,12 @@ export interface GroupRepertoireTag {
85
86
  export interface AGroupRepertoireTag extends GroupRepertoireTag {
86
87
  id: string;
87
88
  }
89
+ export interface GroupInstrument {
90
+ order: number;
91
+ }
92
+ export interface AGroupInstrument extends GroupInstrument {
93
+ id: InstrumentId;
94
+ }
88
95
  export interface GroupData extends GroupBasicData {
89
96
  playerIds: string[];
90
97
  players: Record<string, PlayerBasicData>;
@@ -107,11 +114,13 @@ export interface GroupData extends GroupBasicData {
107
114
  status: GroupStatus;
108
115
  planId: PlansGroup;
109
116
  partnershipId: string | null;
117
+ customerId: string | null;
110
118
  repertoryCount: number;
111
119
  eventCount: Record<EventType, number>;
112
120
  communicationCount: number;
113
121
  country: string;
114
122
  stageTemplates: Record<string, StageTemplate>;
123
+ instruments: Partial<Record<InstrumentId, GroupInstrument>>;
115
124
  metadata: Record<string, string>;
116
125
  firstAnswerAt: Timestamp | null;
117
126
  repertoireTags: Record<string, GroupRepertoireTag>;
@@ -1,6 +1,6 @@
1
1
  import { CollectionNames } from '../../helpers/collections';
2
2
  import { Timestamp } from '../../types/firestore';
3
- export type AllowCollections = CollectionNames.User | CollectionNames.Group | CollectionNames.Event | CollectionNames.Communication | CollectionNames.GroupRepertory | CollectionNames.Partner | CollectionNames.Partnership;
3
+ export type AllowCollections = CollectionNames.User | CollectionNames.Group | CollectionNames.Event | CollectionNames.Communication | CollectionNames.GroupRepertory | CollectionNames.Partner | CollectionNames.Partnership | CollectionNames.Customer;
4
4
  export interface EntityTypes {
5
5
  total: number;
6
6
  acc: number;
@@ -7,13 +7,21 @@ export default class PartnershipGroup extends GroupBasic<PartnershipGroupData> {
7
7
  constructor(doc: DocumentSnapshot, lang?: LanguagesTypes);
8
8
  get linkedAt(): import("../../../types/firestore").Timestamp;
9
9
  get linkedBy(): import("../../../types/firestore").DocumentReference<import("../../../types/firestore").DocumentData>;
10
+ /** @deprecated use customer */
10
11
  get upgradedAt(): import("../../../types/firestore").Timestamp | null;
12
+ /** @deprecated use customer */
11
13
  get upgradedBy(): import("../../../types/firestore").DocumentReference<import("../../../types/firestore").DocumentData> | null;
14
+ /** @deprecated use customer */
12
15
  get upgradedMethod(): string | null;
16
+ /** @deprecated use customer */
13
17
  get planId(): PlansGroup;
18
+ /** @deprecated use customer */
14
19
  get planPeriod(): import("../../../helpers/plans").PlanPeriod | null;
20
+ /** @deprecated use customer */
15
21
  get planDiscount(): string | null;
22
+ /** @deprecated use customer */
16
23
  get planStripeId(): string | null;
24
+ /** @deprecated use customer */
17
25
  get subscriptionStripeId(): string | null;
18
26
  get partnershipId(): string;
19
27
  }
@@ -17,27 +17,35 @@ class PartnershipGroup extends basic_1.default {
17
17
  get linkedBy() {
18
18
  return this.data.linkedBy;
19
19
  }
20
+ /** @deprecated use customer */
20
21
  get upgradedAt() {
21
22
  return this.data.upgradedAt || null;
22
23
  }
24
+ /** @deprecated use customer */
23
25
  get upgradedBy() {
24
26
  return this.data.upgradedBy || null;
25
27
  }
28
+ /** @deprecated use customer */
26
29
  get upgradedMethod() {
27
30
  return this.data.upgradedMethod || null;
28
31
  }
32
+ /** @deprecated use customer */
29
33
  get planId() {
30
34
  return this.data.planId || plans_1.PlansGroup.Piano;
31
35
  }
36
+ /** @deprecated use customer */
32
37
  get planPeriod() {
33
38
  return this.data.planPeriod || null;
34
39
  }
40
+ /** @deprecated use customer */
35
41
  get planDiscount() {
36
42
  return this.data.planDiscount || null;
37
43
  }
44
+ /** @deprecated use customer */
38
45
  get planStripeId() {
39
46
  return this.data.planStripeId || null;
40
47
  }
48
+ /** @deprecated use customer */
41
49
  get subscriptionStripeId() {
42
50
  return this.data.subscriptionStripeId || null;
43
51
  }
@@ -2,13 +2,21 @@ import { PlanPeriod, PlansGroup } from '../../../helpers/plans';
2
2
  import { DocumentReference, Timestamp } from '../../../types/firestore';
3
3
  import { GroupBasicData } from '../../Group/types';
4
4
  export interface PartnershipGroupData extends GroupBasicData {
5
+ /** @deprecated use customer */
5
6
  upgradedAt: Timestamp | null;
7
+ /** @deprecated use customer */
6
8
  upgradedBy: DocumentReference | null;
9
+ /** @deprecated use customer */
7
10
  upgradedMethod: string | null;
11
+ /** @deprecated use customer */
8
12
  planId: PlansGroup;
13
+ /** @deprecated use customer */
9
14
  planPeriod: PlanPeriod | null;
15
+ /** @deprecated use customer */
10
16
  planDiscount: string | null;
17
+ /** @deprecated use customer */
11
18
  planStripeId: string | null;
19
+ /** @deprecated use customer */
12
20
  subscriptionStripeId: string | null;
13
21
  readonly linkedBy: DocumentReference;
14
22
  readonly linkedAt: Timestamp;
@@ -10,16 +10,21 @@ export default class Partnership extends PartnershipBasic<PartnershipData> {
10
10
  adminListByStatus(status: AdminItemStatus): import("../../helpers/types").AdminItem[];
11
11
  isAdmin(userId: string): boolean;
12
12
  get createdAt(): import("../../types/firestore").Timestamp;
13
- private get deletedAt();
13
+ get createdBy(): import("../../types/firestore").DocumentReference<import("../../types/firestore").DocumentData>;
14
+ get deletedAt(): import("../../types/firestore").Timestamp | null;
14
15
  get isDeleted(): boolean;
15
16
  get isActive(): boolean;
16
17
  get federationIds(): string[];
18
+ /** @deprecated use customer */
17
19
  get gocardlessCustomerId(): string | null;
20
+ /** @deprecated use customer */
18
21
  get stripeCustomerId(): string | null;
22
+ /** @deprecated use customer */
19
23
  get stripeTaxIds(): {
20
24
  type: string;
21
25
  value: string;
22
26
  }[];
27
+ /** @deprecated use customer */
23
28
  get howDidYouHearAboutUs(): string | null;
24
29
  get groupIds(): string[];
25
30
  get glissandooAdminUrl(): string;
@@ -28,6 +28,9 @@ class Partnership extends basic_1.default {
28
28
  get createdAt() {
29
29
  return this.data.createdAt;
30
30
  }
31
+ get createdBy() {
32
+ return this.data.createdBy;
33
+ }
31
34
  get deletedAt() {
32
35
  return this.data.deletedAt || null;
33
36
  }
@@ -40,15 +43,19 @@ class Partnership extends basic_1.default {
40
43
  get federationIds() {
41
44
  return this.data.federationIds || [];
42
45
  }
46
+ /** @deprecated use customer */
43
47
  get gocardlessCustomerId() {
44
48
  return this.data.gocardlessCustomerId || null;
45
49
  }
50
+ /** @deprecated use customer */
46
51
  get stripeCustomerId() {
47
52
  return this.data.stripeCustomerId || null;
48
53
  }
54
+ /** @deprecated use customer */
49
55
  get stripeTaxIds() {
50
56
  return this.data.stripeTaxIds || [];
51
57
  }
58
+ /** @deprecated use customer */
52
59
  get howDidYouHearAboutUs() {
53
60
  return this.data.howDidYouHearAboutUs || null;
54
61
  }
@@ -35,12 +35,16 @@ export interface PartnershipData extends PartnershipBasicData {
35
35
  administratorsList: AdminItem[];
36
36
  deletedAt: Timestamp | null;
37
37
  federationIds: string[];
38
+ /** @deprecated use customer */
38
39
  gocardlessCustomerId: string | null;
40
+ /** @deprecated use customer */
39
41
  stripeCustomerId: string | null;
42
+ /** @deprecated use customer */
40
43
  stripeTaxIds: {
41
44
  type: string;
42
45
  value: string;
43
46
  }[];
47
+ /** @deprecated use customer */
44
48
  howDidYouHearAboutUs: string | null;
45
49
  readonly createdAt: Timestamp;
46
50
  readonly createdBy: DocumentReference;
@@ -41,4 +41,5 @@ export default class User extends UserBasic<UserData> {
41
41
  get registerVia(): import("./types").UserRegisterVia;
42
42
  get lastAppLoginAt(): import("../../types/firestore").Timestamp | null;
43
43
  get glissandooAdminUrl(): string;
44
+ get customerIds(): string[];
44
45
  }
@@ -116,5 +116,8 @@ class User extends basic_1.default {
116
116
  get glissandooAdminUrl() {
117
117
  return (0, glissandooAdmin_1.getGlissandooAdminEntityURL)(collections_1.CollectionNames.User, this.id);
118
118
  }
119
+ get customerIds() {
120
+ return this.data.customerIds || [];
121
+ }
119
122
  }
120
123
  exports.default = User;
@@ -26,15 +26,6 @@ export declare enum UserEventsFilter {
26
26
  Annual = 12,
27
27
  Always = 1000
28
28
  }
29
- export interface DeviceInfo {
30
- app_name: string | null;
31
- app_version: string | null;
32
- device: string | null;
33
- os_name: string | null;
34
- os_version: string | null;
35
- is_tablet: boolean;
36
- last_seen_at: Timestamp;
37
- }
38
29
  export interface UserTinyData {
39
30
  displayName: string;
40
31
  photoURL: string;
@@ -61,6 +52,7 @@ export interface UserData extends UserBasicData {
61
52
  deletedAt: Timestamp | null;
62
53
  partnershipIds: string[];
63
54
  federationId: string | null;
55
+ customerIds: string[];
64
56
  groups: string[];
65
57
  groups_admin: string[];
66
58
  birthDate: Timestamp | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glissandoo/lib",
3
- "version": "1.40.2",
3
+ "version": "1.42.0",
4
4
  "description": "Glissandoo library js",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",