@etainabl/nodejs-sdk 1.3.175 → 1.3.178

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
@@ -474,59 +474,27 @@ interface Action {
474
474
  icon?: string;
475
475
  }
476
476
 
477
- interface CustomAlertTemplateAction extends Action {
478
- api?: {
479
- endpoint: string;
480
- method: string;
481
- payload?: Record<string, any>;
482
- };
483
- }
484
- interface CustomAlertTemplateConfigOption {
485
- label: string;
486
- value: string;
487
- }
488
- interface CustomAlertTemplateConfig {
489
- type: 'text' | 'number' | 'password' | 'textarea' | 'radio' | 'select' | 'select2' | 'select-old' | 'select-multiple' | 'select-array' | 'select-array-list' | 'select-array-search' | 'multi-check-options' | 'tag-manager' | 'datePicker' | 'dateTimePicker' | 'dateRangePicker' | 'file' | 'slider';
490
- label: string;
491
- options?: CustomAlertTemplateConfigOption[];
492
- default?: string | null;
493
- required?: boolean;
494
- placeholder?: string;
495
- }
496
- interface CustomAlertTemplate<ID = string, DateType = Date | string> {
497
- _id: ID;
498
- name: string;
499
- description?: string;
500
- key: string;
501
- titleTemplate: string;
502
- messageTemplate: string;
503
- configSchema?: Record<string, CustomAlertTemplateConfig>;
504
- active: boolean;
505
- isSystemTemplate: boolean;
506
- createdAt?: DateType;
507
- updatedAt?: DateType;
508
- deleted?: boolean;
509
- deletedAt?: DateType;
510
- deletedBy?: string;
511
- companyId?: ID;
512
- }
513
-
514
477
  interface CustomAlertTrigger<ID = string, DateType = Date | string, metadataType = {
515
478
  [key: string]: any;
516
479
  }> {
517
480
  _id: ID;
518
- templateId?: ID;
481
+ notificationTemplateId: ID;
519
482
  state: 'pending' | 'processing' | 'processed' | 'failed' | 'cancelled';
520
483
  metadata?: metadataType;
484
+ description: string;
521
485
  channels: {
522
486
  inApp: boolean;
523
487
  email: boolean;
524
488
  sms: boolean;
525
489
  };
490
+ severity: 'error' | 'warning' | 'info' | 'success' | 'tip';
491
+ audience?: 'me' | 'allCompanyUsers' | 'userGroup';
492
+ userGroupId?: ID;
526
493
  processedAt?: DateType;
527
494
  lastTriggeredEvent?: DateType;
528
495
  companyId: ID;
529
496
  userSub: string;
497
+ active: boolean;
530
498
  createdAt?: DateType;
531
499
  updatedAt?: DateType;
532
500
  deleted?: boolean;
@@ -534,6 +502,14 @@ interface CustomAlertTrigger<ID = string, DateType = Date | string, metadataType
534
502
  deletedBy?: string;
535
503
  }
536
504
 
505
+ interface CustomAlertTriggerQueueMessage {
506
+ triggerId: string;
507
+ jobId: string;
508
+ windowStart?: string;
509
+ windowEnd?: string;
510
+ notificationTemplateId?: string;
511
+ }
512
+
537
513
  interface Address {
538
514
  streetAddress: string;
539
515
  locality?: string;
@@ -1324,6 +1300,29 @@ interface ETNEvent {
1324
1300
  companyId: string;
1325
1301
  }
1326
1302
 
1303
+ type JobStatus = 'queued' | 'running' | 'completed' | 'failed' | 'cancelled';
1304
+ interface Job<ID = string, DateType = Date | string> {
1305
+ _id: ID;
1306
+ type: string;
1307
+ key: string;
1308
+ status: JobStatus;
1309
+ windowStart?: DateType;
1310
+ windowEnd?: DateType;
1311
+ startedAt?: DateType;
1312
+ completedAt?: DateType;
1313
+ heartbeatAt?: DateType;
1314
+ expiresAt?: DateType;
1315
+ error?: string;
1316
+ metadata?: Record<string, any>;
1317
+ companyId?: ID;
1318
+ userSub?: string;
1319
+ createdAt?: DateType;
1320
+ updatedAt?: DateType;
1321
+ deleted?: boolean;
1322
+ deletedAt?: DateType;
1323
+ deletedBy?: string;
1324
+ }
1325
+
1327
1326
  /**
1328
1327
  * Context type mapping for different notification events
1329
1328
  * Each event type has its own structured context data
@@ -1370,6 +1369,7 @@ interface Notification<ID = string, DateType = Date | string> {
1370
1369
  userSub: string;
1371
1370
  toastHasShown?: boolean;
1372
1371
  message?: string;
1372
+ status: string;
1373
1373
  isAcknowledged?: boolean;
1374
1374
  acknowledgedAt?: DateType;
1375
1375
  customAlertTriggerId?: ID;
@@ -1401,52 +1401,107 @@ interface Notification<ID = string, DateType = Date | string> {
1401
1401
  deleted?: boolean;
1402
1402
  deletedAt?: DateType;
1403
1403
  deletedBy?: string;
1404
- companyId: ID;
1404
+ companyId?: ID;
1405
1405
  }
1406
1406
 
1407
- type NotificationTemplateCategory = 'automation' | 'report' | 'team' | 'dataQuality' | 'discussion' | 'scraper';
1407
+ declare const NotificationTemplateCategories: readonly ["automation", "report", "team", "dataQuality", "discussion", "scraper"];
1408
+ type NotificationTemplateCategory = typeof NotificationTemplateCategories[number];
1409
+ declare const EventNamesByCategory: {
1410
+ readonly automation: readonly ["automationFailed", "runCompleted", "hasnotRun", "fileNotExpected"];
1411
+ readonly report: readonly ["reportSuccess", "reportFailed"];
1412
+ readonly team: readonly ["newUserSignIn"];
1413
+ readonly dataQuality: readonly ["thresholdBreached", "approachingThreshold", "readingOverdue", "readingDueSoon", "contractRenewalUpcoming", "contractRenewalOverdue"];
1414
+ readonly discussion: readonly ["commentAdded", "mentionInComment"];
1415
+ readonly scraper: readonly ["scraperLoginError", "scraperHasnotRun", "scraperRunCompleted"];
1416
+ };
1417
+ type AutomationEventName = typeof EventNamesByCategory.automation[number];
1418
+ type ReportEventName = typeof EventNamesByCategory.report[number];
1419
+ type TeamEventName = typeof EventNamesByCategory.team[number];
1420
+ type DataQualityEventName = typeof EventNamesByCategory.dataQuality[number];
1421
+ type DiscussionEventName = typeof EventNamesByCategory.discussion[number];
1422
+ type ScraperEventName = typeof EventNamesByCategory.scraper[number];
1423
+ type NotificationEventName = AutomationEventName | ReportEventName | TeamEventName | DataQualityEventName | DiscussionEventName | ScraperEventName;
1408
1424
  type NotificationTemplateSeverity = 'error' | 'warning' | 'info' | 'success' | 'tip';
1409
1425
  type NotificationTemplateDefaultChannel = 'off' | 'inApp' | 'email' | 'sms';
1426
+ type NotificationTemplateConfigType = 'text' | 'number' | 'password' | 'textarea' | 'radio' | 'select' | 'select2' | 'select-old' | 'select-multiple' | 'select-array' | 'select-array-list' | 'select-array-search' | 'multi-check-options' | 'tag-manager' | 'datePicker' | 'dateTimePicker' | 'dateRangePicker' | 'file' | 'slider';
1427
+ interface NotificationTemplateConfigOption {
1428
+ label: string;
1429
+ value: string;
1430
+ }
1431
+ interface NotificationTemplateConfig {
1432
+ type: NotificationTemplateConfigType;
1433
+ label: string;
1434
+ options?: NotificationTemplateConfigOption[];
1435
+ default?: string | null;
1436
+ required?: boolean;
1437
+ placeholder?: string;
1438
+ }
1439
+ interface NotificationTemplateRoute {
1440
+ name?: string;
1441
+ params?: Record<string, any>;
1442
+ }
1410
1443
  interface NotificationTemplate<ID = string, DateType = Date | string> {
1411
1444
  _id: ID;
1412
1445
  name: string;
1413
1446
  description?: string;
1414
1447
  category: NotificationTemplateCategory;
1415
- eventName: string;
1448
+ eventName: NotificationEventName;
1416
1449
  severity: NotificationTemplateSeverity;
1417
1450
  isSystem?: boolean;
1418
1451
  default: NotificationTemplateDefaultChannel;
1419
- message: string;
1420
- route: {
1421
- name: {
1422
- type: String;
1423
- default: '';
1424
- };
1425
- params?: {
1426
- type: Object;
1427
- default: () => {};
1428
- };
1429
- query?: {
1430
- type: Object;
1431
- default: () => {};
1432
- };
1433
- };
1434
- icon: string;
1452
+ message?: string;
1453
+ route?: NotificationTemplateRoute;
1454
+ icon?: string;
1455
+ config?: Map<string, NotificationTemplateConfig> | Record<string, NotificationTemplateConfig>;
1435
1456
  createdAt?: DateType;
1436
1457
  updatedAt?: DateType;
1437
- deleted?: boolean;
1438
- deletedAt?: DateType;
1439
- deletedBy?: string;
1440
1458
  }
1441
1459
 
1442
1460
  type NotificationContextMap = {
1443
- generalReportGenerated: {
1461
+ reportSuccess: {
1462
+ report: {
1463
+ fileName: string;
1464
+ _id: string;
1465
+ };
1466
+ };
1467
+ reportFailed: {
1444
1468
  report: {
1445
1469
  fileName: string;
1446
- type: string;
1447
1470
  _id: string;
1448
1471
  };
1449
1472
  };
1473
+ automationFailed: {
1474
+ context: {
1475
+ message: string;
1476
+ metadata: {
1477
+ items: {
1478
+ message: string;
1479
+ route: {
1480
+ name: string;
1481
+ query: {
1482
+ id: string;
1483
+ };
1484
+ };
1485
+ }[];
1486
+ };
1487
+ };
1488
+ };
1489
+ readingOverdue: {
1490
+ context: {
1491
+ message: string;
1492
+ metadata: {
1493
+ items: {
1494
+ message: string;
1495
+ route: {
1496
+ name: string;
1497
+ params: {
1498
+ id: string;
1499
+ };
1500
+ };
1501
+ }[];
1502
+ };
1503
+ };
1504
+ };
1450
1505
  };
1451
1506
  type NotificationEventType = keyof NotificationContextMap;
1452
1507
  interface NotificationSQSMessage<E extends NotificationEventType = NotificationEventType> {
@@ -1461,6 +1516,7 @@ interface SendNotificationMessageInput<E extends NotificationEventType> {
1461
1516
  companyId: string;
1462
1517
  userSub: string;
1463
1518
  alertTriggerId?: string;
1519
+ timestamp?: string;
1464
1520
  }
1465
1521
 
1466
1522
  interface Log<IDType = ObjectId | string> {
@@ -1725,11 +1781,6 @@ declare const _default$5: (auth: AuthOptions, instanceOptions?: CreateAxiosDefau
1725
1781
  removeAccount: (id: string, options?: AxiosRequestConfig) => Promise<Account<string>>;
1726
1782
  getAccountSchema: (options?: AxiosRequestConfig) => Promise<any>;
1727
1783
  invalidateAccountCache: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
1728
- getAlertTemplate: (id: string, options?: AxiosRequestConfig) => Promise<CustomAlertTemplate<string, string | Date>>;
1729
- listAlertTemplates: <P = CustomAlertTemplate<string, string | Date>>(options?: AxiosRequestConfig) => Promise<ETNPagedResponse<P>>;
1730
- updateAlertTemplate: (id: string, data: any, options?: AxiosRequestConfig) => Promise<CustomAlertTemplate<string, string | Date>>;
1731
- createAlertTemplate: (data: any, options?: AxiosRequestConfig) => Promise<CustomAlertTemplate<string, string | Date>>;
1732
- removeAlertTemplate: (id: string, options?: AxiosRequestConfig) => Promise<CustomAlertTemplate<string, string | Date>>;
1733
1784
  getAlertTrigger: (id: string, options?: AxiosRequestConfig) => Promise<CustomAlertTrigger<string, string, {
1734
1785
  [key: string]: any;
1735
1786
  }>>;
@@ -1748,6 +1799,16 @@ declare const _default$5: (auth: AuthOptions, instanceOptions?: CreateAxiosDefau
1748
1799
  bulkUpdateAlertTriggers: (data: BulkUpdateCustomAlertTriggersRequest, options?: AxiosRequestConfig) => Promise<ETNBulkUpdateResult>;
1749
1800
  retryAlertTrigger: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
1750
1801
  cancelAlertTrigger: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
1802
+ getCustomAlertTrigger: (id: string, options?: AxiosRequestConfig) => Promise<CustomAlertTrigger<string, string, {
1803
+ [key: string]: any;
1804
+ }>>;
1805
+ listCustomAlertTriggers: <P = CustomAlertTrigger<string, string, {
1806
+ [key: string]: any;
1807
+ }>>(options?: AxiosRequestConfig) => Promise<ETNPagedResponse<P>>;
1808
+ updateCustomAlertTrigger: (id: string, data: any, options?: AxiosRequestConfig) => Promise<CustomAlertTrigger<string, string | Date, {
1809
+ [key: string]: any;
1810
+ }>>;
1811
+ bulkUpdateCustomAlertTriggers: (data: BulkUpdateCustomAlertTriggersRequest, options?: AxiosRequestConfig) => Promise<ETNBulkUpdateResult>;
1751
1812
  getAsset: (id: string, options?: AxiosRequestConfig) => Promise<Asset<string>>;
1752
1813
  listAssets: <P = Asset<string>>(options?: AxiosRequestConfig) => Promise<ETNPagedResponse<P>>;
1753
1814
  updateAsset: (id: string, data: any, options?: AxiosRequestConfig) => Promise<Asset<string>>;
@@ -1803,6 +1864,12 @@ declare const _default$5: (auth: AuthOptions, instanceOptions?: CreateAxiosDefau
1803
1864
  createLog: (data: any, options?: AxiosRequestConfig) => Promise<Log<string>>;
1804
1865
  createLogBulk: (data: any, options?: AxiosRequestConfig) => Promise<Log<string>[]>;
1805
1866
  removeLog: (id: string, options?: AxiosRequestConfig) => Promise<Log<string>>;
1867
+ getJob: (id: string, options?: AxiosRequestConfig) => Promise<Job<string, string | Date>>;
1868
+ listJobs: <P = Job<string, string | Date>>(options?: AxiosRequestConfig) => Promise<ETNPagedResponse<P>>;
1869
+ updateJob: (id: string, data: any, options?: AxiosRequestConfig) => Promise<Job<string, string | Date>>;
1870
+ createJob: (data: any, options?: AxiosRequestConfig) => Promise<Job<string, string | Date>>;
1871
+ createJobBulk: (data: any, options?: AxiosRequestConfig) => Promise<Job<string, string | Date>[]>;
1872
+ removeJob: (id: string, options?: AxiosRequestConfig) => Promise<Job<string, string | Date>>;
1806
1873
  getNotification: (id: string, options?: AxiosRequestConfig) => Promise<Notification<string, string | Date>>;
1807
1874
  listNotifications: <P = Notification<string, string | Date>>(options?: AxiosRequestConfig) => Promise<ETNPagedResponse<P>>;
1808
1875
  updateNotification: (id: string, data: any, options?: AxiosRequestConfig) => Promise<Notification<string, string | Date>>;
@@ -1810,6 +1877,11 @@ declare const _default$5: (auth: AuthOptions, instanceOptions?: CreateAxiosDefau
1810
1877
  bulkCreateNotifications: (data: any, options?: AxiosRequestConfig) => Promise<Notification<string, string | Date>[]>;
1811
1878
  bulkUpdateNotificationDeliveryStatus: (data: any, options?: AxiosRequestConfig) => Promise<ETNBulkUpdateResult>;
1812
1879
  removeNotification: (id: string, options?: AxiosRequestConfig) => Promise<Notification<string, string | Date>>;
1880
+ getNotificationTemplate: (id: string, options?: AxiosRequestConfig) => Promise<NotificationTemplate<string, string | Date>>;
1881
+ listNotificationTemplates: <P = NotificationTemplate<string, string | Date>>(options?: AxiosRequestConfig) => Promise<ETNPagedResponse<P>>;
1882
+ updateNotificationTemplate: (id: string, data: any, options?: AxiosRequestConfig) => Promise<NotificationTemplate<string, string | Date>>;
1883
+ createNotificationTemplate: (data: any, options?: AxiosRequestConfig) => Promise<NotificationTemplate<string, string | Date>>;
1884
+ removeNotificationTemplate: (id: string, options?: AxiosRequestConfig) => Promise<NotificationTemplate<string, string | Date>>;
1813
1885
  getReading: (id: string, options?: AxiosRequestConfig) => Promise<Reading<string, Date>>;
1814
1886
  listReadings: <P = Reading<string, Date>>(options?: AxiosRequestConfig) => Promise<ETNPagedResponse<P>>;
1815
1887
  updateReading: (id: string, data: any, options?: AxiosRequestConfig) => Promise<Reading<string, Date>>;
@@ -1942,6 +2014,7 @@ interface SendNotificationMessageOptions {
1942
2014
  sqsClient?: SQSClient;
1943
2015
  }
1944
2016
  type NotificationType = keyof NotificationContextMap;
2017
+ declare function createNotificationMessage<T extends NotificationType>(eventName: T, context: NotificationContextMap[T], input: SendNotificationMessageInput<T>): NotificationSQSMessage<T>;
1945
2018
  type SendNotificationParams<T extends NotificationType> = {
1946
2019
  eventName: T;
1947
2020
  context: NotificationContextMap[T];
@@ -1952,9 +2025,10 @@ declare function sendNotificationMessage<T extends NotificationType>({ eventName
1952
2025
  messageId: string;
1953
2026
  }>;
1954
2027
 
2028
+ declare const notificationQueue_createNotificationMessage: typeof createNotificationMessage;
1955
2029
  declare const notificationQueue_sendNotificationMessage: typeof sendNotificationMessage;
1956
2030
  declare namespace notificationQueue {
1957
- export { notificationQueue_sendNotificationMessage as sendNotificationMessage };
2031
+ export { notificationQueue_createNotificationMessage as createNotificationMessage, notificationQueue_sendNotificationMessage as sendNotificationMessage };
1958
2032
  }
1959
2033
 
1960
2034
  interface ConsumptionData {
@@ -2173,4 +2247,4 @@ declare namespace scrapers {
2173
2247
  export type { scrapers_ETNAccount as ETNAccount };
2174
2248
  }
2175
2249
 
2176
- export { type AccessLevel, type Account, type AccountResult, type Action, type ActionType, 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 CustomAlertTemplate, type CustomAlertTemplateAction, type CustomAlertTemplateConfig, type CustomAlertTemplateConfigOption, type CustomAlertTrigger, type DataIngest, type DefaultField, type DeliveryStatus, 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 Notification, type NotificationAction, type NotificationCategory, type NotificationCategoryKey, NotificationCategoryList, type NotificationCategoryPreferences, type NotificationChannels, type NotificationContextMap, NotificationDefaultChannels, type NotificationEventType, type NotificationPreferences, type NotificationSQSMessage, type NotificationTemplate, type NotificationTemplateCategory, type NotificationTemplateDefaultChannel, type NotificationTemplateSeverity, type NotificationTemplatesMap, 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 SendNotificationMessageInput, type Setting, type SourceType, type Supplier, type User, type UtilityType, type WasteCategories, type WasteTypes, _default$5 as api, consumption, _default$1 as db, _default$4 as emailTemplate, integrations, _default$2 as logger, monitoring, notification, _default$3 as notificationEmailTemplate, notificationQueue, index as openai, reporting, scrapers, _default as slack, units, index$1 as utils };
2250
+ export { type AccessLevel, type Account, type AccountResult, type Action, type ActionType, type Asset, type Automation, type AutomationEventName, type AutomationRun, type AutomationRunLog, type AutomationRunSummary, type AutomationService, type AutomationServiceCategory, type AutomationSource, type Company, type CompanyInvoiceValidationRule, type CompanyInvoiceValidationSettings, type Consumption, type CreateScraperRunParams, type CustomAlertTrigger, type CustomAlertTriggerQueueMessage, type DataIngest, type DataQualityEventName, type DefaultField, type DeliveryStatus, type DiscussionEventName, type ETNEvent, type ETNPagedResponse$1 as ETNPagedResponse, type Email, type Entity, EventNamesByCategory, 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 Job, type JobStatus, type Log, type Notification, type NotificationAction, type NotificationCategory, type NotificationCategoryKey, NotificationCategoryList, type NotificationCategoryPreferences, type NotificationChannels, type NotificationContextMap, NotificationDefaultChannels, type NotificationEventName, type NotificationEventType, type NotificationPreferences, type NotificationSQSMessage, type NotificationTemplate, NotificationTemplateCategories, type NotificationTemplateCategory, type NotificationTemplateConfig, type NotificationTemplateConfigOption, type NotificationTemplateConfigType, type NotificationTemplateDefaultChannel, type NotificationTemplateRoute, type NotificationTemplateSeverity, type NotificationTemplatesMap, type Portal, type PortalSupplierSchema, type Problem, type ProblemCodes, type ProblemDetails, type Reading, type Report, type ReportEventName, type ReportMetadata, type ReportSource, type ReportSourceIdItem, type ReportTemplate, type ReportType, type ScraperEventName, type ScraperRun, type SendNotificationMessageInput, type Setting, type SourceType, type Supplier, type TeamEventName, type User, type UtilityType, type WasteCategories, type WasteTypes, _default$5 as api, consumption, _default$1 as db, _default$4 as emailTemplate, integrations, _default$2 as logger, monitoring, notification, _default$3 as notificationEmailTemplate, notificationQueue, index as openai, reporting, scrapers, _default as slack, units, index$1 as utils };