@amohamud23/notihub 1.1.9 → 1.1.10

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
@@ -940,13 +940,21 @@ var Subscription = class _Subscription {
940
940
  * @returns A promise that resolves to the subscription object or null if not found.
941
941
  */
942
942
  static async getSubscriptionBySubscriptionId(subscriptionId) {
943
- const command = new import_lib_dynamodb7.GetCommand({
943
+ const command = new import_lib_dynamodb7.QueryCommand({
944
944
  TableName: _Subscription.TABLE_NAME,
945
- Key: { subscriptionId }
945
+ IndexName: "SubscriptionIdIndex",
946
+ // Assuming you have a GSI for userId
947
+ KeyConditionExpression: "subscriptionId = :subscriptionId",
948
+ ExpressionAttributeValues: {
949
+ ":subscriptionId": subscriptionId
950
+ }
946
951
  });
947
952
  try {
948
953
  const result = await ddbDocClient.send(command);
949
- return result.Item || null;
954
+ if (!result.Items || result.Items.length === 0) {
955
+ return null;
956
+ }
957
+ return result.Items[0] || null;
950
958
  } catch (error) {
951
959
  console.error("Error fetching subscription by SubscriptionId:", error);
952
960
  throw new Error("Could not fetch subscription by SubscriptionId");
package/dist/index.js CHANGED
@@ -933,13 +933,21 @@ var Subscription = class _Subscription {
933
933
  * @returns A promise that resolves to the subscription object or null if not found.
934
934
  */
935
935
  static async getSubscriptionBySubscriptionId(subscriptionId) {
936
- const command = new GetCommand6({
936
+ const command = new QueryCommand6({
937
937
  TableName: _Subscription.TABLE_NAME,
938
- Key: { subscriptionId }
938
+ IndexName: "SubscriptionIdIndex",
939
+ // Assuming you have a GSI for userId
940
+ KeyConditionExpression: "subscriptionId = :subscriptionId",
941
+ ExpressionAttributeValues: {
942
+ ":subscriptionId": subscriptionId
943
+ }
939
944
  });
940
945
  try {
941
946
  const result = await ddbDocClient.send(command);
942
- return result.Item || null;
947
+ if (!result.Items || result.Items.length === 0) {
948
+ return null;
949
+ }
950
+ return result.Items[0] || null;
943
951
  } catch (error) {
944
952
  console.error("Error fetching subscription by SubscriptionId:", error);
945
953
  throw new Error("Could not fetch subscription by SubscriptionId");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amohamud23/notihub",
3
- "version": "1.1.9",
3
+ "version": "1.1.10",
4
4
  "description": "Notihub Package",
5
5
  "main": "./dist/index.cjs",
6
6
  "types": "./dist/index.d.cts",