@glissandoo/lib 1.98.0 → 1.100.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.
@@ -1,18 +1,20 @@
1
- import { PlanScheduleType } from '../models/Partnership/Plan/types';
1
+ import { PaymentMethod, PlanScheduleType } from '../models/Partnership/Plan/types';
2
2
  export declare namespace PartnershipPlanFbFunctionsTypes {
3
- interface AddParams {
4
- partnershipId: string;
3
+ interface CreateData {
5
4
  name: string;
6
- price: number;
7
5
  description: string;
6
+ price: number;
8
7
  schedule: PlanScheduleType;
8
+ paymentMethod: PaymentMethod;
9
9
  }
10
- type AddResult = void;
11
- interface EditParams {
10
+ interface CreateParams extends CreateData {
11
+ partnershipId: string;
12
+ planId: string;
13
+ }
14
+ type CreateResult = void;
15
+ interface EditParams extends Partial<CreateData> {
12
16
  partnershipId: string;
13
17
  planId: string;
14
- name: string;
15
- description: string;
16
18
  }
17
19
  type EditResult = void;
18
20
  type RemoveParams = {
@@ -0,0 +1,23 @@
1
+ export declare namespace PartnershipSubscriptionFbFunctionsTypes {
2
+ interface CreateData {
3
+ planId: string;
4
+ partnerId: string;
5
+ endDate: number | null;
6
+ }
7
+ interface CreateParams extends CreateData {
8
+ partnershipId: string;
9
+ subscriptionId: string;
10
+ }
11
+ type CreateResult = void;
12
+ interface EditParams {
13
+ partnershipId: string;
14
+ subscriptionId: string;
15
+ endDate: number | null;
16
+ }
17
+ type EditResult = void;
18
+ type RemoveParams = {
19
+ partnershipId: string;
20
+ subscriptionId: string;
21
+ };
22
+ type RemoveResult = void;
23
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -24,6 +24,7 @@ export declare enum HttpsErrorMessages {
24
24
  InvalidOffer = "error.offer.noValid",
25
25
  InvalidPartnership = "error.partnership.noValid",
26
26
  InvalidPartnershipPartner = "error.partner.noValid",
27
+ PartnershipPartnerNotSelf = "error.partner.notSelf",
27
28
  InvalidPartnershipPlan = "error.partnershipPlan.noValid",
28
29
  PartnershipPlanWithSubscriptions = "error.partnershipPlan.withSubscriptions",
29
30
  InvalidPartnershipSubscription = "error.partnershipSubscription.noValid",
package/helpers/errors.js CHANGED
@@ -25,6 +25,7 @@ var HttpsErrorMessages;
25
25
  HttpsErrorMessages["InvalidOffer"] = "error.offer.noValid";
26
26
  HttpsErrorMessages["InvalidPartnership"] = "error.partnership.noValid";
27
27
  HttpsErrorMessages["InvalidPartnershipPartner"] = "error.partner.noValid";
28
+ HttpsErrorMessages["PartnershipPartnerNotSelf"] = "error.partner.notSelf";
28
29
  HttpsErrorMessages["InvalidPartnershipPlan"] = "error.partnershipPlan.noValid";
29
30
  HttpsErrorMessages["PartnershipPlanWithSubscriptions"] = "error.partnershipPlan.withSubscriptions";
30
31
  HttpsErrorMessages["InvalidPartnershipSubscription"] = "error.partnershipSubscription.noValid";
@@ -12,9 +12,11 @@ export default class PartnershipPlan extends ModelWithLang<PartnershipPlanData>
12
12
  get price(): number;
13
13
  get displayPrice(): string;
14
14
  get schedule(): import("./types").PlanScheduleType;
15
- get paymentMethod(): import("./types").PaymentMethod;
16
15
  get isAnnuallySchedule(): boolean;
17
16
  get isPaymentDayEndOfMonth(): boolean;
17
+ get paymentMethod(): import("./types").PaymentMethod;
18
+ get subscriptionsCount(): number;
19
+ get hasSubscriptions(): boolean;
18
20
  get createdAt(): FirebaseFirestore.Timestamp;
19
21
  get createdBy(): string;
20
22
  get editedAt(): FirebaseFirestore.Timestamp | null;
@@ -47,15 +47,21 @@ class PartnershipPlan extends lang_1.default {
47
47
  get schedule() {
48
48
  return this.data.schedule;
49
49
  }
50
- get paymentMethod() {
51
- return this.data.paymentMethod;
52
- }
53
50
  get isAnnuallySchedule() {
54
51
  return this.schedule.periodInMonths === 12;
55
52
  }
56
53
  get isPaymentDayEndOfMonth() {
57
54
  return this.schedule.paymentDay === -1;
58
55
  }
56
+ get paymentMethod() {
57
+ return this.data.paymentMethod;
58
+ }
59
+ get subscriptionsCount() {
60
+ return this.data.subscriptionsCount || 0;
61
+ }
62
+ get hasSubscriptions() {
63
+ return this.subscriptionsCount > 0;
64
+ }
59
65
  get createdAt() {
60
66
  return this.data.createdAt;
61
67
  }
@@ -13,6 +13,7 @@ export interface PartnershipPlanData {
13
13
  price: number;
14
14
  schedule: PlanScheduleType;
15
15
  paymentMethod: PaymentMethod;
16
+ subscriptionsCount: number;
16
17
  createdAt: Timestamp;
17
18
  createdBy: string;
18
19
  editedAt: Timestamp | null;
@@ -1,9 +1,10 @@
1
1
  import Model from '../../Model';
2
- import { SubscriptionData } from './types';
3
- export default class PartnerSubscription extends Model<SubscriptionData> {
2
+ import { PartnershipSubscriptionData } from './types';
3
+ export default class PartnershipSubscription extends Model<PartnershipSubscriptionData> {
4
+ get partnershipId(): string;
4
5
  get planId(): string;
5
6
  get partnerId(): string;
6
- get partnershipId(): string;
7
+ get endDate(): FirebaseFirestore.Timestamp | null;
7
8
  get createdAt(): FirebaseFirestore.Timestamp;
8
9
  get createdBy(): string;
9
10
  get editedAt(): FirebaseFirestore.Timestamp | null;
@@ -5,15 +5,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const utils_1 = require("../../../helpers/utils");
7
7
  const Model_1 = __importDefault(require("../../Model"));
8
- class PartnerSubscription extends Model_1.default {
8
+ class PartnershipSubscription extends Model_1.default {
9
+ get partnershipId() {
10
+ return (0, utils_1.at)(this.ref.path.split('/'), 1) || '';
11
+ }
9
12
  get planId() {
10
13
  return this.data.planId;
11
14
  }
12
15
  get partnerId() {
13
16
  return this.data.partnerId;
14
17
  }
15
- get partnershipId() {
16
- return (0, utils_1.at)(this.ref.path.split('/'), 1) || '';
18
+ get endDate() {
19
+ return this.data.endDate || null;
17
20
  }
18
21
  get createdAt() {
19
22
  return this.data.createdAt;
@@ -40,4 +43,4 @@ class PartnerSubscription extends Model_1.default {
40
43
  return this.exists && !this.data.deletedAt;
41
44
  }
42
45
  }
43
- exports.default = PartnerSubscription;
46
+ exports.default = PartnershipSubscription;
@@ -1,5 +1,5 @@
1
1
  import { Timestamp } from '@google-cloud/firestore';
2
- export interface SubscriptionData {
2
+ export interface PartnershipSubscriptionData {
3
3
  planId: string;
4
4
  partnerId: string;
5
5
  endDate: Timestamp | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glissandoo/lib",
3
- "version": "1.98.0",
3
+ "version": "1.100.0",
4
4
  "description": "Glissandoo library js",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",