@etainabl/nodejs-sdk 1.3.84 → 1.3.85
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/esm/index.js +200 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.cts +19 -2
- package/dist/index.d.ts +19 -2
- package/dist/index.js +201 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -781,6 +781,8 @@ interface Reading<IDType = ObjectId | string> {
|
|
|
781
781
|
type?: string;
|
|
782
782
|
invoiceStartRead?: number;
|
|
783
783
|
source: string;
|
|
784
|
+
isReversal?: boolean;
|
|
785
|
+
comment?: string;
|
|
784
786
|
invoiceId?: IDType;
|
|
785
787
|
rateId?: string;
|
|
786
788
|
contractRateType?: string;
|
|
@@ -910,6 +912,7 @@ interface IUserCompany<IDType = ObjectId | string> {
|
|
|
910
912
|
companyId: IDType;
|
|
911
913
|
}
|
|
912
914
|
interface User<IDType = ObjectId | string> {
|
|
915
|
+
_id: IDType;
|
|
913
916
|
name: string;
|
|
914
917
|
email: string;
|
|
915
918
|
picture: string;
|
|
@@ -946,7 +949,7 @@ interface AuthOptions {
|
|
|
946
949
|
token?: string;
|
|
947
950
|
userOnly?: boolean;
|
|
948
951
|
}
|
|
949
|
-
declare const _default$
|
|
952
|
+
declare const _default$4: (auth: AuthOptions, instanceOptions?: CreateAxiosDefaults) => {
|
|
950
953
|
instance: AxiosInstance;
|
|
951
954
|
getAccount: (id: string, options?: AxiosRequestConfig) => Promise<Account<string>>;
|
|
952
955
|
listAccounts: (options?: AxiosRequestConfig) => Promise<ETNPagedResponse<Account<string>>>;
|
|
@@ -1065,6 +1068,20 @@ declare const _default$3: (auth: AuthOptions, instanceOptions?: CreateAxiosDefau
|
|
|
1065
1068
|
updateScraperRun: (id: string, data: any, options?: AxiosRequestConfig) => Promise<ScraperRun<string>>;
|
|
1066
1069
|
};
|
|
1067
1070
|
|
|
1071
|
+
interface EmailTemplateOptions {
|
|
1072
|
+
title: string;
|
|
1073
|
+
alertLevel?: 'info' | 'warning' | 'critical' | 'success';
|
|
1074
|
+
message: string;
|
|
1075
|
+
stats?: Array<{
|
|
1076
|
+
label: string;
|
|
1077
|
+
value: string | number;
|
|
1078
|
+
highlight?: boolean;
|
|
1079
|
+
}>;
|
|
1080
|
+
footer?: string;
|
|
1081
|
+
includeTimestamp?: boolean;
|
|
1082
|
+
}
|
|
1083
|
+
declare const _default$3: (options: EmailTemplateOptions) => string;
|
|
1084
|
+
|
|
1068
1085
|
declare const _default$2: (namespace: string) => winston.Logger;
|
|
1069
1086
|
|
|
1070
1087
|
declare function connectToDatabase(retryAttempt?: number): Promise<Db>;
|
|
@@ -1219,4 +1236,4 @@ declare namespace index {
|
|
|
1219
1236
|
export { index_Prompt as Prompt, type index_PromptInput as PromptInput, type index_PromptOptions as PromptOptions, type index_PromptResponse as PromptResponse };
|
|
1220
1237
|
}
|
|
1221
1238
|
|
|
1222
|
-
export { type AccessLevel, type Account, type Asset, type Automation, 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 Reading, type Report, type ReportMetadata, type ReportSource, type ReportSourceIdItem, type ReportTemplate, type ReportType, type ScraperRun, type SourceType, type Supplier, type User, type UtilityType, type WasteCategories, type WasteTypes, _default$
|
|
1239
|
+
export { type AccessLevel, type Account, type Asset, type Automation, 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 Reading, type Report, type ReportMetadata, type ReportSource, type ReportSourceIdItem, type ReportTemplate, type ReportType, type ScraperRun, type SourceType, type Supplier, type User, type UtilityType, type WasteCategories, type WasteTypes, _default$4 as api, consumption, _default$1 as db, _default$3 as emailTemplate, _default$2 as logger, monitoring, index as openai, reporting, _default as slack, units, index$1 as utils };
|
package/dist/index.js
CHANGED
|
@@ -34,6 +34,7 @@ __export(index_exports, {
|
|
|
34
34
|
api: () => api_default,
|
|
35
35
|
consumption: () => consumption_exports,
|
|
36
36
|
db: () => db_default,
|
|
37
|
+
emailTemplate: () => emailTemplate_default,
|
|
37
38
|
logger: () => logger_default,
|
|
38
39
|
monitoring: () => monitoring_exports,
|
|
39
40
|
openai: () => openai_exports,
|
|
@@ -384,6 +385,205 @@ var api_default = (auth, instanceOptions = {}) => {
|
|
|
384
385
|
}
|
|
385
386
|
};
|
|
386
387
|
|
|
388
|
+
// src/emailTemplate.ts
|
|
389
|
+
var alertConfigs = {
|
|
390
|
+
critical: {
|
|
391
|
+
emoji: "\u{1F6A8}",
|
|
392
|
+
gradient: "linear-gradient(135deg, #dc3545, #e83e8c)",
|
|
393
|
+
borderColor: "#dc3545",
|
|
394
|
+
backgroundColor: "#f8f9fa",
|
|
395
|
+
textColor: "#dc3545"
|
|
396
|
+
},
|
|
397
|
+
warning: {
|
|
398
|
+
emoji: "\u26A0\uFE0F",
|
|
399
|
+
gradient: "linear-gradient(135deg, #fd7e14, #ffc107)",
|
|
400
|
+
borderColor: "#fd7e14",
|
|
401
|
+
backgroundColor: "#f8f9fa",
|
|
402
|
+
textColor: "#fd7e14"
|
|
403
|
+
},
|
|
404
|
+
info: {
|
|
405
|
+
emoji: "\u2139\uFE0F",
|
|
406
|
+
gradient: "linear-gradient(135deg, #007bff, #17a2b8)",
|
|
407
|
+
borderColor: "#007bff",
|
|
408
|
+
backgroundColor: "#f8f9fa",
|
|
409
|
+
textColor: "#007bff"
|
|
410
|
+
},
|
|
411
|
+
success: {
|
|
412
|
+
emoji: "\u2705",
|
|
413
|
+
gradient: "linear-gradient(135deg, #28a745, #20c997)",
|
|
414
|
+
borderColor: "#28a745",
|
|
415
|
+
backgroundColor: "#f8f9fa",
|
|
416
|
+
textColor: "#28a745"
|
|
417
|
+
}
|
|
418
|
+
};
|
|
419
|
+
var emailTemplate_default = (options) => {
|
|
420
|
+
const { title, alertLevel = "info", message, stats = [], footer = "Etainabl Monitoring System", includeTimestamp = true } = options;
|
|
421
|
+
const config = alertConfigs[alertLevel];
|
|
422
|
+
return `
|
|
423
|
+
<!DOCTYPE html>
|
|
424
|
+
<html>
|
|
425
|
+
<head>
|
|
426
|
+
<style>
|
|
427
|
+
body {
|
|
428
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
|
|
429
|
+
margin: 0;
|
|
430
|
+
padding: 20px;
|
|
431
|
+
background-color: #f5f5f5;
|
|
432
|
+
line-height: 1.5;
|
|
433
|
+
}
|
|
434
|
+
.container {
|
|
435
|
+
max-width: 600px;
|
|
436
|
+
margin: 0 auto;
|
|
437
|
+
background: white;
|
|
438
|
+
border-radius: 8px;
|
|
439
|
+
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
|
440
|
+
overflow: hidden;
|
|
441
|
+
}
|
|
442
|
+
.header {
|
|
443
|
+
background: ${config.gradient};
|
|
444
|
+
color: white;
|
|
445
|
+
padding: 24px;
|
|
446
|
+
text-align: center;
|
|
447
|
+
}
|
|
448
|
+
.header h1 {
|
|
449
|
+
margin: 0;
|
|
450
|
+
font-size: 24px;
|
|
451
|
+
font-weight: 600;
|
|
452
|
+
}
|
|
453
|
+
.content {
|
|
454
|
+
padding: 32px;
|
|
455
|
+
}
|
|
456
|
+
.alert-box {
|
|
457
|
+
background: ${config.backgroundColor};
|
|
458
|
+
border-left: 4px solid ${config.borderColor};
|
|
459
|
+
padding: 16px;
|
|
460
|
+
margin: 20px 0;
|
|
461
|
+
border-radius: 4px;
|
|
462
|
+
}
|
|
463
|
+
.alert-box h2 {
|
|
464
|
+
margin: 0 0 8px 0;
|
|
465
|
+
color: ${config.textColor};
|
|
466
|
+
font-size: 18px;
|
|
467
|
+
}
|
|
468
|
+
.alert-box p {
|
|
469
|
+
margin: 0;
|
|
470
|
+
font-size: 14px;
|
|
471
|
+
color: #374151;
|
|
472
|
+
}
|
|
473
|
+
.stats {
|
|
474
|
+
background: #f8fafc;
|
|
475
|
+
padding: 20px;
|
|
476
|
+
border-radius: 6px;
|
|
477
|
+
margin: 16px 0;
|
|
478
|
+
}
|
|
479
|
+
.stats h3 {
|
|
480
|
+
margin: 0 0 16px 0;
|
|
481
|
+
color: #1e293b;
|
|
482
|
+
font-size: 16px;
|
|
483
|
+
}
|
|
484
|
+
.stat-item {
|
|
485
|
+
display: flex;
|
|
486
|
+
justify-content: space-between;
|
|
487
|
+
margin: 8px 0;
|
|
488
|
+
padding: 8px 0;
|
|
489
|
+
border-bottom: 1px solid #e2e8f0;
|
|
490
|
+
}
|
|
491
|
+
.stat-item:last-child {
|
|
492
|
+
border-bottom: none;
|
|
493
|
+
}
|
|
494
|
+
.stat-label {
|
|
495
|
+
font-weight: 500;
|
|
496
|
+
color: #64748b;
|
|
497
|
+
}
|
|
498
|
+
.stat-value {
|
|
499
|
+
font-weight: 600;
|
|
500
|
+
color: #1e293b;
|
|
501
|
+
}
|
|
502
|
+
.stat-value.highlight {
|
|
503
|
+
color: ${config.textColor};
|
|
504
|
+
}
|
|
505
|
+
.actions {
|
|
506
|
+
background: ${config.backgroundColor};
|
|
507
|
+
border: 1px solid ${config.borderColor}40;
|
|
508
|
+
padding: 16px;
|
|
509
|
+
border-radius: 6px;
|
|
510
|
+
margin: 20px 0;
|
|
511
|
+
}
|
|
512
|
+
.actions h4 {
|
|
513
|
+
margin: 0 0 12px 0;
|
|
514
|
+
color: ${config.textColor};
|
|
515
|
+
font-size: 14px;
|
|
516
|
+
}
|
|
517
|
+
.actions ul {
|
|
518
|
+
margin: 0;
|
|
519
|
+
padding-left: 20px;
|
|
520
|
+
color: #374151;
|
|
521
|
+
}
|
|
522
|
+
.actions li {
|
|
523
|
+
margin: 4px 0;
|
|
524
|
+
font-size: 14px;
|
|
525
|
+
}
|
|
526
|
+
.timestamp {
|
|
527
|
+
font-size: 12px;
|
|
528
|
+
color: #64748b;
|
|
529
|
+
margin-top: 16px;
|
|
530
|
+
padding-top: 16px;
|
|
531
|
+
border-top: 1px solid #e2e8f0;
|
|
532
|
+
}
|
|
533
|
+
.footer {
|
|
534
|
+
background: #f8fafc;
|
|
535
|
+
padding: 16px 32px;
|
|
536
|
+
font-size: 12px;
|
|
537
|
+
color: #64748b;
|
|
538
|
+
text-align: center;
|
|
539
|
+
}
|
|
540
|
+
</style>
|
|
541
|
+
</head>
|
|
542
|
+
<body>
|
|
543
|
+
<div class="container">
|
|
544
|
+
<div class="header">
|
|
545
|
+
<h1>${config.emoji} ${title}</h1>
|
|
546
|
+
</div>
|
|
547
|
+
|
|
548
|
+
<div class="content">
|
|
549
|
+
<div class="alert-box">
|
|
550
|
+
<h2>${message}</h2>
|
|
551
|
+
</div>
|
|
552
|
+
|
|
553
|
+
${stats.length > 0 ? `
|
|
554
|
+
<div class="stats">
|
|
555
|
+
<h3>\u{1F4CA} Details</h3>
|
|
556
|
+
${stats.map(
|
|
557
|
+
(stat) => `
|
|
558
|
+
<div class="stat-item">
|
|
559
|
+
<span class="stat-label">${stat.label}</span>
|
|
560
|
+
${stat.value ? `<span class="stat-value ${stat.highlight ? "highlight" : ""}">:${stat.value}</span>` : ""}
|
|
561
|
+
</div>
|
|
562
|
+
`
|
|
563
|
+
).join("")}
|
|
564
|
+
</div>
|
|
565
|
+
` : ""}
|
|
566
|
+
|
|
567
|
+
${includeTimestamp ? `
|
|
568
|
+
<div class="timestamp">
|
|
569
|
+
Generated: ${(/* @__PURE__ */ new Date()).toLocaleString("en-GB", {
|
|
570
|
+
timeZone: "Europe/London",
|
|
571
|
+
dateStyle: "full",
|
|
572
|
+
timeStyle: "medium"
|
|
573
|
+
})}
|
|
574
|
+
</div>
|
|
575
|
+
` : ""}
|
|
576
|
+
</div>
|
|
577
|
+
|
|
578
|
+
<div class="footer">
|
|
579
|
+
${footer}
|
|
580
|
+
</div>
|
|
581
|
+
</div>
|
|
582
|
+
</body>
|
|
583
|
+
</html>
|
|
584
|
+
`;
|
|
585
|
+
};
|
|
586
|
+
|
|
387
587
|
// src/db.ts
|
|
388
588
|
var import_mongodb = require("mongodb");
|
|
389
589
|
var log2 = logger_default("dbHelpers");
|
|
@@ -1064,6 +1264,7 @@ var import_mongodb2 = require("mongodb");
|
|
|
1064
1264
|
api,
|
|
1065
1265
|
consumption,
|
|
1066
1266
|
db,
|
|
1267
|
+
emailTemplate,
|
|
1067
1268
|
logger,
|
|
1068
1269
|
monitoring,
|
|
1069
1270
|
openai,
|