@amohamud23/notihub 1.1.41 → 1.1.43

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.
package/dist/index.d.cts CHANGED
@@ -91,6 +91,7 @@ type INotiHubNotification = {
91
91
  notificationStatsId: string;
92
92
  customerMinified: INotiHubCustomerMinified;
93
93
  body: string;
94
+ aiGenerated: boolean;
94
95
  deliveryType: "IMMEDIATE" | "SCHEDULED";
95
96
  scheduledAt: string;
96
97
  createdAt: string;
@@ -203,6 +204,7 @@ type INotiHubStripeSubscription = {
203
204
  customerId: string;
204
205
  status: string;
205
206
  stripe_subscription: string;
207
+ stripe_customerId: string;
206
208
  createdAt: string;
207
209
  updatedAt: string;
208
210
  };
@@ -731,6 +733,7 @@ declare class StripeSubscription {
731
733
  * @returns A promise that resolves to an array of stripe subscription objects.
732
734
  */
733
735
  static getStripeSubscriptionsByCustomerId(customerId: string): Promise<INotiHubStripeSubscription[]>;
736
+ static getStripeSubscriptionsByStripeCustomerId(stripeCustomerId: string): Promise<INotiHubStripeSubscription | null>;
734
737
  /**
735
738
  * Creates a new stripe subscription.
736
739
  * @param stripeSubscription - The stripe subscription object to create.
package/dist/index.d.ts CHANGED
@@ -91,6 +91,7 @@ type INotiHubNotification = {
91
91
  notificationStatsId: string;
92
92
  customerMinified: INotiHubCustomerMinified;
93
93
  body: string;
94
+ aiGenerated: boolean;
94
95
  deliveryType: "IMMEDIATE" | "SCHEDULED";
95
96
  scheduledAt: string;
96
97
  createdAt: string;
@@ -203,6 +204,7 @@ type INotiHubStripeSubscription = {
203
204
  customerId: string;
204
205
  status: string;
205
206
  stripe_subscription: string;
207
+ stripe_customerId: string;
206
208
  createdAt: string;
207
209
  updatedAt: string;
208
210
  };
@@ -731,6 +733,7 @@ declare class StripeSubscription {
731
733
  * @returns A promise that resolves to an array of stripe subscription objects.
732
734
  */
733
735
  static getStripeSubscriptionsByCustomerId(customerId: string): Promise<INotiHubStripeSubscription[]>;
736
+ static getStripeSubscriptionsByStripeCustomerId(stripeCustomerId: string): Promise<INotiHubStripeSubscription | null>;
734
737
  /**
735
738
  * Creates a new stripe subscription.
736
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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amohamud23/notihub",
3
- "version": "1.1.41",
3
+ "version": "1.1.43",
4
4
  "description": "Notihub Package",
5
5
  "main": "./dist/index.cjs",
6
6
  "types": "./dist/index.d.cts",