@etainabl/nodejs-sdk 1.3.164 → 1.3.166

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 (78) hide show
  1. package/dist/esm/chunk-5UJEKK4C.js +22 -0
  2. package/dist/esm/chunk-5UJEKK4C.js.map +1 -0
  3. package/dist/esm/chunk-72KZNKH6.js +180 -0
  4. package/dist/esm/chunk-72KZNKH6.js.map +1 -0
  5. package/dist/esm/{chunk-V42NON4H.js → chunk-7QBJXGSP.js} +23 -1
  6. package/dist/esm/chunk-7QBJXGSP.js.map +1 -0
  7. package/dist/esm/{chunk-GEJJRBZZ.js → chunk-AQUTK7AW.js} +15 -5
  8. package/dist/esm/chunk-AQUTK7AW.js.map +1 -0
  9. package/dist/esm/{chunk-JFJBZL6W.js → chunk-EVJULQPT.js} +1458 -230
  10. package/dist/esm/chunk-EVJULQPT.js.map +1 -0
  11. package/dist/esm/chunk-GA2PLVMV.js +29 -0
  12. package/dist/esm/chunk-GA2PLVMV.js.map +1 -0
  13. package/dist/esm/{chunk-ITNQSW66.js → chunk-IMDTX6W5.js} +57 -7
  14. package/dist/esm/chunk-IMDTX6W5.js.map +1 -0
  15. package/dist/esm/chunk-JI6PVVK3.js +739 -0
  16. package/dist/esm/chunk-JI6PVVK3.js.map +1 -0
  17. package/dist/esm/chunk-KH6HADHN.js +31 -0
  18. package/dist/esm/chunk-KH6HADHN.js.map +1 -0
  19. package/dist/esm/{chunk-64PZMULY.js → chunk-LARQKHST.js} +2 -2
  20. package/dist/esm/chunk-PZ5AY32C.js +10 -0
  21. package/dist/esm/chunk-R2ZTENKB.js +37 -0
  22. package/dist/esm/chunk-R2ZTENKB.js.map +1 -0
  23. package/dist/esm/chunk-RREOR7G6.js +9 -0
  24. package/dist/esm/chunk-RREOR7G6.js.map +1 -0
  25. package/dist/esm/chunk-STDLTQUB.js +180 -0
  26. package/dist/esm/chunk-STDLTQUB.js.map +1 -0
  27. package/dist/esm/chunk-STQV3LF2.js +29 -0
  28. package/dist/esm/chunk-STQV3LF2.js.map +1 -0
  29. package/dist/esm/chunk-WRTOEGQL.js +255 -0
  30. package/dist/esm/chunk-WRTOEGQL.js.map +1 -0
  31. package/dist/esm/{chunk-HAEAETXR.js → chunk-ZW5YT27C.js} +55 -96
  32. package/dist/esm/chunk-ZW5YT27C.js.map +1 -0
  33. package/dist/esm/{dist-es-W6M73SKO.js → dist-es-32LEW3C7.js} +6 -5
  34. package/dist/esm/{dist-es-W6M73SKO.js.map → dist-es-32LEW3C7.js.map} +1 -1
  35. package/dist/esm/{dist-es-SHHKSG6R.js → dist-es-GCETMDH7.js} +4 -3
  36. package/dist/esm/dist-es-GCETMDH7.js.map +1 -0
  37. package/dist/esm/{dist-es-UQHTRG6U.js → dist-es-MHO4ZWXK.js} +7 -5
  38. package/dist/esm/{dist-es-UQHTRG6U.js.map → dist-es-MHO4ZWXK.js.map} +1 -1
  39. package/dist/esm/{dist-es-IIKV4LDE.js → dist-es-MRJ45ZBG.js} +19 -15
  40. package/dist/esm/{dist-es-IIKV4LDE.js.map → dist-es-MRJ45ZBG.js.map} +1 -1
  41. package/dist/esm/{dist-es-CQVI4NNF.js → dist-es-NBFOPILZ.js} +53 -14
  42. package/dist/esm/dist-es-NBFOPILZ.js.map +1 -0
  43. package/dist/esm/{dist-es-AV5FKRC6.js → dist-es-YDCANF64.js} +12 -7
  44. package/dist/esm/{dist-es-AV5FKRC6.js.map → dist-es-YDCANF64.js.map} +1 -1
  45. package/dist/esm/{dist-es-HQRLUYWI.js → dist-es-YPLWYQ2P.js} +4 -3
  46. package/dist/esm/{dist-es-HQRLUYWI.js.map → dist-es-YPLWYQ2P.js.map} +1 -1
  47. package/dist/esm/event-streams-C2D437DF.js +198 -0
  48. package/dist/esm/event-streams-C2D437DF.js.map +1 -0
  49. package/dist/esm/index.js +8421 -7505
  50. package/dist/esm/index.js.map +1 -1
  51. package/dist/esm/{loadSso-2Q7LGXOS.js → loadSso-QXCYUPG5.js} +54 -48
  52. package/dist/esm/loadSso-QXCYUPG5.js.map +1 -0
  53. package/dist/esm/{sso-oidc-7RZV73L6.js → sso-oidc-EU7F5QE4.js} +38 -34
  54. package/dist/esm/{sso-oidc-7RZV73L6.js.map → sso-oidc-EU7F5QE4.js.map} +1 -1
  55. package/dist/esm/{sts-IERANB7E.js → sts-7N2XX5PT.js} +34 -28
  56. package/dist/esm/{sts-IERANB7E.js.map → sts-7N2XX5PT.js.map} +1 -1
  57. package/dist/index.d.cts +411 -11
  58. package/dist/index.d.ts +411 -11
  59. package/dist/index.js +20412 -19412
  60. package/dist/index.js.map +1 -1
  61. package/package.json +7 -2
  62. package/dist/esm/chunk-3YGWW265.js +0 -64
  63. package/dist/esm/chunk-3YGWW265.js.map +0 -1
  64. package/dist/esm/chunk-5VQORBLK.js +0 -136
  65. package/dist/esm/chunk-5VQORBLK.js.map +0 -1
  66. package/dist/esm/chunk-6ZE6VFBF.js +0 -2420
  67. package/dist/esm/chunk-6ZE6VFBF.js.map +0 -1
  68. package/dist/esm/chunk-GEJJRBZZ.js.map +0 -1
  69. package/dist/esm/chunk-HAEAETXR.js.map +0 -1
  70. package/dist/esm/chunk-ITNQSW66.js.map +0 -1
  71. package/dist/esm/chunk-JFJBZL6W.js.map +0 -1
  72. package/dist/esm/chunk-JVMEEBKP.js +0 -127
  73. package/dist/esm/chunk-JVMEEBKP.js.map +0 -1
  74. package/dist/esm/chunk-V42NON4H.js.map +0 -1
  75. package/dist/esm/dist-es-CQVI4NNF.js.map +0 -1
  76. package/dist/esm/loadSso-2Q7LGXOS.js.map +0 -1
  77. /package/dist/esm/{chunk-64PZMULY.js.map → chunk-LARQKHST.js.map} +0 -0
  78. /package/dist/esm/{dist-es-SHHKSG6R.js.map → chunk-PZ5AY32C.js.map} +0 -0
package/dist/index.d.ts CHANGED
@@ -8,8 +8,8 @@ import { Context, SQSEvent, SNSEvent, APIGatewayEvent, S3Event } from 'aws-lambd
8
8
  import { SQSClient } from '@aws-sdk/client-sqs';
9
9
  import winston from 'winston';
10
10
  import { Logtail } from '@logtail/node';
11
+ import { z, ZodObject } from 'zod';
11
12
  import moment from 'moment';
12
- import { ZodObject } from 'zod';
13
13
  import OpenAI from 'openai';
14
14
  import { ResponseTextConfig } from 'openai/resources/responses/responses';
15
15
  import { Reasoning } from 'openai/resources.mjs';
@@ -459,6 +459,81 @@ interface Account<IDType = ObjectId | string> {
459
459
  userSub: string;
460
460
  }
461
461
 
462
+ /**
463
+ * Shared action type used across notifications and alert templates
464
+ * Matches the actionSchema defined in etainabl-api/api/shared/actionSchema.js
465
+ */
466
+ type ActionType = 'viewDetails' | 'acknowledge' | 'dismiss';
467
+ interface Action {
468
+ type: ActionType;
469
+ label: string;
470
+ route?: {
471
+ name: string;
472
+ params?: Record<string, any>;
473
+ };
474
+ icon?: string;
475
+ }
476
+
477
+ interface AlertTemplateAction extends Action {
478
+ api?: {
479
+ endpoint: string;
480
+ method: string;
481
+ payload?: Record<string, any>;
482
+ };
483
+ }
484
+ interface AlertTemplateConfigOption {
485
+ label: string;
486
+ value: string;
487
+ }
488
+ interface AlertTemplateConfig {
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?: AlertTemplateConfigOption[];
492
+ default?: string | null;
493
+ required?: boolean;
494
+ placeholder?: string;
495
+ }
496
+ interface AlertTemplate<ID = string, DateType = Date | string> {
497
+ _id: ID;
498
+ name: string;
499
+ description?: string;
500
+ key: string;
501
+ titleTemplate: string;
502
+ messageTemplate: string;
503
+ actions?: AlertTemplateAction[];
504
+ configSchema?: Record<string, AlertTemplateConfig>;
505
+ active: boolean;
506
+ isSystemTemplate: boolean;
507
+ createdAt?: DateType;
508
+ updatedAt?: DateType;
509
+ deleted?: boolean;
510
+ deletedAt?: DateType;
511
+ deletedBy?: string;
512
+ companyId?: ID;
513
+ }
514
+
515
+ interface AlertTrigger<ID = string, DateType = Date | string, metadataType = {
516
+ [key: string]: any;
517
+ }> {
518
+ _id: ID;
519
+ templateId?: ID;
520
+ state: 'pending' | 'processing' | 'processed' | 'failed' | 'cancelled';
521
+ metadata?: metadataType;
522
+ channels: {
523
+ email: boolean;
524
+ sms: boolean;
525
+ };
526
+ processedAt?: DateType;
527
+ lastTriggeredEvent?: DateType;
528
+ companyId: ID;
529
+ userSub: string;
530
+ createdAt?: DateType;
531
+ updatedAt?: DateType;
532
+ deleted?: boolean;
533
+ deletedAt?: DateType;
534
+ deletedBy?: string;
535
+ }
536
+
462
537
  interface Address {
463
538
  streetAddress: string;
464
539
  locality?: string;
@@ -619,7 +694,7 @@ type FormattedReading = Omit<Reading<string, string>, '_id'>;
619
694
  type FormattedInvoice = Omit<Invoice<string, string>, '_id' | 's3Key'>;
620
695
  interface HandleErrorParams {
621
696
  context: Context;
622
- etnApi: ReturnType<typeof _default$4>;
697
+ etnApi: ReturnType<typeof _default$5>;
623
698
  automationRun: AutomationRun<string>;
624
699
  lambdaSource: string;
625
700
  error: Error;
@@ -766,6 +841,13 @@ interface AutomationRun<IDType = ObjectId | string, DateType = Date | string> {
766
841
  totalRecordsToProcess: number;
767
842
  totalRecordsProcessed: number;
768
843
  };
844
+ automation?: any;
845
+ createdAt?: DateType;
846
+ updatedAt?: DateType;
847
+ completedAt?: DateType;
848
+ deleted?: boolean;
849
+ deletedAt?: DateType;
850
+ deletedBy?: string;
769
851
  }
770
852
 
771
853
  interface Consumption<IDType = ObjectId | string, DateType = Date> {
@@ -1241,6 +1323,75 @@ interface ETNEvent {
1241
1323
  companyId: string;
1242
1324
  }
1243
1325
 
1326
+ /**
1327
+ * Notification categories matching user.schema.js NOTIFICATION_CATEGORIES
1328
+ */
1329
+ type NotificationCategory = 'report' | 'invoiceValidation' | 'automation' | 'custom';
1330
+ interface NotificationAction extends Action {
1331
+ api?: {
1332
+ endpoint: string;
1333
+ method: string;
1334
+ payload?: Record<string, any>;
1335
+ };
1336
+ }
1337
+ interface DeliveryStatus {
1338
+ email: {
1339
+ sent: boolean;
1340
+ sentAt?: Date;
1341
+ messageId?: string;
1342
+ error?: string;
1343
+ };
1344
+ sms: {
1345
+ sent: boolean;
1346
+ sentAt?: Date;
1347
+ messageId?: string;
1348
+ error?: string;
1349
+ };
1350
+ }
1351
+ interface Notification<ID = string, DateType = Date | string> {
1352
+ _id: ID;
1353
+ linkedData?: Record<string, any>;
1354
+ type: 'notification' | 'alert';
1355
+ content?: string;
1356
+ icon?: string;
1357
+ status?: string;
1358
+ scheduledAt?: DateType;
1359
+ scheduledBy?: string;
1360
+ isSeen: boolean;
1361
+ userSub: string;
1362
+ title?: string;
1363
+ message?: string;
1364
+ severity?: 'critical' | 'high' | 'medium' | 'low' | 'info';
1365
+ isAcknowledged?: boolean;
1366
+ acknowledgedAt?: DateType;
1367
+ actions?: NotificationAction[] | null;
1368
+ alertTriggerId?: ID;
1369
+ alertTemplateId?: ID;
1370
+ category: NotificationCategory;
1371
+ channels?: {
1372
+ email?: boolean;
1373
+ sms?: boolean;
1374
+ };
1375
+ deliveryStatus?: {
1376
+ email?: {
1377
+ sent?: boolean;
1378
+ sentAt?: DateType;
1379
+ messageId?: string;
1380
+ };
1381
+ sms?: {
1382
+ sent?: boolean;
1383
+ sentAt?: DateType;
1384
+ messageId?: string;
1385
+ };
1386
+ };
1387
+ createdAt?: DateType;
1388
+ updatedAt?: DateType;
1389
+ deleted?: boolean;
1390
+ deletedAt?: DateType;
1391
+ deletedBy?: string;
1392
+ companyId?: ID;
1393
+ }
1394
+
1244
1395
  interface Log<IDType = ObjectId | string> {
1245
1396
  _id: IDType;
1246
1397
  message: string;
@@ -1307,6 +1458,7 @@ interface ReportMetadata<IDType = ObjectId | string> {
1307
1458
  dayNightSplit?: boolean;
1308
1459
  consumptionSource?: 'reading' | 'invoice' | 'combined' | 'hh' | 'reading-hh';
1309
1460
  showSimulated?: boolean;
1461
+ showCosts?: boolean;
1310
1462
  chartOptions?: any;
1311
1463
  customData?: any;
1312
1464
  readingSource?: Reading['source'];
@@ -1415,12 +1567,35 @@ interface Supplier<IDType = ObjectId | string> {
1415
1567
  interface IUserCompany<IDType = ObjectId | string> {
1416
1568
  companyId: IDType;
1417
1569
  }
1570
+ interface CategoryPreferences {
1571
+ enabled: boolean;
1572
+ channels: {
1573
+ email: boolean;
1574
+ sms: boolean;
1575
+ };
1576
+ }
1577
+ interface ReportCategoryPreferences extends CategoryPreferences {
1578
+ onGenerated: boolean;
1579
+ onError: boolean;
1580
+ }
1581
+ interface NotificationPreferences {
1582
+ channels: {
1583
+ email: boolean;
1584
+ sms: boolean;
1585
+ };
1586
+ categories: {
1587
+ report: ReportCategoryPreferences;
1588
+ invoiceValidation?: CategoryPreferences;
1589
+ automation?: CategoryPreferences;
1590
+ };
1591
+ }
1418
1592
  interface User<IDType = ObjectId | string> {
1419
1593
  _id: IDType;
1420
1594
  name: string;
1421
1595
  email: string;
1422
1596
  picture: string;
1423
1597
  authRoles: any[];
1598
+ authPermissions: any[];
1424
1599
  friendlyAuthRoles: any[];
1425
1600
  isAdmin: boolean;
1426
1601
  lastLogin?: Date;
@@ -1433,6 +1608,8 @@ interface User<IDType = ObjectId | string> {
1433
1608
  companyId: IDType;
1434
1609
  companies: IUserCompany<IDType>[];
1435
1610
  userSub: string;
1611
+ dismissedBanners?: string[];
1612
+ notificationPreferences?: NotificationPreferences;
1436
1613
  }
1437
1614
 
1438
1615
  interface ETNPagedResponse$1<T = any> {
@@ -1456,12 +1633,25 @@ interface AutomationFetchRunResponse {
1456
1633
  accountId: string;
1457
1634
  }>;
1458
1635
  }
1636
+ interface ETNBulkUpdateResult {
1637
+ success: boolean;
1638
+ modifiedCount: number;
1639
+ matchedCount: number;
1640
+ }
1641
+ interface BulkUpdateAlertTriggerItem {
1642
+ id: string;
1643
+ processedAt?: Date | string;
1644
+ lastTriggeredEvent?: Date | string;
1645
+ }
1646
+ interface BulkUpdateAlertTriggersRequest {
1647
+ updates: BulkUpdateAlertTriggerItem[];
1648
+ }
1459
1649
  interface AuthOptions {
1460
1650
  key?: string;
1461
1651
  token?: string;
1462
1652
  userOnly?: boolean;
1463
1653
  }
1464
- declare const _default$4: (auth: AuthOptions, instanceOptions?: CreateAxiosDefaults) => {
1654
+ declare const _default$5: (auth: AuthOptions, instanceOptions?: CreateAxiosDefaults) => {
1465
1655
  instance: AxiosInstance;
1466
1656
  getAccount: (id: string, options?: AxiosRequestConfig) => Promise<Account<string>>;
1467
1657
  listAccounts: <P = Account<string>>(options?: AxiosRequestConfig) => Promise<ETNPagedResponse<P>>;
@@ -1470,6 +1660,29 @@ declare const _default$4: (auth: AuthOptions, instanceOptions?: CreateAxiosDefau
1470
1660
  removeAccount: (id: string, options?: AxiosRequestConfig) => Promise<Account<string>>;
1471
1661
  getAccountSchema: (options?: AxiosRequestConfig) => Promise<any>;
1472
1662
  invalidateAccountCache: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
1663
+ getAlertTemplate: (id: string, options?: AxiosRequestConfig) => Promise<AlertTemplate<string, string | Date>>;
1664
+ listAlertTemplates: <P = AlertTemplate<string, string | Date>>(options?: AxiosRequestConfig) => Promise<ETNPagedResponse<P>>;
1665
+ updateAlertTemplate: (id: string, data: any, options?: AxiosRequestConfig) => Promise<AlertTemplate<string, string | Date>>;
1666
+ createAlertTemplate: (data: any, options?: AxiosRequestConfig) => Promise<AlertTemplate<string, string | Date>>;
1667
+ removeAlertTemplate: (id: string, options?: AxiosRequestConfig) => Promise<AlertTemplate<string, string | Date>>;
1668
+ getAlertTrigger: (id: string, options?: AxiosRequestConfig) => Promise<AlertTrigger<string, string, {
1669
+ [key: string]: any;
1670
+ }>>;
1671
+ listAlertTriggers: <P = AlertTrigger<string, string, {
1672
+ [key: string]: any;
1673
+ }>>(options?: AxiosRequestConfig) => Promise<ETNPagedResponse<P>>;
1674
+ updateAlertTrigger: (id: string, data: any, options?: AxiosRequestConfig) => Promise<AlertTrigger<string, string | Date, {
1675
+ [key: string]: any;
1676
+ }>>;
1677
+ createAlertTrigger: (data: any, options?: AxiosRequestConfig) => Promise<AlertTrigger<string, string | Date, {
1678
+ [key: string]: any;
1679
+ }>>;
1680
+ removeAlertTrigger: (id: string, options?: AxiosRequestConfig) => Promise<AlertTrigger<string, string | Date, {
1681
+ [key: string]: any;
1682
+ }>>;
1683
+ bulkUpdateAlertTriggers: (data: BulkUpdateAlertTriggersRequest, options?: AxiosRequestConfig) => Promise<ETNBulkUpdateResult>;
1684
+ retryAlertTrigger: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
1685
+ cancelAlertTrigger: (id: string, data: any, options?: AxiosRequestConfig) => Promise<any>;
1473
1686
  getAsset: (id: string, options?: AxiosRequestConfig) => Promise<Asset<string>>;
1474
1687
  listAssets: <P = Asset<string>>(options?: AxiosRequestConfig) => Promise<ETNPagedResponse<P>>;
1475
1688
  updateAsset: (id: string, data: any, options?: AxiosRequestConfig) => Promise<Asset<string>>;
@@ -1525,6 +1738,13 @@ declare const _default$4: (auth: AuthOptions, instanceOptions?: CreateAxiosDefau
1525
1738
  createLog: (data: any, options?: AxiosRequestConfig) => Promise<Log<string>>;
1526
1739
  createLogBulk: (data: any, options?: AxiosRequestConfig) => Promise<Log<string>[]>;
1527
1740
  removeLog: (id: string, options?: AxiosRequestConfig) => Promise<Log<string>>;
1741
+ getNotification: (id: string, options?: AxiosRequestConfig) => Promise<Notification<string, string | Date>>;
1742
+ listNotifications: <P = Notification<string, string | Date>>(options?: AxiosRequestConfig) => Promise<ETNPagedResponse<P>>;
1743
+ updateNotification: (id: string, data: any, options?: AxiosRequestConfig) => Promise<Notification<string, string | Date>>;
1744
+ createNotification: (data: any, options?: AxiosRequestConfig) => Promise<Notification<string, string | Date>>;
1745
+ bulkCreateNotifications: (data: any, options?: AxiosRequestConfig) => Promise<Notification<string, string | Date>[]>;
1746
+ bulkUpdateNotificationDeliveryStatus: (data: any, options?: AxiosRequestConfig) => Promise<ETNBulkUpdateResult>;
1747
+ removeNotification: (id: string, options?: AxiosRequestConfig) => Promise<Notification<string, string | Date>>;
1528
1748
  getReading: (id: string, options?: AxiosRequestConfig) => Promise<Reading<string, Date>>;
1529
1749
  listReadings: <P = Reading<string, Date>>(options?: AxiosRequestConfig) => Promise<ETNPagedResponse<P>>;
1530
1750
  updateReading: (id: string, data: any, options?: AxiosRequestConfig) => Promise<Reading<string, Date>>;
@@ -1588,7 +1808,7 @@ declare const _default$4: (auth: AuthOptions, instanceOptions?: CreateAxiosDefau
1588
1808
  createScraperRunLog: (id: string, data: any, options?: AxiosRequestConfig) => Promise<ScraperRun<string>>;
1589
1809
  createAutomationRun: (data: Omit<AutomationRun<string, string>, "_id">, options?: AxiosRequestConfig) => Promise<AutomationRun<string, string | Date>>;
1590
1810
  createAutomationFetchRun: (data: any, options?: AxiosRequestConfig) => Promise<AutomationFetchRunResponse>;
1591
- listAutomationRun: <P = AutomationRun<string, string | Date>>(options?: AxiosRequestConfig) => Promise<ETNPagedResponse<P>>;
1811
+ listAutomationRun: <P = AutomationRun<string, string>>(options?: AxiosRequestConfig) => Promise<ETNPagedResponse<P>>;
1592
1812
  getAutomationRun: (id: string, options?: AxiosRequestConfig) => Promise<AutomationRun<string, string | Date>>;
1593
1813
  updateAutomationRun: (id: string, data: any, options?: AxiosRequestConfig) => Promise<AutomationRun<string, string>>;
1594
1814
  createAutomationRunLog: (id: string, data: Omit<AutomationRunLog<string>, "date">, options?: AxiosRequestConfig) => Promise<AutomationRun<string, string | Date>>;
@@ -1610,7 +1830,7 @@ interface EmailTemplateOptions {
1610
1830
  footer?: string;
1611
1831
  includeTimestamp?: boolean;
1612
1832
  }
1613
- declare const _default$3: (options: EmailTemplateOptions) => string;
1833
+ declare const _default$4: (options: EmailTemplateOptions) => string;
1614
1834
 
1615
1835
  interface LoggerOptions {
1616
1836
  betterstack: boolean;
@@ -1620,17 +1840,197 @@ interface LoggerOptions {
1620
1840
  interface ExtendedLogger extends winston.Logger {
1621
1841
  logtail?: Logtail;
1622
1842
  }
1623
- declare const _default$2: (namespace: string, betterStackOptions?: LoggerOptions) => ExtendedLogger;
1843
+ declare const _default$3: (namespace: string, betterStackOptions?: LoggerOptions) => ExtendedLogger;
1624
1844
 
1625
1845
  declare function connectToDatabase(retryAttempt?: number): Promise<Db>;
1626
- declare const _default$1: {
1846
+ declare const _default$2: {
1627
1847
  connectToDatabase: typeof connectToDatabase;
1628
1848
  };
1629
1849
 
1630
- declare const _default: {
1850
+ declare const _default$1: {
1631
1851
  postMessage: (message: string) => Promise<axios.AxiosResponse<any, any>>;
1632
1852
  };
1633
1853
 
1854
+ declare const SendNotificationOptionsSchema: z.ZodObject<{
1855
+ notificationType: z.ZodEnum<["notification", "alert"]>;
1856
+ title: z.ZodString;
1857
+ message: z.ZodString;
1858
+ severity: z.ZodDefault<z.ZodOptional<z.ZodEnum<["critical", "high", "medium", "low", "info"]>>>;
1859
+ user: z.ZodObject<{
1860
+ userSub: z.ZodString;
1861
+ email: z.ZodOptional<z.ZodString>;
1862
+ name: z.ZodOptional<z.ZodString>;
1863
+ }, "strip", z.ZodTypeAny, {
1864
+ userSub: string;
1865
+ name?: string | undefined;
1866
+ email?: string | undefined;
1867
+ }, {
1868
+ userSub: string;
1869
+ name?: string | undefined;
1870
+ email?: string | undefined;
1871
+ }>;
1872
+ category: z.ZodEnum<["report", "invoiceValidation", "automation", "custom"]>;
1873
+ channels: z.ZodObject<{
1874
+ inApp: z.ZodOptional<z.ZodBoolean>;
1875
+ email: z.ZodBoolean;
1876
+ sms: z.ZodBoolean;
1877
+ }, "strip", z.ZodTypeAny, {
1878
+ email: boolean;
1879
+ sms: boolean;
1880
+ inApp?: boolean | undefined;
1881
+ }, {
1882
+ email: boolean;
1883
+ sms: boolean;
1884
+ inApp?: boolean | undefined;
1885
+ }>;
1886
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
1887
+ alertTriggerId: z.ZodOptional<z.ZodString>;
1888
+ alertTemplateId: z.ZodOptional<z.ZodString>;
1889
+ companyId: z.ZodString;
1890
+ actions: z.ZodOptional<z.ZodArray<z.ZodObject<{
1891
+ type: z.ZodEnum<["viewDetails", "acknowledge", "dismiss"]>;
1892
+ label: z.ZodString;
1893
+ route: z.ZodOptional<z.ZodObject<{
1894
+ name: z.ZodString;
1895
+ params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
1896
+ }, "strip", z.ZodTypeAny, {
1897
+ name: string;
1898
+ params?: Record<string, any> | undefined;
1899
+ }, {
1900
+ name: string;
1901
+ params?: Record<string, any> | undefined;
1902
+ }>>;
1903
+ icon: z.ZodOptional<z.ZodString>;
1904
+ api: z.ZodOptional<z.ZodObject<{
1905
+ endpoint: z.ZodString;
1906
+ method: z.ZodString;
1907
+ payload: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
1908
+ }, "strip", z.ZodTypeAny, {
1909
+ endpoint: string;
1910
+ method: string;
1911
+ payload?: Record<string, any> | undefined;
1912
+ }, {
1913
+ endpoint: string;
1914
+ method: string;
1915
+ payload?: Record<string, any> | undefined;
1916
+ }>>;
1917
+ }, "strip", z.ZodTypeAny, {
1918
+ type: "viewDetails" | "acknowledge" | "dismiss";
1919
+ label: string;
1920
+ route?: {
1921
+ name: string;
1922
+ params?: Record<string, any> | undefined;
1923
+ } | undefined;
1924
+ icon?: string | undefined;
1925
+ api?: {
1926
+ endpoint: string;
1927
+ method: string;
1928
+ payload?: Record<string, any> | undefined;
1929
+ } | undefined;
1930
+ }, {
1931
+ type: "viewDetails" | "acknowledge" | "dismiss";
1932
+ label: string;
1933
+ route?: {
1934
+ name: string;
1935
+ params?: Record<string, any> | undefined;
1936
+ } | undefined;
1937
+ icon?: string | undefined;
1938
+ api?: {
1939
+ endpoint: string;
1940
+ method: string;
1941
+ payload?: Record<string, any> | undefined;
1942
+ } | undefined;
1943
+ }>, "many">>;
1944
+ }, "strip", z.ZodTypeAny, {
1945
+ message: string;
1946
+ title: string;
1947
+ category: "custom" | "automation" | "report" | "invoiceValidation";
1948
+ companyId: string;
1949
+ user: {
1950
+ userSub: string;
1951
+ name?: string | undefined;
1952
+ email?: string | undefined;
1953
+ };
1954
+ severity: "info" | "critical" | "medium" | "high" | "low";
1955
+ notificationType: "notification" | "alert";
1956
+ channels: {
1957
+ email: boolean;
1958
+ sms: boolean;
1959
+ inApp?: boolean | undefined;
1960
+ };
1961
+ metadata?: Record<string, any> | undefined;
1962
+ actions?: {
1963
+ type: "viewDetails" | "acknowledge" | "dismiss";
1964
+ label: string;
1965
+ route?: {
1966
+ name: string;
1967
+ params?: Record<string, any> | undefined;
1968
+ } | undefined;
1969
+ icon?: string | undefined;
1970
+ api?: {
1971
+ endpoint: string;
1972
+ method: string;
1973
+ payload?: Record<string, any> | undefined;
1974
+ } | undefined;
1975
+ }[] | undefined;
1976
+ alertTriggerId?: string | undefined;
1977
+ alertTemplateId?: string | undefined;
1978
+ }, {
1979
+ message: string;
1980
+ title: string;
1981
+ category: "custom" | "automation" | "report" | "invoiceValidation";
1982
+ companyId: string;
1983
+ user: {
1984
+ userSub: string;
1985
+ name?: string | undefined;
1986
+ email?: string | undefined;
1987
+ };
1988
+ notificationType: "notification" | "alert";
1989
+ channels: {
1990
+ email: boolean;
1991
+ sms: boolean;
1992
+ inApp?: boolean | undefined;
1993
+ };
1994
+ metadata?: Record<string, any> | undefined;
1995
+ severity?: "info" | "critical" | "medium" | "high" | "low" | undefined;
1996
+ actions?: {
1997
+ type: "viewDetails" | "acknowledge" | "dismiss";
1998
+ label: string;
1999
+ route?: {
2000
+ name: string;
2001
+ params?: Record<string, any> | undefined;
2002
+ } | undefined;
2003
+ icon?: string | undefined;
2004
+ api?: {
2005
+ endpoint: string;
2006
+ method: string;
2007
+ payload?: Record<string, any> | undefined;
2008
+ } | undefined;
2009
+ }[] | undefined;
2010
+ alertTriggerId?: string | undefined;
2011
+ alertTemplateId?: string | undefined;
2012
+ }>;
2013
+ type SendNotificationOptions = z.infer<typeof SendNotificationOptionsSchema>;
2014
+ type CreatedNotification = Notification<string>;
2015
+ interface NotificationContext {
2016
+ db?: Db;
2017
+ api?: ReturnType<typeof _default$5>;
2018
+ }
2019
+ declare function sendBulkNotifications(notifications: SendNotificationOptions[], context: NotificationContext): Promise<CreatedNotification[]>;
2020
+ declare function sendNotification(options: SendNotificationOptions, context: NotificationContext): Promise<CreatedNotification>;
2021
+ declare const _default: {
2022
+ sendNotification: typeof sendNotification;
2023
+ sendBulkNotifications: typeof sendBulkNotifications;
2024
+ };
2025
+
2026
+ type notification_NotificationContext = NotificationContext;
2027
+ type notification_SendNotificationOptions = SendNotificationOptions;
2028
+ declare const notification_sendBulkNotifications: typeof sendBulkNotifications;
2029
+ declare const notification_sendNotification: typeof sendNotification;
2030
+ declare namespace notification {
2031
+ export { type notification_NotificationContext as NotificationContext, type notification_SendNotificationOptions as SendNotificationOptions, _default as default, notification_sendBulkNotifications as sendBulkNotifications, notification_sendNotification as sendNotification };
2032
+ }
2033
+
1634
2034
  interface ConsumptionData {
1635
2035
  date: Date;
1636
2036
  consumption: number;
@@ -1684,7 +2084,7 @@ interface StepFunctionEvent {
1684
2084
  }
1685
2085
  declare class IngestHandler {
1686
2086
  protected event: SQSEvent | SNSEvent | APIGatewayEvent | S3Event;
1687
- protected log: ReturnType<typeof _default$2>;
2087
+ protected log: ReturnType<typeof _default$3>;
1688
2088
  protected sqsReceiptHandle: string | undefined;
1689
2089
  constructor(event: any);
1690
2090
  isSQSEvent(event: any): event is SQSEvent;
@@ -1791,7 +2191,7 @@ type ETNModels = keyof typeof models;
1791
2191
  declare abstract class Model {
1792
2192
  openai: OpenAI;
1793
2193
  protected models: Record<ETNModels, ETNModel>;
1794
- protected log: ReturnType<typeof _default$2>;
2194
+ protected log: ReturnType<typeof _default$3>;
1795
2195
  constructor();
1796
2196
  }
1797
2197
 
@@ -1847,4 +2247,4 @@ declare namespace scrapers {
1847
2247
  export type { scrapers_ETNAccount as ETNAccount };
1848
2248
  }
1849
2249
 
1850
- 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 };
2250
+ export { type AccessLevel, type Account, type AccountResult, type Action, type ActionType, type AlertTemplate, type AlertTemplateAction, type AlertTemplateConfig, type AlertTemplateConfigOption, type AlertTrigger, type Asset, type Automation, type AutomationRun, type AutomationRunLog, type AutomationRunSummary, type AutomationService, type AutomationServiceCategory, type AutomationSource, type CategoryPreferences, type Company, type CompanyInvoiceValidationRule, type CompanyInvoiceValidationSettings, type Consumption, type CreateScraperRunParams, 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 NotificationPreferences, type Portal, type PortalSupplierSchema, type Problem, type ProblemCodes, type ProblemDetails, type Reading, type Report, type ReportCategoryPreferences, 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$5 as api, consumption, _default$2 as db, _default$4 as emailTemplate, integrations, _default$3 as logger, monitoring, notification, index as openai, reporting, scrapers, _default$1 as slack, units, index$1 as utils };