@etainabl/nodejs-sdk 1.3.152 → 1.3.154

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
@@ -422,6 +422,7 @@ interface Account<IDType = ObjectId | string> {
422
422
  reportingType?: string;
423
423
  solarType?: 'generation' | 'export';
424
424
  consumptionSource?: 'primary' | 'sub' | 'primary-sub';
425
+ consumptionPriority?: ('hh' | 'reading' | 'invoice' | 'custom')[];
425
426
  esec?: 'a' | 'b' | 'c' | 'd' | 'e' | 'g' | 'h' | 'j' | 'k' | 'l' | 'm' | 'n' | 'p' | 'q' | 'r' | 's' | 't' | 'u';
426
427
  portal?: PortalAccountSchema;
427
428
  deviceId?: string;
@@ -611,6 +612,7 @@ type FormattedConsumption = Omit<Consumption<string, string>, '_id'>;
611
612
  type FormattedReading = Omit<Reading<string, string>, '_id'>;
612
613
  type FormattedInvoice = Omit<Invoice<string, string>, '_id' | 's3Key'>;
613
614
  interface HandleErrorParams {
615
+ context: Context;
614
616
  etnApi: ReturnType<typeof _default$4>;
615
617
  automationRun: AutomationRun<string>;
616
618
  lambdaSource: string;
@@ -640,7 +642,7 @@ interface UploadCsv {
640
642
  declare function sendEmail(lambdaSource: string, context: Context, error: Error, destinations: string[]): Promise<_aws_sdk_client_ses.SendEmailCommandOutput>;
641
643
  declare function createCsv(data: (FormattedConsumption | FormattedReading | FormattedInvoice)[]): string;
642
644
  declare function uploadCsv({ csvContent, automationRun, s3Client, orgFilename, collectionType }: UploadCsv): Promise<string>;
643
- declare function handleError({ etnApi, automationRun, error, lambdaSource, accountId, automation, messageId }: HandleErrorParams): Promise<void>;
645
+ declare function handleError({ context, etnApi, automationRun, error, lambdaSource, accountId, automation, messageId }: HandleErrorParams): Promise<void>;
644
646
  declare function deleteMessage(queueUrl: string, receiptHandle: string, sqsClient?: SQSClient): Promise<void>;
645
647
 
646
648
  type integrations_CollectionType = CollectionType;
@@ -1351,6 +1353,17 @@ interface ReportTemplate<IDType = ObjectId | string> {
1351
1353
  updatedAt?: Date;
1352
1354
  }
1353
1355
 
1356
+ interface Setting<IDType = ObjectId | string> {
1357
+ _id: IDType;
1358
+ type: string;
1359
+ name: string;
1360
+ code: string;
1361
+ formSchema?: object;
1362
+ values: object | string[] | object[];
1363
+ sideBarPosition: number;
1364
+ readOnly: boolean;
1365
+ }
1366
+
1354
1367
  interface PortalSupplierSchema extends Portal {
1355
1368
  concurrent: boolean;
1356
1369
  checkInvoiceFilenames: boolean;
@@ -1556,6 +1569,7 @@ declare const _default$4: (auth: AuthOptions, instanceOptions?: CreateAxiosDefau
1556
1569
  searchAutomationRun: (options?: AxiosRequestConfig) => Promise<any>;
1557
1570
  updateAutomationRunAccountResults: (id: string, data: any, options?: AxiosRequestConfig) => Promise<AutomationRun<string, string | Date>>;
1558
1571
  globalSearch: (options?: AxiosRequestConfig) => Promise<any>;
1572
+ getSettings: <P = Setting<string>>(options?: AxiosRequestConfig) => Promise<ETNPagedResponse<P>>;
1559
1573
  };
1560
1574
 
1561
1575
  interface EmailTemplateOptions {
@@ -1797,4 +1811,4 @@ declare namespace scrapers {
1797
1811
  export type { scrapers_ETNAccount as ETNAccount };
1798
1812
  }
1799
1813
 
1800
- export { type AccessLevel, type Account, type AccountResult, type Asset, type Automation, type AutomationRun, type AutomationRunLog, type AutomationRunSummary, type AutomationService, type AutomationServiceCategory, type AutomationSource, type Company, type CompanyInvoiceValidationRule, type CompanyInvoiceValidationSettings, type Consumption, type CreateScraperRunParams, type DataIngest, type DefaultField, type ETNEvent, type ETNPagedResponse$1 as ETNPagedResponse, type Email, type Entity, type FileFormat, type ImportTemplate, type Invoice, type InvoiceCapture, type InvoiceCaptureMetadata, type InvoiceCaptureMetadataResult, type InvoiceRate, type InvoiceRateType, type InvoiceValidation, type InvoiceValidationInvoice, type InvoiceValidationResults, type InvoiceValidationRule, type InvoiceValues, type Log, type Portal, type PortalSupplierSchema, type Problem, type ProblemCodes, type ProblemDetails, type Reading, type Report, type ReportMetadata, type ReportSource, type ReportSourceIdItem, type ReportTemplate, type ReportType, type ScraperRun, type SourceType, type Supplier, type User, type UtilityType, type WasteCategories, type WasteTypes, _default$4 as api, consumption, _default$1 as db, _default$3 as emailTemplate, integrations, _default$2 as logger, monitoring, index as openai, reporting, scrapers, _default as slack, units, index$1 as utils };
1814
+ export { type AccessLevel, type Account, type AccountResult, type Asset, type Automation, type AutomationRun, type AutomationRunLog, type AutomationRunSummary, type AutomationService, type AutomationServiceCategory, type AutomationSource, type Company, type CompanyInvoiceValidationRule, type CompanyInvoiceValidationSettings, type Consumption, type CreateScraperRunParams, type DataIngest, type DefaultField, type ETNEvent, type ETNPagedResponse$1 as ETNPagedResponse, type Email, type Entity, type FileFormat, type ImportTemplate, type Invoice, type InvoiceCapture, type InvoiceCaptureMetadata, type InvoiceCaptureMetadataResult, type InvoiceRate, type InvoiceRateType, type InvoiceValidation, type InvoiceValidationInvoice, type InvoiceValidationResults, type InvoiceValidationRule, type InvoiceValues, type Log, type Portal, type PortalSupplierSchema, type Problem, type ProblemCodes, type ProblemDetails, type Reading, type Report, type ReportMetadata, type ReportSource, type ReportSourceIdItem, type ReportTemplate, type ReportType, type ScraperRun, type Setting, type SourceType, type Supplier, type User, type UtilityType, type WasteCategories, type WasteTypes, _default$4 as api, consumption, _default$1 as db, _default$3 as emailTemplate, integrations, _default$2 as logger, monitoring, index as openai, reporting, scrapers, _default as slack, units, index$1 as utils };
package/dist/index.d.ts CHANGED
@@ -422,6 +422,7 @@ interface Account<IDType = ObjectId | string> {
422
422
  reportingType?: string;
423
423
  solarType?: 'generation' | 'export';
424
424
  consumptionSource?: 'primary' | 'sub' | 'primary-sub';
425
+ consumptionPriority?: ('hh' | 'reading' | 'invoice' | 'custom')[];
425
426
  esec?: 'a' | 'b' | 'c' | 'd' | 'e' | 'g' | 'h' | 'j' | 'k' | 'l' | 'm' | 'n' | 'p' | 'q' | 'r' | 's' | 't' | 'u';
426
427
  portal?: PortalAccountSchema;
427
428
  deviceId?: string;
@@ -611,6 +612,7 @@ type FormattedConsumption = Omit<Consumption<string, string>, '_id'>;
611
612
  type FormattedReading = Omit<Reading<string, string>, '_id'>;
612
613
  type FormattedInvoice = Omit<Invoice<string, string>, '_id' | 's3Key'>;
613
614
  interface HandleErrorParams {
615
+ context: Context;
614
616
  etnApi: ReturnType<typeof _default$4>;
615
617
  automationRun: AutomationRun<string>;
616
618
  lambdaSource: string;
@@ -640,7 +642,7 @@ interface UploadCsv {
640
642
  declare function sendEmail(lambdaSource: string, context: Context, error: Error, destinations: string[]): Promise<_aws_sdk_client_ses.SendEmailCommandOutput>;
641
643
  declare function createCsv(data: (FormattedConsumption | FormattedReading | FormattedInvoice)[]): string;
642
644
  declare function uploadCsv({ csvContent, automationRun, s3Client, orgFilename, collectionType }: UploadCsv): Promise<string>;
643
- declare function handleError({ etnApi, automationRun, error, lambdaSource, accountId, automation, messageId }: HandleErrorParams): Promise<void>;
645
+ declare function handleError({ context, etnApi, automationRun, error, lambdaSource, accountId, automation, messageId }: HandleErrorParams): Promise<void>;
644
646
  declare function deleteMessage(queueUrl: string, receiptHandle: string, sqsClient?: SQSClient): Promise<void>;
645
647
 
646
648
  type integrations_CollectionType = CollectionType;
@@ -1351,6 +1353,17 @@ interface ReportTemplate<IDType = ObjectId | string> {
1351
1353
  updatedAt?: Date;
1352
1354
  }
1353
1355
 
1356
+ interface Setting<IDType = ObjectId | string> {
1357
+ _id: IDType;
1358
+ type: string;
1359
+ name: string;
1360
+ code: string;
1361
+ formSchema?: object;
1362
+ values: object | string[] | object[];
1363
+ sideBarPosition: number;
1364
+ readOnly: boolean;
1365
+ }
1366
+
1354
1367
  interface PortalSupplierSchema extends Portal {
1355
1368
  concurrent: boolean;
1356
1369
  checkInvoiceFilenames: boolean;
@@ -1556,6 +1569,7 @@ declare const _default$4: (auth: AuthOptions, instanceOptions?: CreateAxiosDefau
1556
1569
  searchAutomationRun: (options?: AxiosRequestConfig) => Promise<any>;
1557
1570
  updateAutomationRunAccountResults: (id: string, data: any, options?: AxiosRequestConfig) => Promise<AutomationRun<string, string | Date>>;
1558
1571
  globalSearch: (options?: AxiosRequestConfig) => Promise<any>;
1572
+ getSettings: <P = Setting<string>>(options?: AxiosRequestConfig) => Promise<ETNPagedResponse<P>>;
1559
1573
  };
1560
1574
 
1561
1575
  interface EmailTemplateOptions {
@@ -1797,4 +1811,4 @@ declare namespace scrapers {
1797
1811
  export type { scrapers_ETNAccount as ETNAccount };
1798
1812
  }
1799
1813
 
1800
- export { type AccessLevel, type Account, type AccountResult, type Asset, type Automation, type AutomationRun, type AutomationRunLog, type AutomationRunSummary, type AutomationService, type AutomationServiceCategory, type AutomationSource, type Company, type CompanyInvoiceValidationRule, type CompanyInvoiceValidationSettings, type Consumption, type CreateScraperRunParams, type DataIngest, type DefaultField, type ETNEvent, type ETNPagedResponse$1 as ETNPagedResponse, type Email, type Entity, type FileFormat, type ImportTemplate, type Invoice, type InvoiceCapture, type InvoiceCaptureMetadata, type InvoiceCaptureMetadataResult, type InvoiceRate, type InvoiceRateType, type InvoiceValidation, type InvoiceValidationInvoice, type InvoiceValidationResults, type InvoiceValidationRule, type InvoiceValues, type Log, type Portal, type PortalSupplierSchema, type Problem, type ProblemCodes, type ProblemDetails, type Reading, type Report, type ReportMetadata, type ReportSource, type ReportSourceIdItem, type ReportTemplate, type ReportType, type ScraperRun, type SourceType, type Supplier, type User, type UtilityType, type WasteCategories, type WasteTypes, _default$4 as api, consumption, _default$1 as db, _default$3 as emailTemplate, integrations, _default$2 as logger, monitoring, index as openai, reporting, scrapers, _default as slack, units, index$1 as utils };
1814
+ export { type AccessLevel, type Account, type AccountResult, type Asset, type Automation, type AutomationRun, type AutomationRunLog, type AutomationRunSummary, type AutomationService, type AutomationServiceCategory, type AutomationSource, type Company, type CompanyInvoiceValidationRule, type CompanyInvoiceValidationSettings, type Consumption, type CreateScraperRunParams, type DataIngest, type DefaultField, type ETNEvent, type ETNPagedResponse$1 as ETNPagedResponse, type Email, type Entity, type FileFormat, type ImportTemplate, type Invoice, type InvoiceCapture, type InvoiceCaptureMetadata, type InvoiceCaptureMetadataResult, type InvoiceRate, type InvoiceRateType, type InvoiceValidation, type InvoiceValidationInvoice, type InvoiceValidationResults, type InvoiceValidationRule, type InvoiceValues, type Log, type Portal, type PortalSupplierSchema, type Problem, type ProblemCodes, type ProblemDetails, type Reading, type Report, type ReportMetadata, type ReportSource, type ReportSourceIdItem, type ReportTemplate, type ReportType, type ScraperRun, type Setting, type SourceType, type Supplier, type User, type UtilityType, type WasteCategories, type WasteTypes, _default$4 as api, consumption, _default$1 as db, _default$3 as emailTemplate, integrations, _default$2 as logger, monitoring, index as openai, reporting, scrapers, _default as slack, units, index$1 as utils };
package/dist/index.js CHANGED
@@ -16580,7 +16580,9 @@ var api_default = (auth, instanceOptions = {}) => {
16580
16580
  searchAutomationRun: factory.get(etainablApi, "automation-runs", "search"),
16581
16581
  updateAutomationRunAccountResults: factory.update(etainablApi, "automation-runs", "account-results"),
16582
16582
  // global search
16583
- globalSearch: factory.get(etainablApi, "global-search", "search")
16583
+ globalSearch: factory.get(etainablApi, "global-search", "search"),
16584
+ // global settings
16585
+ getSettings: factory.list(etainablApi, "settings")
16584
16586
  };
16585
16587
  } catch (e7) {
16586
16588
  log.error(e7);
@@ -25546,12 +25548,14 @@ async function uploadCsv({ csvContent, automationRun, s3Client, orgFilename, col
25546
25548
  throw new Error(error);
25547
25549
  }
25548
25550
  }
25549
- async function handleError({ etnApi, automationRun, error, lambdaSource, accountId, automation, messageId }) {
25551
+ async function handleError({ context, etnApi, automationRun, error, lambdaSource, accountId, automation, messageId }) {
25550
25552
  await etnApi.createAutomationRunLog(automationRun._id, {
25551
25553
  message: error.message,
25552
25554
  status: "error",
25553
25555
  lambdaSource,
25554
- lambdaMessageId: messageId
25556
+ lambdaMessageId: messageId,
25557
+ lambdaLogStreamName: context.logStreamName,
25558
+ lambdaRequestId: context.awsRequestId
25555
25559
  });
25556
25560
  const { description, service } = automation;
25557
25561
  const message = automationRun.source?.fileName ? `Automation "${description || service}" FAILED while processing file: ${automationRun.source.fileName}` : `Automation "${description}" FAILED.`;