@etainabl/nodejs-sdk 1.3.107 → 1.3.109
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 +60 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.cts +50 -4
- package/dist/index.d.ts +50 -4
- package/dist/index.js +61 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import winston from 'winston';
|
|
|
6
6
|
import moment from 'moment';
|
|
7
7
|
import { ZodObject } from 'zod';
|
|
8
8
|
import OpenAI from 'openai';
|
|
9
|
+
import { SQSClient } from '@aws-sdk/client-sqs';
|
|
9
10
|
|
|
10
11
|
declare const wasteCategories: readonly [{
|
|
11
12
|
readonly name: "General Waste";
|
|
@@ -610,15 +611,21 @@ interface Automation<IDType = ObjectId | string> {
|
|
|
610
611
|
}
|
|
611
612
|
|
|
612
613
|
interface Log$1 {
|
|
613
|
-
date
|
|
614
|
-
message
|
|
615
|
-
status
|
|
614
|
+
date: Date;
|
|
615
|
+
message: string;
|
|
616
|
+
status: string;
|
|
617
|
+
attachment?: {
|
|
618
|
+
s3Bucket: string;
|
|
619
|
+
s3Key: string;
|
|
620
|
+
filename: string;
|
|
621
|
+
};
|
|
616
622
|
}
|
|
617
623
|
interface AutomationRun<IDType = ObjectId | string> {
|
|
618
624
|
_id: IDType;
|
|
619
625
|
logs: Log$1[];
|
|
620
626
|
companyId: IDType;
|
|
621
627
|
automationId: IDType;
|
|
628
|
+
accountIds: IDType[];
|
|
622
629
|
status: 'error' | 'completed' | 'running';
|
|
623
630
|
context: {
|
|
624
631
|
[key: string]: any;
|
|
@@ -1064,6 +1071,13 @@ interface Reading<IDType = ObjectId | string> {
|
|
|
1064
1071
|
entityId: IDType;
|
|
1065
1072
|
companyId: IDType;
|
|
1066
1073
|
userSub?: string;
|
|
1074
|
+
s3Key?: string;
|
|
1075
|
+
referenceOnly?: boolean;
|
|
1076
|
+
isReset?: boolean;
|
|
1077
|
+
isHalfHourly?: boolean;
|
|
1078
|
+
batchCorrectionId?: string;
|
|
1079
|
+
metadata?: Record<string, any>;
|
|
1080
|
+
automationId?: IDType;
|
|
1067
1081
|
}
|
|
1068
1082
|
|
|
1069
1083
|
type ReportSource = 'assetGroup' | 'asset' | 'account' | 'accountsByRegister';
|
|
@@ -1513,4 +1527,36 @@ declare namespace index {
|
|
|
1513
1527
|
export { index_Prompt as Prompt, type index_PromptInput as PromptInput, type index_PromptOptions as PromptOptions, type index_PromptResponse as PromptResponse };
|
|
1514
1528
|
}
|
|
1515
1529
|
|
|
1516
|
-
|
|
1530
|
+
interface DLQPayload {
|
|
1531
|
+
originalMessage: string;
|
|
1532
|
+
account: Account<string>;
|
|
1533
|
+
automation: Automation<string> | null;
|
|
1534
|
+
automationRun: any | null;
|
|
1535
|
+
error: {
|
|
1536
|
+
message: string;
|
|
1537
|
+
stack?: string;
|
|
1538
|
+
timestamp: string;
|
|
1539
|
+
};
|
|
1540
|
+
context: {
|
|
1541
|
+
messageId: string;
|
|
1542
|
+
processingStage: string;
|
|
1543
|
+
};
|
|
1544
|
+
metadata: {
|
|
1545
|
+
service: string;
|
|
1546
|
+
accountName?: string;
|
|
1547
|
+
meterPointNumber?: string;
|
|
1548
|
+
companyId?: string;
|
|
1549
|
+
};
|
|
1550
|
+
}
|
|
1551
|
+
declare function sendToDLQ({ QueueUrl, payload, dlqClient }: {
|
|
1552
|
+
QueueUrl: string;
|
|
1553
|
+
payload: Partial<DLQPayload>;
|
|
1554
|
+
dlqClient: SQSClient;
|
|
1555
|
+
}): Promise<void>;
|
|
1556
|
+
|
|
1557
|
+
declare const integrations_sendToDLQ: typeof sendToDLQ;
|
|
1558
|
+
declare namespace integrations {
|
|
1559
|
+
export { integrations_sendToDLQ as sendToDLQ };
|
|
1560
|
+
}
|
|
1561
|
+
|
|
1562
|
+
export { type AccessLevel, type Account, type Asset, type Automation, type AutomationRun, 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, integrations, _default$2 as logger, monitoring, index as openai, reporting, _default as slack, units, index$1 as utils };
|
package/dist/index.js
CHANGED
|
@@ -35,6 +35,7 @@ __export(index_exports, {
|
|
|
35
35
|
consumption: () => consumption_exports,
|
|
36
36
|
db: () => db_default,
|
|
37
37
|
emailTemplate: () => emailTemplate_default,
|
|
38
|
+
integrations: () => integrations_exports,
|
|
38
39
|
logger: () => logger_default,
|
|
39
40
|
monitoring: () => monitoring_exports,
|
|
40
41
|
openai: () => openai_exports,
|
|
@@ -1364,6 +1365,65 @@ ${additionalInstructions.join("\n\n")}`,
|
|
|
1364
1365
|
}
|
|
1365
1366
|
};
|
|
1366
1367
|
|
|
1368
|
+
// src/integrations.ts
|
|
1369
|
+
var integrations_exports = {};
|
|
1370
|
+
__export(integrations_exports, {
|
|
1371
|
+
sendToDLQ: () => sendToDLQ
|
|
1372
|
+
});
|
|
1373
|
+
var import_client_sqs = require("@aws-sdk/client-sqs");
|
|
1374
|
+
async function sendToDLQ({ QueueUrl, payload, dlqClient }) {
|
|
1375
|
+
if (!QueueUrl) {
|
|
1376
|
+
throw new Error("QueueUrl is required");
|
|
1377
|
+
}
|
|
1378
|
+
if (!payload || !payload.account) {
|
|
1379
|
+
throw new Error("Payload and account information are required");
|
|
1380
|
+
}
|
|
1381
|
+
const { automation, account, context, error, metadata } = payload;
|
|
1382
|
+
if (!context || !context.messageId || !context.processingStage) {
|
|
1383
|
+
throw new Error("Context with messageId and processingStage is required");
|
|
1384
|
+
}
|
|
1385
|
+
if (!metadata || !metadata.service) {
|
|
1386
|
+
throw new Error("Metadata with service information is required");
|
|
1387
|
+
}
|
|
1388
|
+
if (!account || !account._id) {
|
|
1389
|
+
throw new Error("Account information with _id is required");
|
|
1390
|
+
}
|
|
1391
|
+
if (!error || !error.message || !error.timestamp) {
|
|
1392
|
+
throw new Error("Error information with message and timestamp is required");
|
|
1393
|
+
}
|
|
1394
|
+
if (!automation || !automation._id) {
|
|
1395
|
+
throw new Error("Automation information with _id is required");
|
|
1396
|
+
}
|
|
1397
|
+
await dlqClient.send(
|
|
1398
|
+
new import_client_sqs.SendMessageCommand({
|
|
1399
|
+
QueueUrl,
|
|
1400
|
+
MessageBody: JSON.stringify(payload),
|
|
1401
|
+
MessageAttributes: {
|
|
1402
|
+
service: {
|
|
1403
|
+
DataType: "String",
|
|
1404
|
+
StringValue: metadata.service
|
|
1405
|
+
},
|
|
1406
|
+
accountId: {
|
|
1407
|
+
DataType: "String",
|
|
1408
|
+
StringValue: account._id || "unknown"
|
|
1409
|
+
},
|
|
1410
|
+
automationId: {
|
|
1411
|
+
DataType: "String",
|
|
1412
|
+
StringValue: automation._id || "unknown"
|
|
1413
|
+
},
|
|
1414
|
+
processingStage: {
|
|
1415
|
+
DataType: "String",
|
|
1416
|
+
StringValue: context.processingStage
|
|
1417
|
+
},
|
|
1418
|
+
timestamp: {
|
|
1419
|
+
DataType: "String",
|
|
1420
|
+
StringValue: error.timestamp
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
})
|
|
1424
|
+
);
|
|
1425
|
+
}
|
|
1426
|
+
|
|
1367
1427
|
// src/types/index.ts
|
|
1368
1428
|
var import_mongodb2 = require("mongodb");
|
|
1369
1429
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1373,6 +1433,7 @@ var import_mongodb2 = require("mongodb");
|
|
|
1373
1433
|
consumption,
|
|
1374
1434
|
db,
|
|
1375
1435
|
emailTemplate,
|
|
1436
|
+
integrations,
|
|
1376
1437
|
logger,
|
|
1377
1438
|
monitoring,
|
|
1378
1439
|
openai,
|