@amohamud23/notihub 1.1.65 → 1.1.67

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
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
 
20
30
  // src/index.ts
@@ -22,6 +32,7 @@ var index_exports = {};
22
32
  __export(index_exports, {
23
33
  DocumentNotFoundException: () => DocumentNotFoundException,
24
34
  ErrorCode: () => errorcodes_exports,
35
+ Logger: () => Logger,
25
36
  ParameterStoreClient: () => ParameterStoreClient_default,
26
37
  TABLES: () => TABLES,
27
38
  addMonths: () => addMonths,
@@ -2038,6 +2049,108 @@ var ParameterStore = class {
2038
2049
  };
2039
2050
  var ParameterStoreClient_default = new ParameterStore();
2040
2051
 
2052
+ // src/logger.ts
2053
+ var import_pino = __toESM(require("pino"), 1);
2054
+ var Logger = class _Logger {
2055
+ logger;
2056
+ static instance;
2057
+ constructor() {
2058
+ this.logger = (0, import_pino.default)({
2059
+ level: process.env.LOG_LEVEL || "info",
2060
+ transport: process.env.ENV !== "prod" ? {
2061
+ target: "pino-pretty",
2062
+ options: {
2063
+ colorize: true,
2064
+ translateTime: "SYS:standard",
2065
+ ignore: "pid,hostname"
2066
+ }
2067
+ } : void 0
2068
+ });
2069
+ }
2070
+ /**
2071
+ * Get singleton instance of Logger
2072
+ */
2073
+ static getInstance() {
2074
+ if (!_Logger.instance) {
2075
+ _Logger.instance = new _Logger();
2076
+ }
2077
+ return _Logger.instance;
2078
+ }
2079
+ /**
2080
+ * Log informational message
2081
+ */
2082
+ info(message, data) {
2083
+ if (data) {
2084
+ this.logger.info(data, message);
2085
+ } else {
2086
+ this.logger.info(message);
2087
+ }
2088
+ }
2089
+ /**
2090
+ * Log error message
2091
+ */
2092
+ error(message, error) {
2093
+ if (error instanceof Error) {
2094
+ this.logger.error({ err: error }, message);
2095
+ } else if (error) {
2096
+ this.logger.error(error, message);
2097
+ } else {
2098
+ this.logger.error(message);
2099
+ }
2100
+ }
2101
+ /**
2102
+ * Log warning message
2103
+ */
2104
+ warn(message, data) {
2105
+ if (data) {
2106
+ this.logger.warn(data, message);
2107
+ } else {
2108
+ this.logger.warn(message);
2109
+ }
2110
+ }
2111
+ /**
2112
+ * Log debug message
2113
+ */
2114
+ debug(message, data) {
2115
+ if (data) {
2116
+ this.logger.debug(data, message);
2117
+ } else {
2118
+ this.logger.debug(message);
2119
+ }
2120
+ }
2121
+ /**
2122
+ * Log trace message
2123
+ */
2124
+ trace(message, data) {
2125
+ if (data) {
2126
+ this.logger.trace(data, message);
2127
+ } else {
2128
+ this.logger.trace(message);
2129
+ }
2130
+ }
2131
+ /**
2132
+ * Log fatal message
2133
+ */
2134
+ fatal(message, error) {
2135
+ if (error instanceof Error) {
2136
+ this.logger.fatal({ err: error }, message);
2137
+ } else if (error) {
2138
+ this.logger.fatal(error, message);
2139
+ } else {
2140
+ this.logger.fatal(message);
2141
+ }
2142
+ }
2143
+ /**
2144
+ * Create a child logger with additional context
2145
+ */
2146
+ child(bindings) {
2147
+ const childLogger = new _Logger();
2148
+ childLogger.logger = this.logger.child(bindings);
2149
+ return childLogger;
2150
+ }
2151
+ };
2152
+ var logger_default = Logger.getInstance();
2153
+
2041
2154
  // src/errorcodes.ts
2042
2155
  var errorcodes_exports = {};
2043
2156
  __export(errorcodes_exports, {
@@ -2064,6 +2177,7 @@ var InvalidDate = "4011";
2064
2177
  0 && (module.exports = {
2065
2178
  DocumentNotFoundException,
2066
2179
  ErrorCode,
2180
+ Logger,
2067
2181
  ParameterStoreClient,
2068
2182
  TABLES,
2069
2183
  addMonths,
package/dist/index.d.cts CHANGED
@@ -802,6 +802,47 @@ declare class ParameterStore {
802
802
  }
803
803
  declare const _default: ParameterStore;
804
804
 
805
+ /**
806
+ * Reusable Logger class using Pino for structured logging
807
+ */
808
+ declare class Logger {
809
+ private logger;
810
+ private static instance;
811
+ private constructor();
812
+ /**
813
+ * Get singleton instance of Logger
814
+ */
815
+ static getInstance(): Logger;
816
+ /**
817
+ * Log informational message
818
+ */
819
+ info(message: string, data?: Record<string, any>): void;
820
+ /**
821
+ * Log error message
822
+ */
823
+ error(message: string, error?: Error | Record<string, any>): void;
824
+ /**
825
+ * Log warning message
826
+ */
827
+ warn(message: string, data?: Record<string, any>): void;
828
+ /**
829
+ * Log debug message
830
+ */
831
+ debug(message: string, data?: Record<string, any>): void;
832
+ /**
833
+ * Log trace message
834
+ */
835
+ trace(message: string, data?: Record<string, any>): void;
836
+ /**
837
+ * Log fatal message
838
+ */
839
+ fatal(message: string, error?: Error | Record<string, any>): void;
840
+ /**
841
+ * Create a child logger with additional context
842
+ */
843
+ child(bindings: Record<string, any>): Logger;
844
+ }
845
+
805
846
  declare const DocumentNotFound = "4001";
806
847
  declare const UserNotFound = "4002";
807
848
  declare const CustomerNotFound = "4003";
@@ -825,4 +866,4 @@ declare namespace errorcodes {
825
866
  export { errorcodes_CustomerNotFound as CustomerNotFound, errorcodes_DocumentNotFound as DocumentNotFound, errorcodes_InvalidDate as InvalidDate, errorcodes_InvalidEmail as InvalidEmail, errorcodes_InvalidName as InvalidName, errorcodes_InvalidPassword as InvalidPassword, errorcodes_InvalidPhoneNumber as InvalidPhoneNumber, errorcodes_InvalidPushToken as InvalidPushToken, errorcodes_UserNotFound as UserNotFound };
826
867
  }
827
868
 
828
- export { type CreateNotiRequestBody, type CreateSubscriptionRequestBody, type CreateUserRequestBody, type DBMetaData, DocumentNotFoundException, errorcodes as ErrorCode, type ICreateCustomerRequestBody, type ICreateNotiRequestBody, type INotiHubCustomer, type INotiHubCustomerMetadata, type INotiHubCustomerMinified, type INotiHubImage, type INotiHubNotification, type INotiHubNotificationStats, type INotiHubPaymentSession, type INotiHubStats, type INotiHubStatsHistory, type INotiHubStripeSubscription, type INotiHubSubscription, type INotiHubSubscriptionActivity, type INotiHubUser, type INotiHubUserView, type INotiType, type INotiTypeStats, type IUserSubscribeNotifier, type IUserSubscription, type NotiHubTypes, _default as ParameterStoreClient, type Response, TABLES, addMonths, formatResponse, getDate, getDateFormat, handleError, handleSuccess };
869
+ export { type CreateNotiRequestBody, type CreateSubscriptionRequestBody, type CreateUserRequestBody, type DBMetaData, DocumentNotFoundException, errorcodes as ErrorCode, type ICreateCustomerRequestBody, type ICreateNotiRequestBody, type INotiHubCustomer, type INotiHubCustomerMetadata, type INotiHubCustomerMinified, type INotiHubImage, type INotiHubNotification, type INotiHubNotificationStats, type INotiHubPaymentSession, type INotiHubStats, type INotiHubStatsHistory, type INotiHubStripeSubscription, type INotiHubSubscription, type INotiHubSubscriptionActivity, type INotiHubUser, type INotiHubUserView, type INotiType, type INotiTypeStats, type IUserSubscribeNotifier, type IUserSubscription, Logger, type NotiHubTypes, _default as ParameterStoreClient, type Response, TABLES, addMonths, formatResponse, getDate, getDateFormat, handleError, handleSuccess };
package/dist/index.d.ts CHANGED
@@ -802,6 +802,47 @@ declare class ParameterStore {
802
802
  }
803
803
  declare const _default: ParameterStore;
804
804
 
805
+ /**
806
+ * Reusable Logger class using Pino for structured logging
807
+ */
808
+ declare class Logger {
809
+ private logger;
810
+ private static instance;
811
+ private constructor();
812
+ /**
813
+ * Get singleton instance of Logger
814
+ */
815
+ static getInstance(): Logger;
816
+ /**
817
+ * Log informational message
818
+ */
819
+ info(message: string, data?: Record<string, any>): void;
820
+ /**
821
+ * Log error message
822
+ */
823
+ error(message: string, error?: Error | Record<string, any>): void;
824
+ /**
825
+ * Log warning message
826
+ */
827
+ warn(message: string, data?: Record<string, any>): void;
828
+ /**
829
+ * Log debug message
830
+ */
831
+ debug(message: string, data?: Record<string, any>): void;
832
+ /**
833
+ * Log trace message
834
+ */
835
+ trace(message: string, data?: Record<string, any>): void;
836
+ /**
837
+ * Log fatal message
838
+ */
839
+ fatal(message: string, error?: Error | Record<string, any>): void;
840
+ /**
841
+ * Create a child logger with additional context
842
+ */
843
+ child(bindings: Record<string, any>): Logger;
844
+ }
845
+
805
846
  declare const DocumentNotFound = "4001";
806
847
  declare const UserNotFound = "4002";
807
848
  declare const CustomerNotFound = "4003";
@@ -825,4 +866,4 @@ declare namespace errorcodes {
825
866
  export { errorcodes_CustomerNotFound as CustomerNotFound, errorcodes_DocumentNotFound as DocumentNotFound, errorcodes_InvalidDate as InvalidDate, errorcodes_InvalidEmail as InvalidEmail, errorcodes_InvalidName as InvalidName, errorcodes_InvalidPassword as InvalidPassword, errorcodes_InvalidPhoneNumber as InvalidPhoneNumber, errorcodes_InvalidPushToken as InvalidPushToken, errorcodes_UserNotFound as UserNotFound };
826
867
  }
827
868
 
828
- export { type CreateNotiRequestBody, type CreateSubscriptionRequestBody, type CreateUserRequestBody, type DBMetaData, DocumentNotFoundException, errorcodes as ErrorCode, type ICreateCustomerRequestBody, type ICreateNotiRequestBody, type INotiHubCustomer, type INotiHubCustomerMetadata, type INotiHubCustomerMinified, type INotiHubImage, type INotiHubNotification, type INotiHubNotificationStats, type INotiHubPaymentSession, type INotiHubStats, type INotiHubStatsHistory, type INotiHubStripeSubscription, type INotiHubSubscription, type INotiHubSubscriptionActivity, type INotiHubUser, type INotiHubUserView, type INotiType, type INotiTypeStats, type IUserSubscribeNotifier, type IUserSubscription, type NotiHubTypes, _default as ParameterStoreClient, type Response, TABLES, addMonths, formatResponse, getDate, getDateFormat, handleError, handleSuccess };
869
+ export { type CreateNotiRequestBody, type CreateSubscriptionRequestBody, type CreateUserRequestBody, type DBMetaData, DocumentNotFoundException, errorcodes as ErrorCode, type ICreateCustomerRequestBody, type ICreateNotiRequestBody, type INotiHubCustomer, type INotiHubCustomerMetadata, type INotiHubCustomerMinified, type INotiHubImage, type INotiHubNotification, type INotiHubNotificationStats, type INotiHubPaymentSession, type INotiHubStats, type INotiHubStatsHistory, type INotiHubStripeSubscription, type INotiHubSubscription, type INotiHubSubscriptionActivity, type INotiHubUser, type INotiHubUserView, type INotiType, type INotiTypeStats, type IUserSubscribeNotifier, type IUserSubscription, Logger, type NotiHubTypes, _default as ParameterStoreClient, type Response, TABLES, addMonths, formatResponse, getDate, getDateFormat, handleError, handleSuccess };
package/dist/index.js CHANGED
@@ -2084,6 +2084,108 @@ var ParameterStore = class {
2084
2084
  };
2085
2085
  var ParameterStoreClient_default = new ParameterStore();
2086
2086
 
2087
+ // src/logger.ts
2088
+ import pino from "pino";
2089
+ var Logger = class _Logger {
2090
+ logger;
2091
+ static instance;
2092
+ constructor() {
2093
+ this.logger = pino({
2094
+ level: process.env.LOG_LEVEL || "info",
2095
+ transport: process.env.ENV !== "prod" ? {
2096
+ target: "pino-pretty",
2097
+ options: {
2098
+ colorize: true,
2099
+ translateTime: "SYS:standard",
2100
+ ignore: "pid,hostname"
2101
+ }
2102
+ } : void 0
2103
+ });
2104
+ }
2105
+ /**
2106
+ * Get singleton instance of Logger
2107
+ */
2108
+ static getInstance() {
2109
+ if (!_Logger.instance) {
2110
+ _Logger.instance = new _Logger();
2111
+ }
2112
+ return _Logger.instance;
2113
+ }
2114
+ /**
2115
+ * Log informational message
2116
+ */
2117
+ info(message, data) {
2118
+ if (data) {
2119
+ this.logger.info(data, message);
2120
+ } else {
2121
+ this.logger.info(message);
2122
+ }
2123
+ }
2124
+ /**
2125
+ * Log error message
2126
+ */
2127
+ error(message, error) {
2128
+ if (error instanceof Error) {
2129
+ this.logger.error({ err: error }, message);
2130
+ } else if (error) {
2131
+ this.logger.error(error, message);
2132
+ } else {
2133
+ this.logger.error(message);
2134
+ }
2135
+ }
2136
+ /**
2137
+ * Log warning message
2138
+ */
2139
+ warn(message, data) {
2140
+ if (data) {
2141
+ this.logger.warn(data, message);
2142
+ } else {
2143
+ this.logger.warn(message);
2144
+ }
2145
+ }
2146
+ /**
2147
+ * Log debug message
2148
+ */
2149
+ debug(message, data) {
2150
+ if (data) {
2151
+ this.logger.debug(data, message);
2152
+ } else {
2153
+ this.logger.debug(message);
2154
+ }
2155
+ }
2156
+ /**
2157
+ * Log trace message
2158
+ */
2159
+ trace(message, data) {
2160
+ if (data) {
2161
+ this.logger.trace(data, message);
2162
+ } else {
2163
+ this.logger.trace(message);
2164
+ }
2165
+ }
2166
+ /**
2167
+ * Log fatal message
2168
+ */
2169
+ fatal(message, error) {
2170
+ if (error instanceof Error) {
2171
+ this.logger.fatal({ err: error }, message);
2172
+ } else if (error) {
2173
+ this.logger.fatal(error, message);
2174
+ } else {
2175
+ this.logger.fatal(message);
2176
+ }
2177
+ }
2178
+ /**
2179
+ * Create a child logger with additional context
2180
+ */
2181
+ child(bindings) {
2182
+ const childLogger = new _Logger();
2183
+ childLogger.logger = this.logger.child(bindings);
2184
+ return childLogger;
2185
+ }
2186
+ };
2187
+ var logger_default = Logger.getInstance();
2188
+
2087
2189
  // src/errorcodes.ts
2088
2190
  var errorcodes_exports = {};
2089
2191
  __export(errorcodes_exports, {
@@ -2109,6 +2211,7 @@ var InvalidDate = "4011";
2109
2211
  export {
2110
2212
  DocumentNotFoundException,
2111
2213
  errorcodes_exports as ErrorCode,
2214
+ Logger,
2112
2215
  ParameterStoreClient_default as ParameterStoreClient,
2113
2216
  TABLES,
2114
2217
  addMonths,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amohamud23/notihub",
3
- "version": "1.1.65",
3
+ "version": "1.1.67",
4
4
  "description": "Notihub Package",
5
5
  "main": "./dist/index.cjs",
6
6
  "types": "./dist/index.d.cts",
@@ -26,6 +26,7 @@
26
26
  "@types/node": "^22.8.4",
27
27
  "express": "^5.1.0",
28
28
  "jest": "^29.7.0",
29
+ "pino-pretty": "^13.1.3",
29
30
  "ts-jest": "^29.3.4",
30
31
  "tsup": "^8.5.1",
31
32
  "typescript": "^5.8.3"
@@ -36,6 +37,7 @@
36
37
  "@aws-sdk/lib-dynamodb": "^3.821.0",
37
38
  "aws-sdk-client-mock": "^4.1.0",
38
39
  "date-fns": "^4.1.0",
40
+ "pino": "^10.1.0",
39
41
  "ts-node": "^10.9.2",
40
42
  "uuid": "^11.0.2"
41
43
  }