vr-models 1.0.46 → 1.0.48

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.
@@ -4,9 +4,9 @@ import type { DevicePaymentPlan } from "./devicePaymentPlan.models";
4
4
  import type { Transaction } from "./transaction.models";
5
5
  import type { IdempotencyRecord } from "./idempotencyRecord.models";
6
6
  export type PaymentProvider = "mtn_momo" | "airtel_money";
7
- export type PaymentStatus = "pending" | "succeeded" | "failed";
7
+ export type PaymentStatus = "PENDING" | "SUCCESSFUL" | "FAILED";
8
8
  export declare const PAYMENT_PROVIDER: readonly ["mtn_momo", "airtel_money"];
9
- export declare const PAYMENT_STATUS: readonly ["pending", "succeeded", "failed"];
9
+ export declare const PAYMENT_STATUS: readonly ["PENDING", "SUCCESSFUL", "FAILED"];
10
10
  export interface PaymentAttributes {
11
11
  id: string;
12
12
  userId: string;
@@ -42,7 +42,7 @@ export declare class Payment extends Model<InferAttributes<Payment>, InferCreati
42
42
  amount: number;
43
43
  provider: PaymentProvider;
44
44
  providerReference: CreationOptional<string | null>;
45
- status: CreationOptional<PaymentStatus>;
45
+ status: PaymentStatus;
46
46
  metadata: CreationOptional<Record<string, any>>;
47
47
  readonly createdAt: CreationOptional<Date>;
48
48
  readonly updatedAt: CreationOptional<Date>;
@@ -4,7 +4,7 @@ exports.Payment = exports.PAYMENT_STATUS = exports.PAYMENT_PROVIDER = void 0;
4
4
  const vr_migrations_1 = require("vr-migrations");
5
5
  // TYPES AS CONSTANTS
6
6
  exports.PAYMENT_PROVIDER = ["mtn_momo", "airtel_money"];
7
- exports.PAYMENT_STATUS = ["pending", "succeeded", "failed"];
7
+ exports.PAYMENT_STATUS = ["PENDING", "SUCCESSFUL", "FAILED"];
8
8
  class Payment extends vr_migrations_1.Model {
9
9
  // Static initialization method
10
10
  static initialize(sequelize) {
@@ -29,9 +29,9 @@ class Payment extends vr_migrations_1.Model {
29
29
  },
30
30
  providerReference: { type: vr_migrations_1.DataTypes.STRING, allowNull: true },
31
31
  status: {
32
- type: vr_migrations_1.DataTypes.ENUM("pending", "succeeded", "failed"),
32
+ type: vr_migrations_1.DataTypes.ENUM("PENDING", "SUCCESSFUL", "FAILED"),
33
33
  allowNull: false,
34
- defaultValue: "pending",
34
+ defaultValue: "PENDING",
35
35
  },
36
36
  metadata: {
37
37
  type: vr_migrations_1.DataTypes.JSONB,
@@ -46,7 +46,7 @@ class Payment extends vr_migrations_1.Model {
46
46
  modelName: "Payment",
47
47
  hooks: {
48
48
  beforeUpdate: (payment) => {
49
- if (payment.status === "succeeded" && !payment.providerReference) {
49
+ if (payment.status === "SUCCESSFUL" && !payment.providerReference) {
50
50
  throw new Error("providerReference is required for successful payments");
51
51
  }
52
52
  },
@@ -82,7 +82,7 @@ class Payment extends vr_migrations_1.Model {
82
82
  }
83
83
  // Custom instance methods
84
84
  async markAsSucceeded(providerReference, metadata) {
85
- this.status = "succeeded";
85
+ this.status = "SUCCESSFUL";
86
86
  this.providerReference = providerReference;
87
87
  if (metadata) {
88
88
  this.metadata = { ...this.metadata, ...metadata };
@@ -90,7 +90,7 @@ class Payment extends vr_migrations_1.Model {
90
90
  await this.save();
91
91
  }
92
92
  async markAsFailed(reason, metadata) {
93
- this.status = "failed";
93
+ this.status = "FAILED";
94
94
  const failureMetadata = {
95
95
  failureReason: reason,
96
96
  failedAt: new Date().toISOString(),
@@ -107,13 +107,13 @@ class Payment extends vr_migrations_1.Model {
107
107
  await this.save();
108
108
  }
109
109
  isSuccessful() {
110
- return this.status === "succeeded";
110
+ return this.status === "SUCCESSFUL";
111
111
  }
112
112
  isPending() {
113
- return this.status === "pending";
113
+ return this.status === "PENDING";
114
114
  }
115
115
  isFailed() {
116
- return this.status === "failed";
116
+ return this.status === "FAILED";
117
117
  }
118
118
  getProviderDisplayName() {
119
119
  switch (this.provider) {
@@ -15,7 +15,7 @@ export interface PhoneContactAttributes {
15
15
  otpAttempts?: number;
16
16
  lastFailedAttemptAt?: Date;
17
17
  isLocked?: boolean;
18
- lockedUntil?: Date;
18
+ lockedUntil?: Date | null;
19
19
  carrier?: string;
20
20
  countryCode?: string;
21
21
  deactivatedAt?: Date | null;
@@ -44,7 +44,7 @@ export declare class PhoneContact extends Model<InferAttributes<PhoneContact>, I
44
44
  otpAttempts?: number;
45
45
  lastFailedAttemptAt?: Date;
46
46
  isLocked?: boolean;
47
- lockedUntil?: Date;
47
+ lockedUntil?: Date | null;
48
48
  carrier?: string;
49
49
  countryCode?: string;
50
50
  deactivatedAt?: Date | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vr-models",
3
- "version": "1.0.46",
3
+ "version": "1.0.48",
4
4
  "description": "Shared database models package for VR applications",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",