@etainabl/nodejs-sdk 1.3.174 → 1.3.176

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
@@ -1364,12 +1363,13 @@ interface DeliveryStatus {
1364
1363
  }
1365
1364
  interface Notification<ID = string, DateType = Date | string> {
1366
1365
  _id: ID;
1367
- notificationTemplateIdId: ID;
1366
+ notificationTemplateId: ID;
1368
1367
  scheduledAt?: DateType;
1369
1368
  scheduledBy?: 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,42 +1401,60 @@ 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 ["runError", "runCompleted", "hasnotRun", "fileNotExpected"];
1411
+ readonly report: readonly ["runCompleted", "runError"];
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 = {
@@ -1447,6 +1465,11 @@ type NotificationContextMap = {
1447
1465
  _id: string;
1448
1466
  };
1449
1467
  };
1468
+ automationFailed: {
1469
+ context: {
1470
+ message: string;
1471
+ };
1472
+ };
1450
1473
  };
1451
1474
  type NotificationEventType = keyof NotificationContextMap;
1452
1475
  interface NotificationSQSMessage<E extends NotificationEventType = NotificationEventType> {
@@ -1461,6 +1484,7 @@ interface SendNotificationMessageInput<E extends NotificationEventType> {
1461
1484
  companyId: string;
1462
1485
  userSub: string;
1463
1486
  alertTriggerId?: string;
1487
+ timestamp?: string;
1464
1488
  }
1465
1489
 
1466
1490
  interface Log<IDType = ObjectId | string> {
@@ -1725,11 +1749,6 @@ declare const _default$5: (auth: AuthOptions, instanceOptions?: CreateAxiosDefau
1725
1749
  removeAccount: (id: string, options?: AxiosRequestConfig) => Promise<Account<string>>;
1726
1750
  getAccountSchema: (options?: AxiosRequestConfig) => Promise<any>;
1727
1751
  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
1752
  getAlertTrigger: (id: string, options?: AxiosRequestConfig) => Promise<CustomAlertTrigger<string, string, {
1734
1753
  [key: string]: any;
1735
1754
  }>>;
@@ -1748,6 +1767,16 @@ declare const _default$5: (auth: AuthOptions, instanceOptions?: CreateAxiosDefau
1748
1767
  bulkUpdateAlertTriggers: (data: BulkUpdateCustomAlertTriggersRequest, options?: AxiosRequestConfig) => Promise<ETNBulkUpdateResult>;
1749
1768
  retryAlertTrigger: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
1750
1769
  cancelAlertTrigger: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
1770
+ getCustomAlertTrigger: (id: string, options?: AxiosRequestConfig) => Promise<CustomAlertTrigger<string, string, {
1771
+ [key: string]: any;
1772
+ }>>;
1773
+ listCustomAlertTriggers: <P = CustomAlertTrigger<string, string, {
1774
+ [key: string]: any;
1775
+ }>>(options?: AxiosRequestConfig) => Promise<ETNPagedResponse<P>>;
1776
+ updateCustomAlertTrigger: (id: string, data: any, options?: AxiosRequestConfig) => Promise<CustomAlertTrigger<string, string | Date, {
1777
+ [key: string]: any;
1778
+ }>>;
1779
+ bulkUpdateCustomAlertTriggers: (data: BulkUpdateCustomAlertTriggersRequest, options?: AxiosRequestConfig) => Promise<ETNBulkUpdateResult>;
1751
1780
  getAsset: (id: string, options?: AxiosRequestConfig) => Promise<Asset<string>>;
1752
1781
  listAssets: <P = Asset<string>>(options?: AxiosRequestConfig) => Promise<ETNPagedResponse<P>>;
1753
1782
  updateAsset: (id: string, data: any, options?: AxiosRequestConfig) => Promise<Asset<string>>;
@@ -1803,6 +1832,12 @@ declare const _default$5: (auth: AuthOptions, instanceOptions?: CreateAxiosDefau
1803
1832
  createLog: (data: any, options?: AxiosRequestConfig) => Promise<Log<string>>;
1804
1833
  createLogBulk: (data: any, options?: AxiosRequestConfig) => Promise<Log<string>[]>;
1805
1834
  removeLog: (id: string, options?: AxiosRequestConfig) => Promise<Log<string>>;
1835
+ getJob: (id: string, options?: AxiosRequestConfig) => Promise<Job<string, string | Date>>;
1836
+ listJobs: <P = Job<string, string | Date>>(options?: AxiosRequestConfig) => Promise<ETNPagedResponse<P>>;
1837
+ updateJob: (id: string, data: any, options?: AxiosRequestConfig) => Promise<Job<string, string | Date>>;
1838
+ createJob: (data: any, options?: AxiosRequestConfig) => Promise<Job<string, string | Date>>;
1839
+ createJobBulk: (data: any, options?: AxiosRequestConfig) => Promise<Job<string, string | Date>[]>;
1840
+ removeJob: (id: string, options?: AxiosRequestConfig) => Promise<Job<string, string | Date>>;
1806
1841
  getNotification: (id: string, options?: AxiosRequestConfig) => Promise<Notification<string, string | Date>>;
1807
1842
  listNotifications: <P = Notification<string, string | Date>>(options?: AxiosRequestConfig) => Promise<ETNPagedResponse<P>>;
1808
1843
  updateNotification: (id: string, data: any, options?: AxiosRequestConfig) => Promise<Notification<string, string | Date>>;
@@ -1810,6 +1845,11 @@ declare const _default$5: (auth: AuthOptions, instanceOptions?: CreateAxiosDefau
1810
1845
  bulkCreateNotifications: (data: any, options?: AxiosRequestConfig) => Promise<Notification<string, string | Date>[]>;
1811
1846
  bulkUpdateNotificationDeliveryStatus: (data: any, options?: AxiosRequestConfig) => Promise<ETNBulkUpdateResult>;
1812
1847
  removeNotification: (id: string, options?: AxiosRequestConfig) => Promise<Notification<string, string | Date>>;
1848
+ getNotificationTemplate: (id: string, options?: AxiosRequestConfig) => Promise<NotificationTemplate<string, string | Date>>;
1849
+ listNotificationTemplates: <P = NotificationTemplate<string, string | Date>>(options?: AxiosRequestConfig) => Promise<ETNPagedResponse<P>>;
1850
+ updateNotificationTemplate: (id: string, data: any, options?: AxiosRequestConfig) => Promise<NotificationTemplate<string, string | Date>>;
1851
+ createNotificationTemplate: (data: any, options?: AxiosRequestConfig) => Promise<NotificationTemplate<string, string | Date>>;
1852
+ removeNotificationTemplate: (id: string, options?: AxiosRequestConfig) => Promise<NotificationTemplate<string, string | Date>>;
1813
1853
  getReading: (id: string, options?: AxiosRequestConfig) => Promise<Reading<string, Date>>;
1814
1854
  listReadings: <P = Reading<string, Date>>(options?: AxiosRequestConfig) => Promise<ETNPagedResponse<P>>;
1815
1855
  updateReading: (id: string, data: any, options?: AxiosRequestConfig) => Promise<Reading<string, Date>>;
@@ -1942,6 +1982,7 @@ interface SendNotificationMessageOptions {
1942
1982
  sqsClient?: SQSClient;
1943
1983
  }
1944
1984
  type NotificationType = keyof NotificationContextMap;
1985
+ declare function createNotificationMessage<T extends NotificationType>(eventName: T, context: NotificationContextMap[T], input: SendNotificationMessageInput<T>): NotificationSQSMessage<T>;
1945
1986
  type SendNotificationParams<T extends NotificationType> = {
1946
1987
  eventName: T;
1947
1988
  context: NotificationContextMap[T];
@@ -1952,9 +1993,10 @@ declare function sendNotificationMessage<T extends NotificationType>({ eventName
1952
1993
  messageId: string;
1953
1994
  }>;
1954
1995
 
1996
+ declare const notificationQueue_createNotificationMessage: typeof createNotificationMessage;
1955
1997
  declare const notificationQueue_sendNotificationMessage: typeof sendNotificationMessage;
1956
1998
  declare namespace notificationQueue {
1957
- export { notificationQueue_sendNotificationMessage as sendNotificationMessage };
1999
+ export { notificationQueue_createNotificationMessage as createNotificationMessage, notificationQueue_sendNotificationMessage as sendNotificationMessage };
1958
2000
  }
1959
2001
 
1960
2002
  interface ConsumptionData {
@@ -2173,4 +2215,4 @@ declare namespace scrapers {
2173
2215
  export type { scrapers_ETNAccount as ETNAccount };
2174
2216
  }
2175
2217
 
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 };
2218
+ 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 };
package/dist/index.d.ts 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
@@ -1364,12 +1363,13 @@ interface DeliveryStatus {
1364
1363
  }
1365
1364
  interface Notification<ID = string, DateType = Date | string> {
1366
1365
  _id: ID;
1367
- notificationTemplateIdId: ID;
1366
+ notificationTemplateId: ID;
1368
1367
  scheduledAt?: DateType;
1369
1368
  scheduledBy?: 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,42 +1401,60 @@ 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 ["runError", "runCompleted", "hasnotRun", "fileNotExpected"];
1411
+ readonly report: readonly ["runCompleted", "runError"];
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 = {
@@ -1447,6 +1465,11 @@ type NotificationContextMap = {
1447
1465
  _id: string;
1448
1466
  };
1449
1467
  };
1468
+ automationFailed: {
1469
+ context: {
1470
+ message: string;
1471
+ };
1472
+ };
1450
1473
  };
1451
1474
  type NotificationEventType = keyof NotificationContextMap;
1452
1475
  interface NotificationSQSMessage<E extends NotificationEventType = NotificationEventType> {
@@ -1461,6 +1484,7 @@ interface SendNotificationMessageInput<E extends NotificationEventType> {
1461
1484
  companyId: string;
1462
1485
  userSub: string;
1463
1486
  alertTriggerId?: string;
1487
+ timestamp?: string;
1464
1488
  }
1465
1489
 
1466
1490
  interface Log<IDType = ObjectId | string> {
@@ -1725,11 +1749,6 @@ declare const _default$5: (auth: AuthOptions, instanceOptions?: CreateAxiosDefau
1725
1749
  removeAccount: (id: string, options?: AxiosRequestConfig) => Promise<Account<string>>;
1726
1750
  getAccountSchema: (options?: AxiosRequestConfig) => Promise<any>;
1727
1751
  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
1752
  getAlertTrigger: (id: string, options?: AxiosRequestConfig) => Promise<CustomAlertTrigger<string, string, {
1734
1753
  [key: string]: any;
1735
1754
  }>>;
@@ -1748,6 +1767,16 @@ declare const _default$5: (auth: AuthOptions, instanceOptions?: CreateAxiosDefau
1748
1767
  bulkUpdateAlertTriggers: (data: BulkUpdateCustomAlertTriggersRequest, options?: AxiosRequestConfig) => Promise<ETNBulkUpdateResult>;
1749
1768
  retryAlertTrigger: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
1750
1769
  cancelAlertTrigger: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
1770
+ getCustomAlertTrigger: (id: string, options?: AxiosRequestConfig) => Promise<CustomAlertTrigger<string, string, {
1771
+ [key: string]: any;
1772
+ }>>;
1773
+ listCustomAlertTriggers: <P = CustomAlertTrigger<string, string, {
1774
+ [key: string]: any;
1775
+ }>>(options?: AxiosRequestConfig) => Promise<ETNPagedResponse<P>>;
1776
+ updateCustomAlertTrigger: (id: string, data: any, options?: AxiosRequestConfig) => Promise<CustomAlertTrigger<string, string | Date, {
1777
+ [key: string]: any;
1778
+ }>>;
1779
+ bulkUpdateCustomAlertTriggers: (data: BulkUpdateCustomAlertTriggersRequest, options?: AxiosRequestConfig) => Promise<ETNBulkUpdateResult>;
1751
1780
  getAsset: (id: string, options?: AxiosRequestConfig) => Promise<Asset<string>>;
1752
1781
  listAssets: <P = Asset<string>>(options?: AxiosRequestConfig) => Promise<ETNPagedResponse<P>>;
1753
1782
  updateAsset: (id: string, data: any, options?: AxiosRequestConfig) => Promise<Asset<string>>;
@@ -1803,6 +1832,12 @@ declare const _default$5: (auth: AuthOptions, instanceOptions?: CreateAxiosDefau
1803
1832
  createLog: (data: any, options?: AxiosRequestConfig) => Promise<Log<string>>;
1804
1833
  createLogBulk: (data: any, options?: AxiosRequestConfig) => Promise<Log<string>[]>;
1805
1834
  removeLog: (id: string, options?: AxiosRequestConfig) => Promise<Log<string>>;
1835
+ getJob: (id: string, options?: AxiosRequestConfig) => Promise<Job<string, string | Date>>;
1836
+ listJobs: <P = Job<string, string | Date>>(options?: AxiosRequestConfig) => Promise<ETNPagedResponse<P>>;
1837
+ updateJob: (id: string, data: any, options?: AxiosRequestConfig) => Promise<Job<string, string | Date>>;
1838
+ createJob: (data: any, options?: AxiosRequestConfig) => Promise<Job<string, string | Date>>;
1839
+ createJobBulk: (data: any, options?: AxiosRequestConfig) => Promise<Job<string, string | Date>[]>;
1840
+ removeJob: (id: string, options?: AxiosRequestConfig) => Promise<Job<string, string | Date>>;
1806
1841
  getNotification: (id: string, options?: AxiosRequestConfig) => Promise<Notification<string, string | Date>>;
1807
1842
  listNotifications: <P = Notification<string, string | Date>>(options?: AxiosRequestConfig) => Promise<ETNPagedResponse<P>>;
1808
1843
  updateNotification: (id: string, data: any, options?: AxiosRequestConfig) => Promise<Notification<string, string | Date>>;
@@ -1810,6 +1845,11 @@ declare const _default$5: (auth: AuthOptions, instanceOptions?: CreateAxiosDefau
1810
1845
  bulkCreateNotifications: (data: any, options?: AxiosRequestConfig) => Promise<Notification<string, string | Date>[]>;
1811
1846
  bulkUpdateNotificationDeliveryStatus: (data: any, options?: AxiosRequestConfig) => Promise<ETNBulkUpdateResult>;
1812
1847
  removeNotification: (id: string, options?: AxiosRequestConfig) => Promise<Notification<string, string | Date>>;
1848
+ getNotificationTemplate: (id: string, options?: AxiosRequestConfig) => Promise<NotificationTemplate<string, string | Date>>;
1849
+ listNotificationTemplates: <P = NotificationTemplate<string, string | Date>>(options?: AxiosRequestConfig) => Promise<ETNPagedResponse<P>>;
1850
+ updateNotificationTemplate: (id: string, data: any, options?: AxiosRequestConfig) => Promise<NotificationTemplate<string, string | Date>>;
1851
+ createNotificationTemplate: (data: any, options?: AxiosRequestConfig) => Promise<NotificationTemplate<string, string | Date>>;
1852
+ removeNotificationTemplate: (id: string, options?: AxiosRequestConfig) => Promise<NotificationTemplate<string, string | Date>>;
1813
1853
  getReading: (id: string, options?: AxiosRequestConfig) => Promise<Reading<string, Date>>;
1814
1854
  listReadings: <P = Reading<string, Date>>(options?: AxiosRequestConfig) => Promise<ETNPagedResponse<P>>;
1815
1855
  updateReading: (id: string, data: any, options?: AxiosRequestConfig) => Promise<Reading<string, Date>>;
@@ -1942,6 +1982,7 @@ interface SendNotificationMessageOptions {
1942
1982
  sqsClient?: SQSClient;
1943
1983
  }
1944
1984
  type NotificationType = keyof NotificationContextMap;
1985
+ declare function createNotificationMessage<T extends NotificationType>(eventName: T, context: NotificationContextMap[T], input: SendNotificationMessageInput<T>): NotificationSQSMessage<T>;
1945
1986
  type SendNotificationParams<T extends NotificationType> = {
1946
1987
  eventName: T;
1947
1988
  context: NotificationContextMap[T];
@@ -1952,9 +1993,10 @@ declare function sendNotificationMessage<T extends NotificationType>({ eventName
1952
1993
  messageId: string;
1953
1994
  }>;
1954
1995
 
1996
+ declare const notificationQueue_createNotificationMessage: typeof createNotificationMessage;
1955
1997
  declare const notificationQueue_sendNotificationMessage: typeof sendNotificationMessage;
1956
1998
  declare namespace notificationQueue {
1957
- export { notificationQueue_sendNotificationMessage as sendNotificationMessage };
1999
+ export { notificationQueue_createNotificationMessage as createNotificationMessage, notificationQueue_sendNotificationMessage as sendNotificationMessage };
1958
2000
  }
1959
2001
 
1960
2002
  interface ConsumptionData {
@@ -2173,4 +2215,4 @@ declare namespace scrapers {
2173
2215
  export type { scrapers_ETNAccount as ETNAccount };
2174
2216
  }
2175
2217
 
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 };
2218
+ 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 };