@amohamud23/notihub 1.1.36 → 1.1.38

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/dist/index.cjs CHANGED
@@ -1919,6 +1919,76 @@ var StripeSubscription = class _StripeSubscription {
1919
1919
  };
1920
1920
  var StripeSubscriptions_default = StripeSubscription;
1921
1921
 
1922
+ // src/DynamoModels/PaymentSession.ts
1923
+ var import_lib_dynamodb16 = require("@aws-sdk/lib-dynamodb");
1924
+ var PaymentSession = class _PaymentSession {
1925
+ static ENV = process.env.ENV || "dev";
1926
+ static TABLE_NAME = `NotiHub-PaymentSession-v1-${_PaymentSession.ENV}`;
1927
+ static async createPaymentSession(paymentSession) {
1928
+ const command = new import_lib_dynamodb16.PutCommand({
1929
+ TableName: _PaymentSession.TABLE_NAME,
1930
+ Item: paymentSession
1931
+ });
1932
+ try {
1933
+ await ddbDocClient.send(command);
1934
+ return paymentSession;
1935
+ } catch (error) {
1936
+ console.error("Error creating payment session:", error);
1937
+ throw new Error("Could not create payment session");
1938
+ }
1939
+ }
1940
+ static async getPaymentSessionById(id) {
1941
+ const command = new import_lib_dynamodb16.GetCommand({
1942
+ TableName: _PaymentSession.TABLE_NAME,
1943
+ Key: { id }
1944
+ });
1945
+ try {
1946
+ const result = await ddbDocClient.send(command);
1947
+ return result.Item || null;
1948
+ } catch (error) {
1949
+ console.error("Error fetching payment session:", error);
1950
+ throw new Error("Could not fetch payment session");
1951
+ }
1952
+ }
1953
+ static async updatePaymentSession(id, intent) {
1954
+ const command = new import_lib_dynamodb16.UpdateCommand({
1955
+ TableName: _PaymentSession.TABLE_NAME,
1956
+ Key: { id },
1957
+ UpdateExpression: "set #status = :status",
1958
+ ExpressionAttributeValues: {
1959
+ ":status": intent
1960
+ }
1961
+ });
1962
+ try {
1963
+ await ddbDocClient.send(command);
1964
+ } catch (error) {
1965
+ console.error("Error updating payment session:", error);
1966
+ throw new Error("Could not update payment session");
1967
+ }
1968
+ }
1969
+ static async getPaymentSessionBySessionId(sessionId) {
1970
+ const command = new import_lib_dynamodb16.QueryCommand({
1971
+ TableName: _PaymentSession.TABLE_NAME,
1972
+ IndexName: "SessionIdIndex",
1973
+ KeyConditionExpression: "session = :sessionId",
1974
+ ExpressionAttributeValues: {
1975
+ ":sessionId": sessionId
1976
+ }
1977
+ });
1978
+ try {
1979
+ const result = await ddbDocClient.send(command);
1980
+ if (!result.Items || result.Items.length === 0) {
1981
+ return null;
1982
+ }
1983
+ return result.Items[0] || null;
1984
+ } catch (error) {
1985
+ console.error("Error fetching payment session:", error);
1986
+ throw new Error("Could not fetch payment session");
1987
+ }
1988
+ }
1989
+ };
1990
+ var PaymentSession_default = PaymentSession;
1991
+
1922
1992
  // src/DynamoModels/index.ts
1923
1993
  var TABLES = {
1924
1994
  User: User_default,
@@ -1934,7 +2004,8 @@ var TABLES = {
1934
2004
  CustomerMinified: CustomerMinified_default,
1935
2005
  NotificationStats: NotificationStats_default,
1936
2006
  NotiHubStatsHistory: NotiHubStatsHistory_default,
1937
- StripeSubscription: StripeSubscriptions_default
2007
+ StripeSubscription: StripeSubscriptions_default,
2008
+ PaymentSession: PaymentSession_default
1938
2009
  };
1939
2010
 
1940
2011
  // src/errorcodes.ts
package/dist/index.d.cts CHANGED
@@ -207,6 +207,9 @@ type INotiHubPaymentSession = {
207
207
  id: string;
208
208
  session: string;
209
209
  customerId: string;
210
+ status: "PENDING" | "COMPLETED" | "FAILED";
211
+ createdAt: string;
212
+ updatedAt: string;
210
213
  };
211
214
  type NotiHubTypes = {
212
215
  INotiHubUserView: INotiHubUserView;
@@ -746,6 +749,15 @@ declare class StripeSubscription {
746
749
  static updateStripeSubscription(id: string, updates: Partial<INotiHubStripeSubscription>): Promise<INotiHubStripeSubscription>;
747
750
  }
748
751
 
752
+ declare class PaymentSession {
753
+ static ENV: string;
754
+ static TABLE_NAME: string;
755
+ static createPaymentSession(paymentSession: INotiHubPaymentSession): Promise<INotiHubPaymentSession>;
756
+ static getPaymentSessionById(id: string): Promise<INotiHubPaymentSession>;
757
+ static updatePaymentSession(id: string, intent: string): Promise<void>;
758
+ static getPaymentSessionBySessionId(sessionId: string): Promise<INotiHubPaymentSession | null>;
759
+ }
760
+
749
761
  declare const TABLES: {
750
762
  User: typeof User;
751
763
  Customer: typeof Customer;
@@ -761,6 +773,7 @@ declare const TABLES: {
761
773
  NotificationStats: typeof NotificationStats;
762
774
  NotiHubStatsHistory: typeof NotiHubStatsHistory;
763
775
  StripeSubscription: typeof StripeSubscription;
776
+ PaymentSession: typeof PaymentSession;
764
777
  };
765
778
 
766
779
  declare const DocumentNotFound = "4001";
package/dist/index.d.ts CHANGED
@@ -207,6 +207,9 @@ type INotiHubPaymentSession = {
207
207
  id: string;
208
208
  session: string;
209
209
  customerId: string;
210
+ status: "PENDING" | "COMPLETED" | "FAILED";
211
+ createdAt: string;
212
+ updatedAt: string;
210
213
  };
211
214
  type NotiHubTypes = {
212
215
  INotiHubUserView: INotiHubUserView;
@@ -746,6 +749,15 @@ declare class StripeSubscription {
746
749
  static updateStripeSubscription(id: string, updates: Partial<INotiHubStripeSubscription>): Promise<INotiHubStripeSubscription>;
747
750
  }
748
751
 
752
+ declare class PaymentSession {
753
+ static ENV: string;
754
+ static TABLE_NAME: string;
755
+ static createPaymentSession(paymentSession: INotiHubPaymentSession): Promise<INotiHubPaymentSession>;
756
+ static getPaymentSessionById(id: string): Promise<INotiHubPaymentSession>;
757
+ static updatePaymentSession(id: string, intent: string): Promise<void>;
758
+ static getPaymentSessionBySessionId(sessionId: string): Promise<INotiHubPaymentSession | null>;
759
+ }
760
+
749
761
  declare const TABLES: {
750
762
  User: typeof User;
751
763
  Customer: typeof Customer;
@@ -761,6 +773,7 @@ declare const TABLES: {
761
773
  NotificationStats: typeof NotificationStats;
762
774
  NotiHubStatsHistory: typeof NotiHubStatsHistory;
763
775
  StripeSubscription: typeof StripeSubscription;
776
+ PaymentSession: typeof PaymentSession;
764
777
  };
765
778
 
766
779
  declare const DocumentNotFound = "4001";
package/dist/index.js CHANGED
@@ -1949,6 +1949,81 @@ var StripeSubscription = class _StripeSubscription {
1949
1949
  };
1950
1950
  var StripeSubscriptions_default = StripeSubscription;
1951
1951
 
1952
+ // src/DynamoModels/PaymentSession.ts
1953
+ import {
1954
+ GetCommand as GetCommand14,
1955
+ PutCommand as PutCommand15,
1956
+ QueryCommand as QueryCommand14,
1957
+ UpdateCommand as UpdateCommand14
1958
+ } from "@aws-sdk/lib-dynamodb";
1959
+ var PaymentSession = class _PaymentSession {
1960
+ static ENV = process.env.ENV || "dev";
1961
+ static TABLE_NAME = `NotiHub-PaymentSession-v1-${_PaymentSession.ENV}`;
1962
+ static async createPaymentSession(paymentSession) {
1963
+ const command = new PutCommand15({
1964
+ TableName: _PaymentSession.TABLE_NAME,
1965
+ Item: paymentSession
1966
+ });
1967
+ try {
1968
+ await ddbDocClient.send(command);
1969
+ return paymentSession;
1970
+ } catch (error) {
1971
+ console.error("Error creating payment session:", error);
1972
+ throw new Error("Could not create payment session");
1973
+ }
1974
+ }
1975
+ static async getPaymentSessionById(id) {
1976
+ const command = new GetCommand14({
1977
+ TableName: _PaymentSession.TABLE_NAME,
1978
+ Key: { id }
1979
+ });
1980
+ try {
1981
+ const result = await ddbDocClient.send(command);
1982
+ return result.Item || null;
1983
+ } catch (error) {
1984
+ console.error("Error fetching payment session:", error);
1985
+ throw new Error("Could not fetch payment session");
1986
+ }
1987
+ }
1988
+ static async updatePaymentSession(id, intent) {
1989
+ const command = new UpdateCommand14({
1990
+ TableName: _PaymentSession.TABLE_NAME,
1991
+ Key: { id },
1992
+ UpdateExpression: "set #status = :status",
1993
+ ExpressionAttributeValues: {
1994
+ ":status": intent
1995
+ }
1996
+ });
1997
+ try {
1998
+ await ddbDocClient.send(command);
1999
+ } catch (error) {
2000
+ console.error("Error updating payment session:", error);
2001
+ throw new Error("Could not update payment session");
2002
+ }
2003
+ }
2004
+ static async getPaymentSessionBySessionId(sessionId) {
2005
+ const command = new QueryCommand14({
2006
+ TableName: _PaymentSession.TABLE_NAME,
2007
+ IndexName: "SessionIdIndex",
2008
+ KeyConditionExpression: "session = :sessionId",
2009
+ ExpressionAttributeValues: {
2010
+ ":sessionId": sessionId
2011
+ }
2012
+ });
2013
+ try {
2014
+ const result = await ddbDocClient.send(command);
2015
+ if (!result.Items || result.Items.length === 0) {
2016
+ return null;
2017
+ }
2018
+ return result.Items[0] || null;
2019
+ } catch (error) {
2020
+ console.error("Error fetching payment session:", error);
2021
+ throw new Error("Could not fetch payment session");
2022
+ }
2023
+ }
2024
+ };
2025
+ var PaymentSession_default = PaymentSession;
2026
+
1952
2027
  // src/DynamoModels/index.ts
1953
2028
  var TABLES = {
1954
2029
  User: User_default,
@@ -1964,7 +2039,8 @@ var TABLES = {
1964
2039
  CustomerMinified: CustomerMinified_default,
1965
2040
  NotificationStats: NotificationStats_default,
1966
2041
  NotiHubStatsHistory: NotiHubStatsHistory_default,
1967
- StripeSubscription: StripeSubscriptions_default
2042
+ StripeSubscription: StripeSubscriptions_default,
2043
+ PaymentSession: PaymentSession_default
1968
2044
  };
1969
2045
 
1970
2046
  // src/errorcodes.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amohamud23/notihub",
3
- "version": "1.1.36",
3
+ "version": "1.1.38",
4
4
  "description": "Notihub Package",
5
5
  "main": "./dist/index.cjs",
6
6
  "types": "./dist/index.d.cts",