@amohamud23/notihub 1.1.37 → 1.1.39
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 +72 -1
- package/dist/index.d.cts +11 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +77 -1
- package/package.json +1 -1
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
|
@@ -201,6 +201,7 @@ type INotiHubSubscriptionActivity = {
|
|
|
201
201
|
type INotiHubStripeSubscription = {
|
|
202
202
|
id: string;
|
|
203
203
|
customerId: string;
|
|
204
|
+
status: string;
|
|
204
205
|
stripe_subscription: string;
|
|
205
206
|
};
|
|
206
207
|
type INotiHubPaymentSession = {
|
|
@@ -749,6 +750,15 @@ declare class StripeSubscription {
|
|
|
749
750
|
static updateStripeSubscription(id: string, updates: Partial<INotiHubStripeSubscription>): Promise<INotiHubStripeSubscription>;
|
|
750
751
|
}
|
|
751
752
|
|
|
753
|
+
declare class PaymentSession {
|
|
754
|
+
static ENV: string;
|
|
755
|
+
static TABLE_NAME: string;
|
|
756
|
+
static createPaymentSession(paymentSession: INotiHubPaymentSession): Promise<INotiHubPaymentSession>;
|
|
757
|
+
static getPaymentSessionById(id: string): Promise<INotiHubPaymentSession>;
|
|
758
|
+
static updatePaymentSession(id: string, intent: string): Promise<void>;
|
|
759
|
+
static getPaymentSessionBySessionId(sessionId: string): Promise<INotiHubPaymentSession | null>;
|
|
760
|
+
}
|
|
761
|
+
|
|
752
762
|
declare const TABLES: {
|
|
753
763
|
User: typeof User;
|
|
754
764
|
Customer: typeof Customer;
|
|
@@ -764,6 +774,7 @@ declare const TABLES: {
|
|
|
764
774
|
NotificationStats: typeof NotificationStats;
|
|
765
775
|
NotiHubStatsHistory: typeof NotiHubStatsHistory;
|
|
766
776
|
StripeSubscription: typeof StripeSubscription;
|
|
777
|
+
PaymentSession: typeof PaymentSession;
|
|
767
778
|
};
|
|
768
779
|
|
|
769
780
|
declare const DocumentNotFound = "4001";
|
package/dist/index.d.ts
CHANGED
|
@@ -201,6 +201,7 @@ type INotiHubSubscriptionActivity = {
|
|
|
201
201
|
type INotiHubStripeSubscription = {
|
|
202
202
|
id: string;
|
|
203
203
|
customerId: string;
|
|
204
|
+
status: string;
|
|
204
205
|
stripe_subscription: string;
|
|
205
206
|
};
|
|
206
207
|
type INotiHubPaymentSession = {
|
|
@@ -749,6 +750,15 @@ declare class StripeSubscription {
|
|
|
749
750
|
static updateStripeSubscription(id: string, updates: Partial<INotiHubStripeSubscription>): Promise<INotiHubStripeSubscription>;
|
|
750
751
|
}
|
|
751
752
|
|
|
753
|
+
declare class PaymentSession {
|
|
754
|
+
static ENV: string;
|
|
755
|
+
static TABLE_NAME: string;
|
|
756
|
+
static createPaymentSession(paymentSession: INotiHubPaymentSession): Promise<INotiHubPaymentSession>;
|
|
757
|
+
static getPaymentSessionById(id: string): Promise<INotiHubPaymentSession>;
|
|
758
|
+
static updatePaymentSession(id: string, intent: string): Promise<void>;
|
|
759
|
+
static getPaymentSessionBySessionId(sessionId: string): Promise<INotiHubPaymentSession | null>;
|
|
760
|
+
}
|
|
761
|
+
|
|
752
762
|
declare const TABLES: {
|
|
753
763
|
User: typeof User;
|
|
754
764
|
Customer: typeof Customer;
|
|
@@ -764,6 +774,7 @@ declare const TABLES: {
|
|
|
764
774
|
NotificationStats: typeof NotificationStats;
|
|
765
775
|
NotiHubStatsHistory: typeof NotiHubStatsHistory;
|
|
766
776
|
StripeSubscription: typeof StripeSubscription;
|
|
777
|
+
PaymentSession: typeof PaymentSession;
|
|
767
778
|
};
|
|
768
779
|
|
|
769
780
|
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
|