@adtrackify/at-service-common 1.2.18 → 1.2.20

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.
Files changed (29) hide show
  1. package/dist/clients/generic/cognito-client.js +9 -9
  2. package/dist/clients/generic/cognito-client.js.map +1 -1
  3. package/dist/clients/generic/dynamodb-client.js +8 -8
  4. package/dist/clients/generic/dynamodb-client.js.map +1 -1
  5. package/dist/clients/generic/eventbridge-client.js +2 -2
  6. package/dist/clients/generic/eventbridge-client.js.map +1 -1
  7. package/dist/clients/generic/s3-client.d.ts +5 -2
  8. package/dist/clients/generic/s3-client.js +10 -5
  9. package/dist/clients/generic/s3-client.js.map +1 -1
  10. package/dist/clients/generic/sqs-client.js +2 -2
  11. package/dist/clients/generic/sqs-client.js.map +1 -1
  12. package/dist/clients/internal-api/accounts-client.js +9 -9
  13. package/dist/clients/internal-api/accounts-client.js.map +1 -1
  14. package/dist/clients/internal-api/destinations-client.js +3 -3
  15. package/dist/clients/internal-api/destinations-client.js.map +1 -1
  16. package/dist/clients/internal-api/users-auth-client.js +8 -8
  17. package/dist/clients/internal-api/users-auth-client.js.map +1 -1
  18. package/dist/clients/third-party/shopify-client.js +11 -11
  19. package/dist/clients/third-party/shopify-client.js.map +1 -1
  20. package/dist/helpers/input-validation-helper.js +3 -3
  21. package/dist/helpers/input-validation-helper.js.map +1 -1
  22. package/dist/helpers/logging-helper.d.ts +1 -0
  23. package/dist/helpers/logging-helper.js +7 -2
  24. package/dist/helpers/logging-helper.js.map +1 -1
  25. package/dist/helpers/shopify-helper.js +4 -4
  26. package/dist/helpers/shopify-helper.js.map +1 -1
  27. package/dist/index.esm.js +108 -111
  28. package/dist/index.esm.js.map +4 -4
  29. package/package.json +2 -2
package/dist/index.esm.js CHANGED
@@ -8,7 +8,6 @@ var __publicField = (obj, key, value) => {
8
8
  // src/clients/generic/dynamodb-client.ts
9
9
  import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
10
10
  import { DynamoDBDocument } from "@aws-sdk/lib-dynamodb";
11
- import * as log from "lambda-log";
12
11
  var marshallOptions = {
13
12
  convertEmptyValues: false,
14
13
  removeUndefinedValues: false,
@@ -34,7 +33,7 @@ __publicField(DynamoDbClient, "safeGet", async (tableName, keyName, keyValue) =>
34
33
  const res = await client.get(params);
35
34
  return res?.Item ?? null;
36
35
  } catch (e) {
37
- log.error(e, { message: "Dynamo Client Get Failed" });
36
+ Logger.error(e, { message: "Dynamo Client Get Failed" });
38
37
  return null;
39
38
  }
40
39
  });
@@ -47,7 +46,7 @@ __publicField(DynamoDbClient, "safePut", async (tableName, data) => {
47
46
  const res = await client.put(params);
48
47
  return res;
49
48
  } catch (e) {
50
- log.error(e, { message: "Dynamo failed simplePut" });
49
+ Logger.error(e, { message: "Dynamo failed simplePut" });
51
50
  return null;
52
51
  }
53
52
  });
@@ -62,7 +61,7 @@ __publicField(DynamoDbClient, "safeDelete", async (tableName, keyName, keyValue)
62
61
  const res = await client.delete(params);
63
62
  return res;
64
63
  } catch (e) {
65
- log.error(e, { message: "Dynamo failed safeDelete" });
64
+ Logger.error(e, { message: "Dynamo failed safeDelete" });
66
65
  return null;
67
66
  }
68
67
  });
@@ -87,19 +86,19 @@ __publicField(DynamoDbClient, "safeBatchGet", async (tableName, keys) => {
87
86
  Keys: keys
88
87
  };
89
88
  const res = await client.batchGet(params);
90
- log.info("batchget res", { batchGetRes: res });
89
+ Logger.debug("batchget res", { batchGetRes: res });
91
90
  if (res?.Responses?.[tableName]) {
92
91
  return res?.Responses?.[tableName];
93
92
  }
94
93
  return [];
95
94
  } catch (e) {
96
- log.error(e, { message: "Dynamo failed safeBatchGet" });
95
+ Logger.error(e, { message: "Dynamo failed safeBatchGet" });
97
96
  return [];
98
97
  }
99
98
  });
100
99
  __publicField(DynamoDbClient, "queryAll", async (params) => {
101
100
  try {
102
- log.info("Invoke Query All", { params });
101
+ Logger.debug("Invoke Query All", { params });
103
102
  let currentResult, exclusiveStartKey;
104
103
  let accumulatedResults = [];
105
104
  do {
@@ -113,7 +112,7 @@ __publicField(DynamoDbClient, "queryAll", async (params) => {
113
112
  } while (currentResult.Items && currentResult.Items.length > 0 && currentResult.LastEvaluatedKey);
114
113
  return accumulatedResults;
115
114
  } catch (e) {
116
- log.error(e, { message: "Dynamo failed queryAll" });
115
+ Logger.error(e, { message: "Dynamo failed queryAll" });
117
116
  return null;
118
117
  }
119
118
  });
@@ -142,7 +141,6 @@ var getCurrentDate = () => {
142
141
  };
143
142
 
144
143
  // src/clients/generic/eventbridge-client.ts
145
- import * as log2 from "lambda-log";
146
144
  var EventBridgeClient = class {
147
145
  eventBridge;
148
146
  EVENT_BUS_NAME;
@@ -174,7 +172,7 @@ var EventBridgeClient = class {
174
172
  };
175
173
  const putEventscommand = new PutEventsCommand(params);
176
174
  const response = await this.eventBridge.send(putEventscommand);
177
- log2.debug(
175
+ Logger.debug(
178
176
  "EventBus Event Published",
179
177
  {
180
178
  eventBusName: this.EVENT_BUS_NAME,
@@ -198,10 +196,10 @@ var httpResponse = (res = {}) => {
198
196
  status: res?.status || 0
199
197
  };
200
198
  };
201
- var handleAxiosError = (error8) => {
202
- if (!error8?.response && !error8?.request)
203
- throw error8;
204
- return error8.response ? httpResponse(error8.response) : httpResponse({ status: 500, data: { error: error8.request } });
199
+ var handleAxiosError = (error) => {
200
+ if (!error?.response && !error?.request)
201
+ throw error;
202
+ return error.response ? httpResponse(error.response) : httpResponse({ status: 500, data: { error: error.request } });
205
203
  };
206
204
  var axiosHttpService = (config = {}) => {
207
205
  config.adapter = "http";
@@ -220,13 +218,12 @@ var axiosHttpService = (config = {}) => {
220
218
 
221
219
  // src/clients/generic/s3-client.ts
222
220
  import { ObjectCannedACL, S3 } from "@aws-sdk/client-s3";
223
- import * as log3 from "lambda-log";
224
221
  var S3Client = class {
225
222
  s3;
226
223
  constructor(region = "us-west-2") {
227
224
  this.s3 = new S3({ region });
228
225
  }
229
- async uploadJson(path, bucket, jsonData, ACL = ObjectCannedACL.private) {
226
+ async uploadJson(path, bucket, jsonData, ACL = ObjectCannedACL.private, retryCount = 0) {
230
227
  try {
231
228
  const res = await this.s3.putObject({
232
229
  ACL,
@@ -235,17 +232,21 @@ var S3Client = class {
235
232
  Body: JSON.stringify(jsonData),
236
233
  Key: path
237
234
  });
238
- return res;
239
- } catch (error8) {
240
- log3.error("Error in s3 upload json", { error: error8 });
241
- return error8;
235
+ return { status: true, response: res };
236
+ } catch (error) {
237
+ Logger.error("Error in s3 upload json", { error });
238
+ if (retryCount <= 5) {
239
+ retryCount++;
240
+ Logger.error("retrying to uploadJson", { path, bucket, jsonData, ACL, retryCount });
241
+ return await this.uploadJson(path, bucket, jsonData, ACL, retryCount);
242
+ }
243
+ return { status: false, response: jsonData };
242
244
  }
243
245
  }
244
246
  };
245
247
 
246
248
  // src/clients/generic/cognito-client.ts
247
249
  import { CognitoIdentityProvider } from "@aws-sdk/client-cognito-identity-provider";
248
- import * as log4 from "lambda-log";
249
250
  function dictToAwsAttributes(input) {
250
251
  delete input.email;
251
252
  delete input.password;
@@ -281,7 +282,7 @@ var CognitoClient = class {
281
282
  UserAttributes: buildAttributes(data)
282
283
  };
283
284
  const cognitoResponse = await this.cognitoClient.signUp(params);
284
- log4.debug("Successfully Registered User", { cognitoResponse });
285
+ Logger.debug("Successfully Registered User", { cognitoResponse });
285
286
  return cognitoResponse;
286
287
  };
287
288
  forgotPassword = async (email) => {
@@ -291,7 +292,7 @@ var CognitoClient = class {
291
292
  Username: email
292
293
  };
293
294
  const cognitoResponse = await this.cognitoClient.forgotPassword(params);
294
- log4.debug("Sent Forgot Password", { cognitoResponse });
295
+ Logger.debug("Sent Forgot Password", { cognitoResponse });
295
296
  return cognitoResponse;
296
297
  };
297
298
  adminEmailVerify = async (email) => {
@@ -300,8 +301,8 @@ var CognitoClient = class {
300
301
  if (user && user?.UserStatus === "CONFIRMED" && user?.email_verified !== "true") {
301
302
  await this.forceValidateEmail(email);
302
303
  }
303
- } catch (error8) {
304
- log4.error("Failed admin email verify", { error: error8 });
304
+ } catch (error) {
305
+ Logger.error("Failed admin email verify", { error });
305
306
  }
306
307
  };
307
308
  forceValidateEmail = async (email) => {
@@ -317,8 +318,8 @@ var CognitoClient = class {
317
318
  ]
318
319
  };
319
320
  await this.cognitoClient.adminUpdateUserAttributes(params);
320
- } catch (error8) {
321
- log4.error("Failed force validate email", { email, error: error8 });
321
+ } catch (error) {
322
+ Logger.error("Failed force validate email", { email, error });
322
323
  }
323
324
  };
324
325
  adminConfirmUser = async (data) => {
@@ -328,7 +329,7 @@ var CognitoClient = class {
328
329
  };
329
330
  const cognitoResponse = await this.cognitoClient.adminConfirmSignUp(params);
330
331
  await this.forceValidateEmail(data.email);
331
- log4.debug("Admin Successfully Confirmed User", { cognitoResponse });
332
+ Logger.debug("Admin Successfully Confirmed User", { cognitoResponse });
332
333
  return cognitoResponse;
333
334
  };
334
335
  confirmUser = async (data) => {
@@ -338,7 +339,7 @@ var CognitoClient = class {
338
339
  Username: data.email
339
340
  };
340
341
  const cognitoResponse = await this.cognitoClient.confirmSignUp(params);
341
- log4.debug("Successfully Confirmed User", { cognitoResponse });
342
+ Logger.debug("Successfully Confirmed User", { cognitoResponse });
342
343
  return cognitoResponse;
343
344
  };
344
345
  resendCode = async (email) => {
@@ -347,7 +348,7 @@ var CognitoClient = class {
347
348
  Username: email
348
349
  };
349
350
  await this.cognitoClient.resendConfirmationCode(params);
350
- log4.debug("Successfully Resend Confirmation Code", { email });
351
+ Logger.debug("Successfully Resend Confirmation Code", { email });
351
352
  return;
352
353
  };
353
354
  adminDeleteUser = async (userId) => {
@@ -365,7 +366,7 @@ var CognitoClient = class {
365
366
  Limit: 1
366
367
  };
367
368
  const cognitoResponse = await this.cognitoClient.listUsers(params);
368
- log4.debug("Get Users by Email", { cognitoResponse });
369
+ Logger.debug("Get Users by Email", { cognitoResponse });
369
370
  if (cognitoResponse?.Users && cognitoResponse?.Users.length > 0) {
370
371
  const attributes = cognitoResponse.Users[0].Attributes;
371
372
  const user = {
@@ -385,7 +386,6 @@ var CognitoClient = class {
385
386
  // src/clients/generic/sqs-client.ts
386
387
  import { SQS } from "@aws-sdk/client-sqs";
387
388
  import { v4 as uuidv42 } from "uuid";
388
- import * as log5 from "lambda-log";
389
389
  var SQSClient = class {
390
390
  sqs;
391
391
  queueUrl;
@@ -412,13 +412,12 @@ var SQSClient = class {
412
412
  MessageBody: JSON.stringify(messageBody)
413
413
  };
414
414
  const response = await this.sqs.sendMessage(params);
415
- log5.debug("SQS Message Sent", { queueUrl: this.queueUrl, messageBody, delaySeconds, response });
415
+ Logger.debug("SQS Message Sent", { queueUrl: this.queueUrl, messageBody, delaySeconds, response });
416
416
  return response;
417
417
  };
418
418
  };
419
419
 
420
420
  // src/clients/internal-api/destinations-client.ts
421
- import * as log6 from "lambda-log";
422
421
  var DestinationsClient = class {
423
422
  BASE_API_URL;
424
423
  DESTINATIONS_API_KEY;
@@ -443,19 +442,18 @@ var DestinationsClient = class {
443
442
  createDestination = async (createDestinationRequest) => {
444
443
  const client2 = await this.getClient();
445
444
  const response = await client2.post("/", createDestinationRequest);
446
- log6.info("createDestinationResponse", { response });
445
+ Logger.debug("createDestinationResponse", { response });
447
446
  return response;
448
447
  };
449
448
  getPixelDestinations = async (pixelId) => {
450
449
  const client2 = await this.getClient();
451
450
  const response = await client2.get(`/?pixelId=${pixelId}`);
452
- log6.info("getPixelResponse", { response });
451
+ Logger.debug("getPixelResponse", { response });
453
452
  return response;
454
453
  };
455
454
  };
456
455
 
457
456
  // src/clients/internal-api/accounts-client.ts
458
- import * as log7 from "lambda-log";
459
457
  var AccountsClient = class {
460
458
  BASE_API_URL;
461
459
  ACCOUNTS_API_KEY;
@@ -483,19 +481,19 @@ var AccountsClient = class {
483
481
  createAccount = async (createAccountRequest) => {
484
482
  const client2 = await this.getClient();
485
483
  const createAccountResponse = await client2.post("", createAccountRequest);
486
- log7.info("createAccountResponse", { createAccountResponse });
484
+ Logger.debug("createAccountResponse", { createAccountResponse });
487
485
  return createAccountResponse;
488
486
  };
489
487
  updateAccount = async (accountId, body) => {
490
488
  const client2 = await this.getClient();
491
489
  const response = await client2.patch(`/${accountId}/`, body);
492
- log7.info("update Account response", { response });
490
+ Logger.debug("update Account response", { response });
493
491
  return response;
494
492
  };
495
493
  addOwner = async (accountId, userId) => {
496
494
  const client2 = await this.getClient();
497
495
  const addOwnerResponse = await client2.post("/addOwner", { accountId, userId });
498
- log7.info("addOwnerResponse", { addOwnerResponse });
496
+ Logger.debug("addOwnerResponse", { addOwnerResponse });
499
497
  return addOwnerResponse;
500
498
  };
501
499
  isAuthorizedUser = async (userId, accountId, pixelId) => {
@@ -506,44 +504,41 @@ var AccountsClient = class {
506
504
  pixelId
507
505
  };
508
506
  const response = await client2.post("/checkUserAuthorization", body);
509
- log7.info("checkUserAuthorization", { response });
507
+ Logger.debug("checkUserAuthorization", { response });
510
508
  return response;
511
509
  };
512
510
  adminDeleteAccount = async (accountId) => {
513
511
  const client2 = await this.getClient();
514
512
  const success2 = await client2.delete(`/${accountId}`);
515
- log7.info("adminDeleteAccount");
513
+ Logger.debug("adminDeleteAccount");
516
514
  return success2;
517
515
  };
518
516
  getPixelConfigById = async (pixelId) => {
519
517
  const client2 = await this.getClient();
520
518
  const pixelResponse = await client2.get(`/px/${pixelId}/config`);
521
- log7.debug("get pixelResponse", { pixelResponse });
519
+ Logger.debug("get pixelResponse", { pixelResponse });
522
520
  return pixelResponse;
523
521
  };
524
522
  getAccount = async (accountId) => {
525
523
  const client2 = await this.getClient();
526
524
  const response = await client2.get(`/${accountId}/`);
527
- log7.info("get account response", { response });
525
+ Logger.debug("get account response", { response });
528
526
  return response;
529
527
  };
530
528
  addUserToAccount = async (accountId, userId) => {
531
529
  const client2 = await this.getClient();
532
530
  const response = await client2.post("/addUser", { accountId, userId });
533
- log7.info("add user account response", { response });
531
+ Logger.debug("add user account response", { response });
534
532
  return response;
535
533
  };
536
534
  // setAccountSubscriptionId = async (accountId: string, subscriptionId: string): Promise<ApiResponse<any>> => {
537
535
  // const client = await this.getClient();
538
536
  // const pixelResponse = await client.get(`/px/${pixelId}/config`);
539
- // log.debug('pixelResponse', { pixelResponse });
537
+ // Logger.debug('pixelResponse', { pixelResponse });
540
538
  // return pixelResponse;
541
539
  // };
542
540
  };
543
541
 
544
- // src/clients/internal-api/users-auth-client.ts
545
- import * as log8 from "lambda-log";
546
-
547
542
  // src/libs/http-error.ts
548
543
  import { strict as assert } from "assert";
549
544
  var deepClone = (o = {}) => JSON.parse(JSON.stringify(o));
@@ -703,20 +698,20 @@ var UsersAuthClient = class {
703
698
  return user;
704
699
  };
705
700
  signupUser = async (userSignupRequest) => {
706
- log8.info("Attempting to signup user", { email: userSignupRequest.email });
701
+ Logger.info("Attempting to signup user", { email: userSignupRequest.email });
707
702
  const client2 = await this.getClient();
708
703
  const response = await client2.post("/signup", userSignupRequest);
709
704
  if (response.status !== 200 || !response?.data?.user) {
710
705
  const message = "User Signup Failed";
711
- log8.error(message, { response });
706
+ Logger.error(message, { response });
712
707
  throw new HttpError(500 /* INTERNAL_SERVER_ERROR */, message);
713
708
  }
714
- log8.info("User Signup Successful", { response });
709
+ Logger.info("User Signup Successful", { response });
715
710
  return response.data.user;
716
711
  };
717
712
  //userName is same as user id
718
713
  adminConfirmUser = async (email) => {
719
- log8.info("Attempting to admin confirm user", { email });
714
+ Logger.info("Attempting to admin confirm user", { email });
720
715
  const client2 = await this.getClient();
721
716
  const response = await client2.post(
722
717
  "/admin/confirm",
@@ -731,10 +726,10 @@ var UsersAuthClient = class {
731
726
  );
732
727
  if (response.status !== 200) {
733
728
  const message = "Admin User Confirmation Failed";
734
- log8.error(message, { response });
729
+ Logger.error(message, { response });
735
730
  throw new HttpError(500 /* INTERNAL_SERVER_ERROR */, message);
736
731
  }
737
- log8.info("Admin User Confirmation Successful", { response });
732
+ Logger.info("Admin User Confirmation Successful", { response });
738
733
  return response;
739
734
  };
740
735
  getUserByEmail = async (email) => {
@@ -747,13 +742,13 @@ var UsersAuthClient = class {
747
742
  email
748
743
  }
749
744
  });
750
- log8.info("getUserResponse", { getUserResponse });
745
+ Logger.debug("getUserResponse", { getUserResponse });
751
746
  return getUserResponse;
752
747
  };
753
748
  };
754
749
 
755
750
  // src/clients/internal-api/shopify-app-install-client.ts
756
- import log9 from "lambda-log";
751
+ import log from "lambda-log";
757
752
  var ShopifyAppInstallClient = class {
758
753
  BASE_API_URL;
759
754
  SHOPIFY_APP_INSTALL_API_KEY;
@@ -778,25 +773,24 @@ var ShopifyAppInstallClient = class {
778
773
  updateShopifyAppInstall = async (shopifyAppInstallId, updateShopifyAppInstallRequest) => {
779
774
  const client2 = await this.getClient();
780
775
  const response = await client2.put(`/${shopifyAppInstallId}`, updateShopifyAppInstallRequest);
781
- log9.info("updateShopifyAppInstall", { response });
776
+ log.info("updateShopifyAppInstall", { response });
782
777
  return response;
783
778
  };
784
779
  getShopifyAppInstall = async (shopifyAppInstallId) => {
785
780
  const client2 = await this.getClient();
786
781
  const response = await client2.get(`/${shopifyAppInstallId}`);
787
- log9.info("getShopifyAppInstall", { response });
782
+ log.info("getShopifyAppInstall", { response });
788
783
  return response;
789
784
  };
790
785
  getShopifyAppInstallByShop = async (shop) => {
791
786
  const client2 = await this.getClient();
792
787
  const response = await client2.get(`/?shop=${shop}`);
793
- log9.info("getShopifyAppInstallByShop", { response });
788
+ log.info("getShopifyAppInstallByShop", { response });
794
789
  return response;
795
790
  };
796
791
  };
797
792
 
798
793
  // src/clients/third-party/shopify-client.ts
799
- import * as log10 from "lambda-log";
800
794
  var _ShopifyClient = class {
801
795
  };
802
796
  var ShopifyClient = _ShopifyClient;
@@ -840,9 +834,9 @@ __publicField(ShopifyClient, "registerWebhookTopic", async (shop, accessToken, e
840
834
  };
841
835
  const res = await client2.post(url, payload, { headers: { "X-Shopify-Access-Token": accessToken } });
842
836
  if (res.status >= 400) {
843
- log10.error("Failed to register Webhook Topic", { shop, accessToken, eventBridgeArn, topic, url, payload });
837
+ Logger.error("Failed to register Webhook Topic", { shop, accessToken, eventBridgeArn, topic, url, payload });
844
838
  }
845
- log10.debug("Shopify Client Webhook Registration Response", { registrationResponse: res });
839
+ Logger.debug("Shopify Client Webhook Registration Response", { registrationResponse: res });
846
840
  return res;
847
841
  });
848
842
  __publicField(ShopifyClient, "updateShopifyAppMetafield", async (shop, accessToken, pixelId) => {
@@ -857,7 +851,7 @@ __publicField(ShopifyClient, "updateShopifyAppMetafield", async (shop, accessTok
857
851
  };
858
852
  const res = await _ShopifyClient.genericShopifyPost(url, accessToken, payload);
859
853
  if (res.status >= 400) {
860
- log10.error("Failed to update Shopify app Metafield ", { shop, accessToken, url, payload });
854
+ Logger.error("Failed to update Shopify app Metafield ", { shop, accessToken, url, payload });
861
855
  }
862
856
  return res;
863
857
  });
@@ -865,7 +859,7 @@ __publicField(ShopifyClient, "getShopifyStoreProperties", async (shop, accessTok
865
859
  const url = `https://${shop}/admin/api/${_ShopifyClient._shopify_api_version}/shop.json`;
866
860
  const res = await _ShopifyClient.genericShopifyGet(url, accessToken);
867
861
  if (res.status >= 400) {
868
- log10.error("Failed to get Shopify Store Properties", { shop, accessToken, url });
862
+ Logger.error("Failed to get Shopify Store Properties", { shop, accessToken, url });
869
863
  }
870
864
  return res;
871
865
  });
@@ -880,7 +874,7 @@ __publicField(ShopifyClient, "createAppSubscription", async (shop, accessToken,
880
874
  };
881
875
  const res = await _ShopifyClient.genericShopifyPost(url, accessToken, { recurring_application_charge });
882
876
  if (res.status >= 400) {
883
- log10.error("Failed to create App Subscription", { shop, accessToken, url });
877
+ Logger.error("Failed to create App Subscription", { shop, accessToken, url });
884
878
  }
885
879
  return res;
886
880
  });
@@ -889,7 +883,7 @@ __publicField(ShopifyClient, "cancelAppSubscription", async (shop, accessToken,
889
883
  const client2 = axiosHttpService();
890
884
  const res = await client2.delete(url, { headers: { "X-Shopify-Access-Token": accessToken } });
891
885
  if (res.status !== 200) {
892
- log10.error("Failed to cancel recurring App billing", { shop, accessToken, url });
886
+ Logger.error("Failed to cancel recurring App billing", { shop, accessToken, url });
893
887
  }
894
888
  return res;
895
889
  });
@@ -897,50 +891,31 @@ __publicField(ShopifyClient, "listAppSubscriptions", async (shop, accessToken) =
897
891
  const url = `https://${shop}/admin/api/${_ShopifyClient._shopify_api_version}/recurring_application_charges.json`;
898
892
  const res = await _ShopifyClient.genericShopifyGet(url, accessToken);
899
893
  if (res.status >= 400) {
900
- log10.error("Failed to get App Subscriptions", { shop, accessToken, url });
894
+ Logger.error("Failed to get App Subscriptions", { shop, accessToken, url });
901
895
  }
902
896
  return res;
903
897
  });
904
898
  __publicField(ShopifyClient, "genericShopifyPost", async (url, accessToken, payload) => {
905
899
  const client2 = axiosHttpService();
906
900
  const res = await client2.post(url, payload, { headers: { "X-Shopify-Access-Token": accessToken, "Content-Type": "application/json" } });
907
- log10.debug("Shopify Client Response", { res });
901
+ Logger.debug("Shopify Client Response", { res });
908
902
  return res;
909
903
  });
910
904
  __publicField(ShopifyClient, "genericShopifyGet", async (url, accessToken) => {
911
905
  const client2 = axiosHttpService();
912
906
  const res = await client2.get(url, { headers: { "X-Shopify-Access-Token": accessToken } });
913
- log10.debug("Shopify Client Response", { res });
907
+ Logger.debug("Shopify Client Response", { res });
914
908
  return res;
915
909
  });
916
910
  __publicField(ShopifyClient, "genericShopifyPut", async (url, accessToken, payload) => {
917
911
  const client2 = axiosHttpService();
918
912
  const res = await client2.put(url, payload, { headers: { "X-Shopify-Access-Token": accessToken } });
919
- log10.debug("Shopify Client Response", { res });
913
+ Logger.debug("Shopify Client Response", { res });
920
914
  return res;
921
915
  });
922
916
 
923
- // src/helpers/input-validation-helper.ts
924
- import * as log11 from "lambda-log";
925
- var validateInput = (schema, input) => {
926
- const { error: error8, value } = schema.validate(input);
927
- if (error8) {
928
- log11.info("", { error: error8 });
929
- const httperr = HttpError.badRequest("Bad Request", {
930
- errors: error8.details.map((detail) => ({
931
- message: detail?.message,
932
- key: detail?.context?.key,
933
- path: detail?.path
934
- }))
935
- });
936
- log11.info("", { httperr });
937
- throw httperr;
938
- }
939
- return value;
940
- };
941
-
942
917
  // src/helpers/logging-helper.ts
943
- import * as log12 from "lambda-log";
918
+ import * as log2 from "lambda-log";
944
919
  var stage = process?.env?.STAGE;
945
920
  var LEVEL = process?.env?.LOG_LEVEL ?? "info";
946
921
  var LogLevelId = {
@@ -950,36 +925,59 @@ var LogLevelId = {
950
925
  warn: 3,
951
926
  error: 4
952
927
  };
953
- var configureLogger = (event, context, debug7 = LEVEL === "debug") => {
954
- log12.options.meta.stage = stage;
955
- log12.options.meta.source_name = context?.functionName || "unknown";
956
- log12.options.meta.awsRequestId = context?.awsRequestId || "unknown";
957
- log12.options.meta.lambdaEvent = event;
958
- log12.options.debug = debug7;
928
+ var configureLogger = (event, context, debug = LEVEL === "debug") => {
929
+ log2.options.meta.stage = stage;
930
+ log2.options.meta.source_name = context?.functionName || "unknown";
931
+ log2.options.meta.awsRequestId = context?.awsRequestId || "unknown";
932
+ log2.options.meta.lambdaEvent = event;
933
+ log2.options.debug = debug;
959
934
  };
960
935
  var Logger = {
936
+ log: (logLevel, msg, meta, tags) => {
937
+ if (LogLevelId[logLevel] >= LogLevelId[LEVEL]) {
938
+ log2.log(logLevel, msg, meta, tags);
939
+ }
940
+ },
961
941
  debug: (msg, meta, tags) => {
962
942
  if (LogLevelId["debug"] >= LogLevelId[LEVEL]) {
963
- log12.debug(msg, meta, tags);
943
+ Logger.debug(msg, meta, tags);
964
944
  }
965
945
  },
966
946
  info: (msg, meta, tags) => {
967
947
  if (LogLevelId["info"] >= LogLevelId[LEVEL]) {
968
- log12.info(msg, meta, tags);
948
+ log2.info(msg, meta, tags);
969
949
  }
970
950
  },
971
951
  warn: (msg, meta, tags) => {
972
952
  if (LogLevelId["warn"] >= LogLevelId[LEVEL]) {
973
- log12.warn(msg, meta, tags);
953
+ log2.warn(msg, meta, tags);
974
954
  }
975
955
  },
976
956
  error: (msg, meta, tags) => {
977
957
  if (LogLevelId["error"] >= LogLevelId[LEVEL]) {
978
- log12.error(msg, meta, tags);
958
+ Logger.error(msg, meta, tags);
979
959
  }
980
960
  }
981
961
  };
982
962
 
963
+ // src/helpers/input-validation-helper.ts
964
+ var validateInput = (schema, input) => {
965
+ const { error, value } = schema.validate(input);
966
+ if (error) {
967
+ Logger.info("", { error });
968
+ const httperr = HttpError.badRequest("Bad Request", {
969
+ errors: error.details.map((detail) => ({
970
+ message: detail?.message,
971
+ key: detail?.context?.key,
972
+ path: detail?.path
973
+ }))
974
+ });
975
+ Logger.error("validation failure", { httperr });
976
+ throw httperr;
977
+ }
978
+ return value;
979
+ };
980
+
983
981
  // src/helpers/response-helper.ts
984
982
  var success = (body) => {
985
983
  return buildResponse(200, body);
@@ -987,13 +985,13 @@ var success = (body) => {
987
985
  var defaultError = {
988
986
  message: "internalServerError"
989
987
  };
990
- var failure = (error8, statusCode = 500) => {
991
- statusCode = error8?.statusCode ?? statusCode;
988
+ var failure = (error, statusCode = 500) => {
989
+ statusCode = error?.statusCode ?? statusCode;
992
990
  let body = defaultError;
993
- if (error8?.body) {
994
- body = error8.body;
995
- } else if (error8?.message) {
996
- body = { message: error8.message };
991
+ if (error?.body) {
992
+ body = error.body;
993
+ } else if (error?.message) {
994
+ body = { message: error.message };
997
995
  } else if (statusCode === 500) {
998
996
  body = defaultError;
999
997
  }
@@ -1017,7 +1015,6 @@ var buildResponse = (statusCode, body = {}) => {
1017
1015
 
1018
1016
  // src/helpers/shopify-helper.ts
1019
1017
  import { createHmac } from "crypto";
1020
- import * as log13 from "lambda-log";
1021
1018
 
1022
1019
  // src/libs/url.ts
1023
1020
  var mapObjectToQueryString = (inputObj) => {
@@ -1038,14 +1035,14 @@ var isShopifyRequestValid = (validationParams, validationHmac, shopifyAppApiSecr
1038
1035
  return generatedHash === validationHmac;
1039
1036
  };
1040
1037
  var validateShopifyRequest = (validationParams, validationHmac, shopifyAppApiSecret) => {
1041
- log13.info("Validating shopify request is authentic", { validationParams });
1038
+ Logger.info("Validating shopify request is authentic", { validationParams });
1042
1039
  const isValid = isShopifyRequestValid(validationParams, validationHmac, shopifyAppApiSecret);
1043
1040
  if (!isValid) {
1044
1041
  const message = "Failed: Shopify Request hmac validation";
1045
- log13.error(message);
1042
+ Logger.error(message);
1046
1043
  throw HttpError.badRequest(message);
1047
1044
  }
1048
- log13.info("Sucess: Shopify Request hmac validation");
1045
+ Logger.info("Sucess: Shopify Request hmac validation");
1049
1046
  return true;
1050
1047
  };
1051
1048