@amohamud23/notihub 1.1.42 → 1.1.44

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
@@ -1853,6 +1853,31 @@ var StripeSubscription = class _StripeSubscription {
1853
1853
  throw new Error("Could not fetch stripe subscriptions by customerId");
1854
1854
  }
1855
1855
  }
1856
+ static async getStripeSubscriptionsByStripeCustomerId(stripeCustomerId) {
1857
+ const command = new import_lib_dynamodb15.QueryCommand({
1858
+ TableName: _StripeSubscription.TABLE_NAME,
1859
+ IndexName: "StripeCustomerIdIndex",
1860
+ KeyConditionExpression: "stripe_customerId = :stripeCustomerId",
1861
+ ExpressionAttributeValues: {
1862
+ ":stripeCustomerId": stripeCustomerId
1863
+ }
1864
+ });
1865
+ try {
1866
+ const result = await ddbDocClient.send(command);
1867
+ if (!result.Items || result.Items.length === 0) {
1868
+ return null;
1869
+ }
1870
+ return result.Items[0];
1871
+ } catch (error) {
1872
+ console.error(
1873
+ "Error fetching stripe subscriptions by stripe customerId:",
1874
+ error
1875
+ );
1876
+ throw new Error(
1877
+ "Could not fetch stripe subscriptions by stripe customerId"
1878
+ );
1879
+ }
1880
+ }
1856
1881
  /**
1857
1882
  * Creates a new stripe subscription.
1858
1883
  * @param stripeSubscription - The stripe subscription object to create.
@@ -1923,7 +1948,7 @@ var StripeSubscriptions_default = StripeSubscription;
1923
1948
  var import_lib_dynamodb16 = require("@aws-sdk/lib-dynamodb");
1924
1949
  var PaymentSession = class _PaymentSession {
1925
1950
  static ENV = process.env.ENV || "dev";
1926
- static TABLE_NAME = `NotiHub-PaymentSession-v1-${_PaymentSession.ENV}`;
1951
+ static TABLE_NAME = `NotiHub-PaymentSessions-v1-${_PaymentSession.ENV}`;
1927
1952
  static async createPaymentSession(paymentSession) {
1928
1953
  const command = new import_lib_dynamodb16.PutCommand({
1929
1954
  TableName: _PaymentSession.TABLE_NAME,
package/dist/index.d.cts CHANGED
@@ -733,6 +733,7 @@ declare class StripeSubscription {
733
733
  * @returns A promise that resolves to an array of stripe subscription objects.
734
734
  */
735
735
  static getStripeSubscriptionsByCustomerId(customerId: string): Promise<INotiHubStripeSubscription[]>;
736
+ static getStripeSubscriptionsByStripeCustomerId(stripeCustomerId: string): Promise<INotiHubStripeSubscription | null>;
736
737
  /**
737
738
  * Creates a new stripe subscription.
738
739
  * @param stripeSubscription - The stripe subscription object to create.
package/dist/index.d.ts CHANGED
@@ -733,6 +733,7 @@ declare class StripeSubscription {
733
733
  * @returns A promise that resolves to an array of stripe subscription objects.
734
734
  */
735
735
  static getStripeSubscriptionsByCustomerId(customerId: string): Promise<INotiHubStripeSubscription[]>;
736
+ static getStripeSubscriptionsByStripeCustomerId(stripeCustomerId: string): Promise<INotiHubStripeSubscription | null>;
736
737
  /**
737
738
  * Creates a new stripe subscription.
738
739
  * @param stripeSubscription - The stripe subscription object to create.
package/dist/index.js CHANGED
@@ -1883,6 +1883,31 @@ var StripeSubscription = class _StripeSubscription {
1883
1883
  throw new Error("Could not fetch stripe subscriptions by customerId");
1884
1884
  }
1885
1885
  }
1886
+ static async getStripeSubscriptionsByStripeCustomerId(stripeCustomerId) {
1887
+ const command = new QueryCommand13({
1888
+ TableName: _StripeSubscription.TABLE_NAME,
1889
+ IndexName: "StripeCustomerIdIndex",
1890
+ KeyConditionExpression: "stripe_customerId = :stripeCustomerId",
1891
+ ExpressionAttributeValues: {
1892
+ ":stripeCustomerId": stripeCustomerId
1893
+ }
1894
+ });
1895
+ try {
1896
+ const result = await ddbDocClient.send(command);
1897
+ if (!result.Items || result.Items.length === 0) {
1898
+ return null;
1899
+ }
1900
+ return result.Items[0];
1901
+ } catch (error) {
1902
+ console.error(
1903
+ "Error fetching stripe subscriptions by stripe customerId:",
1904
+ error
1905
+ );
1906
+ throw new Error(
1907
+ "Could not fetch stripe subscriptions by stripe customerId"
1908
+ );
1909
+ }
1910
+ }
1886
1911
  /**
1887
1912
  * Creates a new stripe subscription.
1888
1913
  * @param stripeSubscription - The stripe subscription object to create.
@@ -1958,7 +1983,7 @@ import {
1958
1983
  } from "@aws-sdk/lib-dynamodb";
1959
1984
  var PaymentSession = class _PaymentSession {
1960
1985
  static ENV = process.env.ENV || "dev";
1961
- static TABLE_NAME = `NotiHub-PaymentSession-v1-${_PaymentSession.ENV}`;
1986
+ static TABLE_NAME = `NotiHub-PaymentSessions-v1-${_PaymentSession.ENV}`;
1962
1987
  static async createPaymentSession(paymentSession) {
1963
1988
  const command = new PutCommand15({
1964
1989
  TableName: _PaymentSession.TABLE_NAME,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amohamud23/notihub",
3
- "version": "1.1.42",
3
+ "version": "1.1.44",
4
4
  "description": "Notihub Package",
5
5
  "main": "./dist/index.cjs",
6
6
  "types": "./dist/index.d.cts",