@etainabl/nodejs-sdk 1.3.125 → 1.3.127

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.d.cts CHANGED
@@ -623,6 +623,7 @@ interface HandleErrorParams {
623
623
  lambdaSource: string;
624
624
  error: Error;
625
625
  accountId?: string;
626
+ automation: Automation<string>;
626
627
  }
627
628
  declare const collectionTypes: readonly ["readings", "consumptions", "invoices"];
628
629
  declare const errorCodes: readonly ["ACCOUNT_NOT_FOUND", "INVALID_DATE_FORMAT", "INVALID_TIME_FORMAT", "COLUMN_LIMIT_EXCEEDED", "INVALID_TIMESTAMP", "MISSING_DEVICE_ID", "UNSUPPORTED_UTILITY_TYPE", "VALIDATION_ERROR", "METER_READS_ZERO"];
@@ -638,7 +639,7 @@ interface UploadCsv {
638
639
  declare function sendEmail(lambdaSource: string, context: Context, error: Error, destinations: string[]): Promise<_aws_sdk_client_ses.SendEmailCommandOutput>;
639
640
  declare function createCsv(data: (FormattedConsumption | FormattedReading | FormattedInvoice)[]): string;
640
641
  declare function uploadCsv({ csvContent, automationRun, s3Client, orgFilename, collectionType }: UploadCsv): Promise<string>;
641
- declare function handleError({ etnApi, automationRun, error, lambdaSource, accountId }: HandleErrorParams): Promise<void>;
642
+ declare function handleError({ etnApi, automationRun, error, lambdaSource, accountId, automation }: HandleErrorParams): Promise<void>;
642
643
  declare function deleteMessage(queueUrl: string, receiptHandle: string, sqsClient?: SQSClient): Promise<void>;
643
644
 
644
645
  type integrations_CollectionType = CollectionType;
@@ -670,6 +671,7 @@ interface AutomationRunLog<DateType = Date | string> {
670
671
  interface AccountResult<IDType = ObjectId | string, DateType = Date | string> {
671
672
  accountId: IDType;
672
673
  mpan: string;
674
+ name: string;
673
675
  deviceId?: string;
674
676
  status: 'success' | 'warning' | 'error' | 'running';
675
677
  rowsProcessed?: number;
@@ -731,7 +733,6 @@ interface AutomationRun<IDType = ObjectId | string, DateType = Date | string> {
731
733
  _id: IDType;
732
734
  automationId: IDType;
733
735
  companyId: IDType;
734
- description: string;
735
736
  active: boolean;
736
737
  category: 'dataFetcher' | 'dataExtractor';
737
738
  status: 'running' | 'success' | 'failed' | 'completedWithWarnings';
@@ -793,7 +794,7 @@ interface InvoiceValidationInvoice {
793
794
  endPage: number;
794
795
  supplyAddress: string;
795
796
  utilityType: string;
796
- meterIndex: number;
797
+ meterId: string;
797
798
  accountId?: string;
798
799
  supplierId?: string;
799
800
  }
@@ -815,8 +816,7 @@ interface InvoiceValidationResults<IDType = ObjectId | string> {
815
816
  comment: string;
816
817
  status: 'passed' | 'warning' | 'failed' | 'error';
817
818
  originalStatus: 'passed' | 'warning' | 'failed' | 'error';
818
- invoiceIndex?: number;
819
- meterIndex?: number;
819
+ meterId?: string;
820
820
  checkedAt: Date;
821
821
  }
822
822
  interface InvoiceValidation<IDType = ObjectId | string> {
package/dist/index.d.ts CHANGED
@@ -623,6 +623,7 @@ interface HandleErrorParams {
623
623
  lambdaSource: string;
624
624
  error: Error;
625
625
  accountId?: string;
626
+ automation: Automation<string>;
626
627
  }
627
628
  declare const collectionTypes: readonly ["readings", "consumptions", "invoices"];
628
629
  declare const errorCodes: readonly ["ACCOUNT_NOT_FOUND", "INVALID_DATE_FORMAT", "INVALID_TIME_FORMAT", "COLUMN_LIMIT_EXCEEDED", "INVALID_TIMESTAMP", "MISSING_DEVICE_ID", "UNSUPPORTED_UTILITY_TYPE", "VALIDATION_ERROR", "METER_READS_ZERO"];
@@ -638,7 +639,7 @@ interface UploadCsv {
638
639
  declare function sendEmail(lambdaSource: string, context: Context, error: Error, destinations: string[]): Promise<_aws_sdk_client_ses.SendEmailCommandOutput>;
639
640
  declare function createCsv(data: (FormattedConsumption | FormattedReading | FormattedInvoice)[]): string;
640
641
  declare function uploadCsv({ csvContent, automationRun, s3Client, orgFilename, collectionType }: UploadCsv): Promise<string>;
641
- declare function handleError({ etnApi, automationRun, error, lambdaSource, accountId }: HandleErrorParams): Promise<void>;
642
+ declare function handleError({ etnApi, automationRun, error, lambdaSource, accountId, automation }: HandleErrorParams): Promise<void>;
642
643
  declare function deleteMessage(queueUrl: string, receiptHandle: string, sqsClient?: SQSClient): Promise<void>;
643
644
 
644
645
  type integrations_CollectionType = CollectionType;
@@ -670,6 +671,7 @@ interface AutomationRunLog<DateType = Date | string> {
670
671
  interface AccountResult<IDType = ObjectId | string, DateType = Date | string> {
671
672
  accountId: IDType;
672
673
  mpan: string;
674
+ name: string;
673
675
  deviceId?: string;
674
676
  status: 'success' | 'warning' | 'error' | 'running';
675
677
  rowsProcessed?: number;
@@ -731,7 +733,6 @@ interface AutomationRun<IDType = ObjectId | string, DateType = Date | string> {
731
733
  _id: IDType;
732
734
  automationId: IDType;
733
735
  companyId: IDType;
734
- description: string;
735
736
  active: boolean;
736
737
  category: 'dataFetcher' | 'dataExtractor';
737
738
  status: 'running' | 'success' | 'failed' | 'completedWithWarnings';
@@ -793,7 +794,7 @@ interface InvoiceValidationInvoice {
793
794
  endPage: number;
794
795
  supplyAddress: string;
795
796
  utilityType: string;
796
- meterIndex: number;
797
+ meterId: string;
797
798
  accountId?: string;
798
799
  supplierId?: string;
799
800
  }
@@ -815,8 +816,7 @@ interface InvoiceValidationResults<IDType = ObjectId | string> {
815
816
  comment: string;
816
817
  status: 'passed' | 'warning' | 'failed' | 'error';
817
818
  originalStatus: 'passed' | 'warning' | 'failed' | 'error';
818
- invoiceIndex?: number;
819
- meterIndex?: number;
819
+ meterId?: string;
820
820
  checkedAt: Date;
821
821
  }
822
822
  interface InvoiceValidation<IDType = ObjectId | string> {
package/dist/index.js CHANGED
@@ -21654,8 +21654,8 @@ var dataFetchersIds = ["bacnet", "solis", "solarman", "gridfetch", "smartflow",
21654
21654
  function sendEmail(lambdaSource, context, error, destinations) {
21655
21655
  const sesClient = new import_client_ses.SESClient({ region: "eu-west-1" });
21656
21656
  const template = emailTemplate_default({
21657
- title: `WARNING: ${lambdaSource} Lambda Failed`,
21658
- alertLevel: "warning",
21657
+ title: `CRITICAL: ${lambdaSource} Lambda Failed`,
21658
+ alertLevel: "critical",
21659
21659
  message: `Error: ${error.message}. AWS Log Stream: ${context.logStreamName}, AWS Request ID: ${context.awsRequestId}`
21660
21660
  });
21661
21661
  const emailCommand = new import_client_ses.SendEmailCommand({
@@ -21664,7 +21664,7 @@ function sendEmail(lambdaSource, context, error, destinations) {
21664
21664
  ToAddresses: destinations
21665
21665
  },
21666
21666
  Message: {
21667
- Subject: { Data: `WARNING: New Alert for the ${lambdaSource}` },
21667
+ Subject: { Data: `CRITICAL: New Alert for the ${lambdaSource}` },
21668
21668
  Body: {
21669
21669
  Html: { Data: template }
21670
21670
  }
@@ -21752,27 +21752,28 @@ async function uploadCsv({ csvContent, automationRun, s3Client, orgFilename, col
21752
21752
  throw new Error(error);
21753
21753
  }
21754
21754
  }
21755
- async function handleError({ etnApi, automationRun, error, lambdaSource, accountId }) {
21755
+ async function handleError({ etnApi, automationRun, error, lambdaSource, accountId, automation }) {
21756
21756
  await etnApi.createAutomationRunLog(automationRun._id, {
21757
21757
  message: error.message,
21758
21758
  status: "error",
21759
21759
  lambdaSource
21760
21760
  });
21761
- const message = automationRun.source?.fileName ? `Automation "${automationRun.description}" FAILED while processing file: ${automationRun.source.fileName}` : `Automation "${automationRun.description}" FAILED.`;
21761
+ const { description, service } = automation;
21762
+ const message = automationRun.source?.fileName ? `Automation "${description || service}" FAILED while processing file: ${automationRun.source.fileName}` : `Automation "${description}" FAILED.`;
21762
21763
  await etnApi.createLog({
21763
21764
  message,
21764
21765
  context: {
21765
21766
  status: "error",
21766
21767
  error: error.message,
21767
21768
  automationId: automationRun.automationId,
21768
- automationDescription: automationRun.description,
21769
+ automationDescription: description,
21769
21770
  automationRunId: automationRun._id
21770
21771
  },
21771
21772
  type: "automation-ingest",
21772
21773
  userSub: lambdaSource,
21773
21774
  companyId: automationRun.companyId
21774
21775
  });
21775
- if (accountId) {
21776
+ if (automationRun.category === "dataFetcher" && accountId) {
21776
21777
  await etnApi.updateAccountStatusForAutomation(automationRun.automationId, accountId, { status: "error" });
21777
21778
  }
21778
21779
  }