@amohamud23/notihub 1.0.192 → 1.0.194
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 +11 -4
- package/dist/index.js +19 -11
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1152,13 +1152,20 @@ var CustomerMetaData = class _CustomerMetaData {
|
|
|
1152
1152
|
* @returns A promise that resolves to an array of customer metadata objects or null if not found.
|
|
1153
1153
|
*/
|
|
1154
1154
|
static async getCustomerMetaDataByCustomerId(customerId) {
|
|
1155
|
-
const command = new import_lib_dynamodb11.
|
|
1155
|
+
const command = new import_lib_dynamodb11.QueryCommand({
|
|
1156
1156
|
TableName: _CustomerMetaData.TABLE_NAME,
|
|
1157
|
-
|
|
1157
|
+
// replace with your resolved table name
|
|
1158
|
+
KeyConditionExpression: "customerId = :cid",
|
|
1159
|
+
ExpressionAttributeValues: {
|
|
1160
|
+
":cid": customerId
|
|
1161
|
+
}
|
|
1158
1162
|
});
|
|
1159
1163
|
try {
|
|
1160
1164
|
const result = await ddbDocClient.send(command);
|
|
1161
|
-
|
|
1165
|
+
if (!result.Items || result.Items.length === 0) {
|
|
1166
|
+
return null;
|
|
1167
|
+
}
|
|
1168
|
+
return result?.Items[0] || null;
|
|
1162
1169
|
} catch (error) {
|
|
1163
1170
|
console.error("Error fetching customer metadata by customerId:", error);
|
|
1164
1171
|
throw new Error("Could not fetch customer metadata by customerId");
|
|
@@ -1338,7 +1345,7 @@ var NotificationStats_default = NotificationStats;
|
|
|
1338
1345
|
var import_lib_dynamodb14 = require("@aws-sdk/lib-dynamodb");
|
|
1339
1346
|
var NotiHubStatsHistory = class _NotiHubStatsHistory {
|
|
1340
1347
|
static ENV = process.env.ENV || "dev";
|
|
1341
|
-
static TABLE_NAME = `NotiHub-
|
|
1348
|
+
static TABLE_NAME = `NotiHub-StatsHistory-v1-${_NotiHubStatsHistory.ENV}`;
|
|
1342
1349
|
/**
|
|
1343
1350
|
* Creates a new NotiHub stats history entry.
|
|
1344
1351
|
* @param statsHistory - The statistics history object to create.
|
package/dist/index.js
CHANGED
|
@@ -1115,7 +1115,8 @@ var SubscriptionType_default = SubscriptionType;
|
|
|
1115
1115
|
import {
|
|
1116
1116
|
DeleteCommand as DeleteCommand9,
|
|
1117
1117
|
GetCommand as GetCommand10,
|
|
1118
|
-
PutCommand as PutCommand10
|
|
1118
|
+
PutCommand as PutCommand10,
|
|
1119
|
+
QueryCommand as QueryCommand10
|
|
1119
1120
|
} from "@aws-sdk/lib-dynamodb";
|
|
1120
1121
|
var CustomerMetaData = class _CustomerMetaData {
|
|
1121
1122
|
static ENV = process.env.ENV || "dev";
|
|
@@ -1161,13 +1162,20 @@ var CustomerMetaData = class _CustomerMetaData {
|
|
|
1161
1162
|
* @returns A promise that resolves to an array of customer metadata objects or null if not found.
|
|
1162
1163
|
*/
|
|
1163
1164
|
static async getCustomerMetaDataByCustomerId(customerId) {
|
|
1164
|
-
const command = new
|
|
1165
|
+
const command = new QueryCommand10({
|
|
1165
1166
|
TableName: _CustomerMetaData.TABLE_NAME,
|
|
1166
|
-
|
|
1167
|
+
// replace with your resolved table name
|
|
1168
|
+
KeyConditionExpression: "customerId = :cid",
|
|
1169
|
+
ExpressionAttributeValues: {
|
|
1170
|
+
":cid": customerId
|
|
1171
|
+
}
|
|
1167
1172
|
});
|
|
1168
1173
|
try {
|
|
1169
1174
|
const result = await ddbDocClient.send(command);
|
|
1170
|
-
|
|
1175
|
+
if (!result.Items || result.Items.length === 0) {
|
|
1176
|
+
return null;
|
|
1177
|
+
}
|
|
1178
|
+
return result?.Items[0] || null;
|
|
1171
1179
|
} catch (error) {
|
|
1172
1180
|
console.error("Error fetching customer metadata by customerId:", error);
|
|
1173
1181
|
throw new Error("Could not fetch customer metadata by customerId");
|
|
@@ -1199,7 +1207,7 @@ import {
|
|
|
1199
1207
|
DeleteCommand as DeleteCommand10,
|
|
1200
1208
|
GetCommand as GetCommand11,
|
|
1201
1209
|
PutCommand as PutCommand11,
|
|
1202
|
-
QueryCommand as
|
|
1210
|
+
QueryCommand as QueryCommand11
|
|
1203
1211
|
} from "@aws-sdk/lib-dynamodb";
|
|
1204
1212
|
var CustomerMinified = class _CustomerMinified {
|
|
1205
1213
|
static ENV = process.env.ENV || "dev";
|
|
@@ -1264,7 +1272,7 @@ var CustomerMinified = class _CustomerMinified {
|
|
|
1264
1272
|
* @returns A promise that resolves to the customer object or null if not found.
|
|
1265
1273
|
*/
|
|
1266
1274
|
static async getCustomerMinifiedByUsername(username) {
|
|
1267
|
-
const command = new
|
|
1275
|
+
const command = new QueryCommand11({
|
|
1268
1276
|
TableName: _CustomerMinified.TABLE_NAME,
|
|
1269
1277
|
IndexName: "UsernameIndex",
|
|
1270
1278
|
// Assuming you have a GSI for username
|
|
@@ -1351,11 +1359,11 @@ var NotificationStats_default = NotificationStats;
|
|
|
1351
1359
|
// src/DynamoModels/NotiHubStatsHistory.ts
|
|
1352
1360
|
import {
|
|
1353
1361
|
PutCommand as PutCommand13,
|
|
1354
|
-
QueryCommand as
|
|
1362
|
+
QueryCommand as QueryCommand12
|
|
1355
1363
|
} from "@aws-sdk/lib-dynamodb";
|
|
1356
1364
|
var NotiHubStatsHistory = class _NotiHubStatsHistory {
|
|
1357
1365
|
static ENV = process.env.ENV || "dev";
|
|
1358
|
-
static TABLE_NAME = `NotiHub-
|
|
1366
|
+
static TABLE_NAME = `NotiHub-StatsHistory-v1-${_NotiHubStatsHistory.ENV}`;
|
|
1359
1367
|
/**
|
|
1360
1368
|
* Creates a new NotiHub stats history entry.
|
|
1361
1369
|
* @param statsHistory - The statistics history object to create.
|
|
@@ -1384,7 +1392,7 @@ var NotiHubStatsHistory = class _NotiHubStatsHistory {
|
|
|
1384
1392
|
Date.now() - 365 * 24 * 60 * 60 * 1e3
|
|
1385
1393
|
).toISOString();
|
|
1386
1394
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
1387
|
-
const command = new
|
|
1395
|
+
const command = new QueryCommand12({
|
|
1388
1396
|
TableName: _NotiHubStatsHistory.TABLE_NAME,
|
|
1389
1397
|
IndexName: "CustomerIdIndex",
|
|
1390
1398
|
KeyConditionExpression: "customerId = :customerId AND createdAt BETWEEN :start AND :end",
|
|
@@ -1415,7 +1423,7 @@ var NotiHubStatsHistory = class _NotiHubStatsHistory {
|
|
|
1415
1423
|
Date.now() - 182 * 24 * 60 * 60 * 1e3
|
|
1416
1424
|
).toISOString();
|
|
1417
1425
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
1418
|
-
const command = new
|
|
1426
|
+
const command = new QueryCommand12({
|
|
1419
1427
|
TableName: _NotiHubStatsHistory.TABLE_NAME,
|
|
1420
1428
|
IndexName: "CustomerIdIndex",
|
|
1421
1429
|
KeyConditionExpression: "customerId = :customerId AND createdAt BETWEEN :start AND :end",
|
|
@@ -1442,7 +1450,7 @@ var NotiHubStatsHistory = class _NotiHubStatsHistory {
|
|
|
1442
1450
|
* @returns A promise that resolves to the last statistics history object or null if not found.
|
|
1443
1451
|
*/
|
|
1444
1452
|
static async getLastStatsHistoryByCustomerId(customerId) {
|
|
1445
|
-
const command = new
|
|
1453
|
+
const command = new QueryCommand12({
|
|
1446
1454
|
TableName: _NotiHubStatsHistory.TABLE_NAME,
|
|
1447
1455
|
IndexName: "CustomerIdIndex",
|
|
1448
1456
|
KeyConditionExpression: "customerId = :customerId",
|