@cemiar/cemiarlink-sdk 1.0.40 → 1.0.42

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/README.md CHANGED
@@ -1,2 +1,651 @@
1
1
  # @cemiar/cemiarlink-sdk
2
2
 
3
+ Unified SDK for accessing CemiarLink API services. This package consolidates multiple legacy services into a single, consistent SDK.
4
+
5
+ **This package replaces the following legacy libraries:**
6
+
7
+ | Legacy Package | Replaced By |
8
+ |----------------|-------------|
9
+ | `cemiar-mail-service` | `MailService` |
10
+ | `cemiar-admin-service` | `AdminService` |
11
+ | `cemiar-epic-service` | `EpicService` |
12
+ | `cemiar-epic-service-common` | `EpicService` |
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ npm install @cemiar/cemiarlink-sdk
18
+ ```
19
+
20
+ When working inside this monorepo, you can add it via a file reference:
21
+
22
+ ```bash
23
+ npm install @cemiar/cemiarlink-sdk@file:../packages/cemiar-cemiarlink-sdk
24
+ ```
25
+
26
+ ## Usage
27
+
28
+ ### MailService
29
+
30
+ ```ts
31
+ import { MailService } from "@cemiar/cemiarlink-sdk";
32
+
33
+ const mailService = new MailService(
34
+ process.env.CEMIARLINK_MAIL_URL,
35
+ { Authorization: `Bearer ${token}` },
36
+ "user@gmail.com", // Gmail user (optional)
37
+ "app-password" // Gmail app password (optional)
38
+ );
39
+
40
+ // Get email folders
41
+ const folders = await mailService.getEmailFolders();
42
+
43
+ // Get email message IDs with filter
44
+ const messageIds = await mailService.getEmailMessageIds({
45
+ labelIds: "UNREAD",
46
+ q: "from:example@domain.com"
47
+ });
48
+
49
+ // Retrieve email reports for a specific date
50
+ const reports = await mailService.getEmailReports(new Date(), {
51
+ includeRead: false,
52
+ skipRead: false,
53
+ subfolders: ["INBOX"]
54
+ });
55
+
56
+ // Send an email via Nodemailer
57
+ await mailService.sendMail(
58
+ "Subject",
59
+ "Plain text content",
60
+ "<h1>HTML content</h1>",
61
+ ["recipient@example.com"],
62
+ [{ filename: "attachment.pdf", content: buffer }],
63
+ ["cc@example.com"]
64
+ );
65
+
66
+ // Delete an email
67
+ await mailService.deleteEmail(emailId);
68
+ ```
69
+
70
+ ### AdminService
71
+
72
+ ```ts
73
+ import { AdminService } from "@cemiar/cemiarlink-sdk";
74
+
75
+ const adminService = new AdminService(
76
+ process.env.CEMIARLINK_ADMIN_URL,
77
+ { Authorization: `Bearer ${token}` },
78
+ "task-id" // Optional task ID
79
+ );
80
+
81
+ // Update Cemiar task status
82
+ await adminService.updateCemiarTask("success");
83
+
84
+ // PDF operations
85
+ const pdfResponse = await adminService.pdfReader("route", "insurer", { base64: fileBase64 });
86
+ const comparison = await adminService.pdfCompare(payload, "v2");
87
+ const comparisonExcel = await adminService.pdfCompareExcel(payload, "v2");
88
+
89
+ // Text extraction
90
+ const textPages = await adminService.getPdfText(fileBase64, "engine", "1");
91
+
92
+ // Table extraction from PDF
93
+ const tables = await adminService.extractTableFromBase64({ base64: fileBase64 });
94
+
95
+ // Insurer extraction
96
+ const insurer = await adminService.extractInsurerFromBase64({ base64: fileBase64 });
97
+
98
+ // Azure OCR
99
+ const ocrResults = await adminService.azureOCRExtraction({ base64: fileBase64 });
100
+
101
+ // Document classification
102
+ const classification = await adminService.classifyDocument("insurer", fileBase64);
103
+
104
+ // Send SMS via Kimoby
105
+ await adminService.sendTextMessage("Hello!", "+15551234567", "John Doe", "enterprise");
106
+
107
+ // Send email notification
108
+ await adminService.sendNotification({
109
+ to: "recipient@example.com",
110
+ subject: "Notification",
111
+ body: "Content"
112
+ });
113
+
114
+ // Send email via AWS SES
115
+ const result = await adminService.sendEmailAws({
116
+ to: ["recipient@example.com"],
117
+ subject: "Subject",
118
+ html: "<p>Content</p>"
119
+ });
120
+
121
+ // Service Bus messages
122
+ await adminService.sendMessagesToQueue("queue-name", { messages: [...] });
123
+
124
+ // Report management
125
+ const reportData = await adminService.getReportData<MyType>("2024-01-15", "Report", 0);
126
+ await adminService.createReport(data, headers, "report.xlsx");
127
+ await adminService.removeReportFiles("2024-01-15", "Report");
128
+
129
+ // Counter management
130
+ const counter = await adminService.getCounter("task-id");
131
+ await adminService.updateCounter("counter-id", 42);
132
+ ```
133
+
134
+ ### EpicService
135
+
136
+ ```ts
137
+ import { EpicService } from "@cemiar/cemiarlink-sdk";
138
+
139
+ const epicService = new EpicService(
140
+ process.env.CEMIARLINK_EPIC_URL,
141
+ { Authorization: `Bearer ${token}` }
142
+ );
143
+
144
+ // Activities
145
+ const activities = await epicService.getActivities({ clientId: "123" });
146
+ const activity = await epicService.getActivity("activity-id");
147
+ const newActivityId = await epicService.createActivity({ /* payload */ });
148
+ await epicService.updateActivity("activity-id", { /* payload */ });
149
+ await epicService.copyActivity("activity-id", { /* payload */ });
150
+
151
+ // Attachments
152
+ const attachments = await epicService.getAttachments({ policyId: "123" });
153
+ const attachment = await epicService.getAttachment("attachment-id");
154
+ const content = await epicService.getAttachmentContent("attachment-id");
155
+ await epicService.createAttachment({ /* payload */ });
156
+ await epicService.updateAttachment("attachment-id", { /* payload */ });
157
+ await epicService.deleteAttachment("attachment-id");
158
+
159
+ // Policies (V1)
160
+ const policies = await epicService.getPolicies({ clientId: "123" });
161
+ const policy = await epicService.getPolicy("policy-id");
162
+ await epicService.createPolicy({ /* payload */ });
163
+ await epicService.updatePolicy("policy-id", { /* payload */ });
164
+ await epicService.renewPolicy("policy-id", { /* payload */ });
165
+ await epicService.issuePolicy("policy-id", { /* payload */ });
166
+ await epicService.cancelPolicy("policy-id", { /* payload */ });
167
+ await epicService.endorsePolicy("policy-id", { /* payload */ });
168
+
169
+ // Policies (V2 - recommended)
170
+ const policiesV2 = await epicService.getPoliciesV2({ clientId: "123" });
171
+ const policyV2 = await epicService.getPolicyV2("policy-id");
172
+ await epicService.createPolicyV2({ /* payload */ });
173
+ await epicService.updatePolicyV2("policy-id", { /* payload */ });
174
+ await epicService.renewPolicyV2({ /* payload */ });
175
+ await epicService.issuePolicyV2({ /* payload */ });
176
+ await epicService.cancelPolicyV2({ /* payload */ });
177
+ await epicService.endorseExistingLinePolicyV2({ /* payload */ });
178
+ await epicService.issueEndorsementPolicyV2({ /* payload */ });
179
+ await epicService.issueCancellationPolicyV2({ /* payload */ });
180
+ const renewalStages = await epicService.getPolicyV2RenewalStages([1, 2, 3]);
181
+
182
+ // Customers
183
+ const customers = await epicService.getCustomers({ name: "John" });
184
+ const customer = await epicService.getCustomer("client-id");
185
+ await epicService.createCustomer({ /* payload */ });
186
+ await epicService.updateCustomer("client-id", { /* payload */ });
187
+
188
+ // Contacts
189
+ const contacts = await epicService.getContacts({ clientId: "123" });
190
+ const contact = await epicService.getContact("contact-id", {});
191
+ await epicService.createContact({ /* payload */ });
192
+ await epicService.updateContact("contact-id", "accountType", { /* payload */ });
193
+
194
+ // Transactions
195
+ const transactions = await epicService.getTransactions({ policyId: "123" });
196
+ const transaction = await epicService.getTransaction("transaction-id");
197
+ await epicService.createTransaction({ /* payload */ });
198
+ await epicService.createPaymentTransaction({ /* payload */ });
199
+ await epicService.updateTransaction("transaction-id", { /* payload */ });
200
+ await epicService.financeTransaction("transaction-id", { /* payload */ });
201
+ await epicService.reverseTransaction("transaction-id", { /* payload */ });
202
+ await epicService.transactionApplyCreditsToDebits("transaction-id", { /* payload */ });
203
+
204
+ // Employees
205
+ const employees = await epicService.getEmployees({});
206
+ const employee = await epicService.getEmployee("employee-id");
207
+ const employeesV2 = await epicService.getEmployeesV2({});
208
+ const employeeV2 = await epicService.getEmployeeV2(123);
209
+ await epicService.createEmployee({ /* payload */ });
210
+ await epicService.updateEmployee(123, { /* payload */ });
211
+
212
+ // Companies
213
+ const companies = await epicService.getCompanies({});
214
+ const company = await epicService.getCompany("company-id");
215
+
216
+ // Receipts
217
+ const receipts = await epicService.getReceipts({});
218
+ const receipt = await epicService.getReceipt("receipt-id");
219
+ await epicService.createReceipt({ /* payload */ });
220
+ await epicService.updateReceipt("receipt-id", { /* payload */ });
221
+ await epicService.receiptApplyCreditsToDebits("receipt-id", { /* payload */ });
222
+
223
+ // Claims
224
+ const claims = await epicService.getClaims({});
225
+ const claim = await epicService.getClaim("claim-id");
226
+
227
+ // Opportunities
228
+ const opportunities = await epicService.getOpportunities({});
229
+ const opportunity = await epicService.getOpportunity("opportunity-id");
230
+ await epicService.createOpportunity({ /* payload */ });
231
+ await epicService.updateOpportunity("opportunity-id", { /* payload */ });
232
+
233
+ // Vehicles & Drivers
234
+ const personalVehicles = await epicService.getPersonalAutoVehicles({});
235
+ const personalDrivers = await epicService.getPersonalAutoDrivers({});
236
+ const commercialVehicles = await epicService.getCommercialAutoVehicles({});
237
+ const commercialDrivers = await epicService.getCommercialAutoDrivers({});
238
+
239
+ // Policy Lines
240
+ const lines = await epicService.getPolicyLines({});
241
+ const line = await epicService.getPolicyLine("line-id");
242
+ await epicService.createPolicyLine({ /* payload */ });
243
+ await epicService.updatePolicyLine("line-id", { /* payload */ });
244
+
245
+ // Commissions
246
+ const commission = await epicService.getCommission("commission-id");
247
+ const commissions = await epicService.getCommissions("commission-id", {});
248
+
249
+ // Lookups
250
+ const lookups = await epicService.getLookUp({ type: "coverageType" });
251
+
252
+ // Habitationals
253
+ const habitationals = await epicService.getHabitationals({});
254
+
255
+ // Additional Interests
256
+ const additionalInterests = await epicService.getAdditionalInterests({});
257
+
258
+ // Journal Entries
259
+ const journalEntries = await epicService.getJournalEntries({});
260
+ const journalEntry = await epicService.getJournalEntry("journal-id");
261
+ await epicService.createJournalEntry({ /* payload */ });
262
+ await epicService.updateJournalEntry("journal-id", { /* payload */ });
263
+
264
+ // General Ledger Banks
265
+ const banks = await epicService.getGeneralLedgerReconcileBanks({});
266
+ const bank = await epicService.getGeneralLedgerReconcileBank("bank-id");
267
+ await epicService.createGeneralLedgerReconcileBank({ /* payload */ });
268
+ await epicService.updateGeneralLedgerBank("bank-id", { /* payload */ });
269
+
270
+ // Payable Contracts
271
+ const contracts = await epicService.getPayableContracts({});
272
+ const contract = await epicService.getPayableContract("contract-id", {});
273
+
274
+ // Sub-services
275
+ const mcsResult = await epicService.multiCarrierSchedule.getSchedules({});
276
+ const dbcResult = await epicService.directBillCommission.getCommissions({});
277
+ ```
278
+
279
+ ### GoogleAdsService
280
+
281
+ ```ts
282
+ import { GoogleAdsService } from "@cemiar/cemiarlink-sdk";
283
+
284
+ const googleAdsService = new GoogleAdsService(
285
+ process.env.CEMIARLINK_BASE_URL,
286
+ { Authorization: `Bearer ${token}` }
287
+ );
288
+
289
+ // Upload offline conversions
290
+ const uploadResult = await googleAdsService.uploadConversions("enterprise", [
291
+ {
292
+ gclid: "click-id",
293
+ conversion_action: "conversion-action-name",
294
+ conversion_date_time: "2024-01-15 10:30:00+00:00",
295
+ conversion_value: 100.00,
296
+ currency_code: "CAD"
297
+ }
298
+ ]);
299
+
300
+ // Upload conversion adjustments
301
+ const adjustmentResult = await googleAdsService.uploadConversionAdjustments("enterprise", [
302
+ { /* adjustment payload */ }
303
+ ]);
304
+ ```
305
+
306
+ ### SharepointService
307
+
308
+ ```ts
309
+ import { SharepointService } from "@cemiar/cemiarlink-sdk";
310
+
311
+ const sharepointService = new SharepointService(
312
+ process.env.CEMIARLINK_BASE_URL,
313
+ { Authorization: `Bearer ${token}` }
314
+ );
315
+
316
+ // Find a file
317
+ const fileInfo = await sharepointService.findFile({
318
+ connection: { siteId: "site-id", driveId: "drive-id" },
319
+ path: "/folder/subfolder",
320
+ fileName: "document.pdf"
321
+ });
322
+
323
+ // Download a file by ID
324
+ const buffer = await sharepointService.downloadFileById("file-id", {
325
+ siteId: "site-id",
326
+ driveId: "drive-id"
327
+ });
328
+
329
+ // Find and download in one call
330
+ const result = await sharepointService.findAndDownload({
331
+ connection: { siteId: "site-id", driveId: "drive-id" },
332
+ path: "/folder",
333
+ fileName: "report.xlsx"
334
+ });
335
+ if (result) {
336
+ console.log(result.fileName, result.fileId, result.webUrl);
337
+ fs.writeFileSync(result.fileName, result.buffer);
338
+ }
339
+ ```
340
+
341
+ ## Migration Guide
342
+
343
+ ### From `cemiar-mail-service`
344
+
345
+ ```diff
346
+ - import MailService from "cemiar-mail-service";
347
+ + import { MailService } from "@cemiar/cemiarlink-sdk";
348
+
349
+ // Constructor signature remains the same
350
+ const mailService = new MailService(mailUrl, headers, user, password);
351
+
352
+ // All methods have the same signatures:
353
+ // ✅ getEmailFolders()
354
+ // ✅ getEmailMessageIds(filter)
355
+ // ✅ updateEmailMetadata(mailId, payload)
356
+ // ✅ getEmailReport(to, subjectType, options)
357
+ // ✅ getEmailReports(date, options)
358
+ // ✅ getTransactionWatchList(to, subjectType)
359
+ // ✅ deleteEmail(id)
360
+ // ✅ sendMail(subject, text, html, to, attachments, cc)
361
+ ```
362
+
363
+ ### From `cemiar-admin-service`
364
+
365
+ ```diff
366
+ - import AdminService from "cemiar-admin-service";
367
+ + import { AdminService } from "@cemiar/cemiarlink-sdk";
368
+
369
+ // Constructor signature remains the same
370
+ const adminService = new AdminService(adminUrl, headers, taskId);
371
+
372
+ // All methods have the same signatures:
373
+ // ✅ updateCemiarTask(status)
374
+ // ✅ pdfReader(route, issuingCompany, payload)
375
+ // ✅ pdfCompare(payload, apiVersion)
376
+ // ✅ pdfCompareExcel(payload, apiVersion)
377
+ // ✅ extractTableFromBase64(payload)
378
+ // ✅ extractInsurerFromBase64(payload)
379
+ // ✅ extractVehicles(payload)
380
+ // ✅ azureOCRExtraction(payload)
381
+ // ✅ sendTextMessage(message, phoneNumber, name, enterprise)
382
+ // ✅ getModuleConfig()
383
+ // ✅ getReportData(date, fileName, sheetNumber)
384
+ // ✅ getTestData(fileName, sheetNumber)
385
+ // ✅ saveTestResult(result, fileName)
386
+ // ✅ removeReportFiles(date, fileName)
387
+ // ✅ unSyncFiles()
388
+ // ✅ createReport(sheatData, headers, name)
389
+ // ✅ getPrimacoFlashPaymentLink(request, enterprise) - deprecated
390
+ // ✅ getCounter(taskId)
391
+ // ✅ updateCounter(counterId, numberOfRequest)
392
+ // ✅ classifyDocument(insurer, fileContentBase64)
393
+ // ✅ sendMessagesToQueue(queue, messages)
394
+ // ✅ sendNotification(notification)
395
+ // ✅ sendEmailAws(emailBody)
396
+
397
+ // New method in cemiarlink-sdk:
398
+ // ➕ getPdfText(fileContentBase64, engine?, page?)
399
+ ```
400
+
401
+ ### From `cemiar-epic-service`
402
+
403
+ ```diff
404
+ - import EpicService from "cemiar-epic-service";
405
+ + import { EpicService } from "@cemiar/cemiarlink-sdk";
406
+
407
+ // Constructor signature remains the same
408
+ const epicService = new EpicService(epicUrl, headers);
409
+
410
+ // All existing methods are preserved with same signatures:
411
+ // ✅ getActivity(activityId)
412
+ // ✅ getActivities(queryParams)
413
+ // ✅ updateActivity(activityId, payload)
414
+ // ✅ createActivity(payload)
415
+ // ✅ getAttachments(queryParams)
416
+ // ✅ getAttachment(attachmentId)
417
+ // ✅ updateAttachment(attachmentId, payload)
418
+ // ✅ createAttachment(payload)
419
+ // ✅ getAttachmentContent(attachmentId)
420
+ // ✅ deleteAttachment(attachmentId)
421
+ // ✅ getPolicies(queryParams)
422
+ // ✅ getPolicy(id)
423
+ // ✅ createPolicy(payload)
424
+ // ✅ updatePolicy(id, payload)
425
+ // ✅ renewPolicy(id, payload)
426
+ // ✅ issuePolicy(id, payload)
427
+ // ✅ cancelPolicy(id, payload)
428
+ // ✅ getEmployee(id)
429
+ // ✅ getEmployees(queryParams)
430
+ // ✅ getLookUp(queryParams)
431
+ // ✅ getContact(id, queryParams)
432
+ // ✅ getContacts(queryParams)
433
+ // ✅ createContact(payload)
434
+ // ✅ updateContact(id, accountType, payload)
435
+ // ✅ getTransactions(queryParams)
436
+ // ✅ getTransaction(transactionId)
437
+ // ✅ financeTransaction(transactionId, payload)
438
+ // ✅ reverseTransaction(transactionId, payload)
439
+ // ✅ transactionApplyCreditsToDebits(transactionId, payload)
440
+ // ✅ updateTransaction(transactionId, payload)
441
+ // ✅ createTransaction(payload)
442
+ // ✅ createPaymentTransaction(payload)
443
+ // ✅ getCompany(companyId)
444
+ // ✅ getCompanies(queryParams)
445
+ // ✅ getCustomers(queryParams)
446
+ // ✅ getCustomer(clientId)
447
+ // ✅ updateCustomer(clientId, payload)
448
+ // ✅ createCustomer(payload)
449
+ // ✅ getHabitationals(queryParams)
450
+ // ✅ getCommissions(commissionId, queryParams)
451
+ // ✅ getCommission(commissionId)
452
+ // ✅ getOpportunity(opportunityId)
453
+ // ✅ getOpportunities(queryParams)
454
+ // ✅ updateOpportunity(opportunityId, payload)
455
+ // ✅ createOpportunity(payload)
456
+ // ✅ getClaim(claimId)
457
+ // ✅ getClaims(queryParams)
458
+ // ✅ getPolicyLines(queryParams)
459
+ // ✅ createPolicyLine(policyLine)
460
+ // ✅ getDirectBillCommission(commissionId) → via epicService.directBillCommission
461
+ // ✅ getDirectBillCommissions(queryParams) → via epicService.directBillCommission
462
+ // ✅ updateDirectBillCommission(commissionId, payload) → via epicService.directBillCommission
463
+ // ✅ getReceipts(queryParams)
464
+ // ✅ getReceipt(receiptId)
465
+ // ✅ updateReceipt(receiptId, payload)
466
+ // ✅ createReceipt(payload)
467
+ // ✅ receiptApplyCreditsToDebits(receiptId, payload)
468
+
469
+ // Renamed methods:
470
+ - epicService.getPersonalVehicles(queryParams)
471
+ + epicService.getPersonalAutoVehicles(queryParams)
472
+ ```
473
+
474
+ ### From `cemiar-epic-service-common`
475
+
476
+ ```diff
477
+ - import EpicService from "cemiar-epic-service-common";
478
+ + import { EpicService } from "@cemiar/cemiarlink-sdk";
479
+
480
+ // Constructor signature remains the same
481
+ const epicService = new EpicService(epicUrl, headers);
482
+
483
+ // All methods from cemiar-epic-service-common are preserved:
484
+ // ✅ All V1 methods (see cemiar-epic-service above)
485
+
486
+ // V2 Policy methods:
487
+ // ✅ getPoliciesV2(queryParams)
488
+ // ✅ getPolicyV2(id)
489
+ // ✅ createPolicyV2(payload)
490
+ // ✅ updatePolicyV2(id, payload)
491
+ // ✅ renewPolicyV2(payload)
492
+ // ✅ endorseExistingLinePolicyV2(payload)
493
+ // ✅ cancelPolicyV2(payload)
494
+ // ✅ issuePolicyV2(payload)
495
+ // ✅ issueEndorsementPolicyV2(payload)
496
+ // ✅ issueCancellationPolicyV2(payload)
497
+ // ✅ getPolicyV2RenewalStages(ids)
498
+
499
+ // V2 Employee methods:
500
+ // ✅ getEmployeeV2(id)
501
+ // ✅ getEmployeesV2(queryParams)
502
+ // ✅ createEmployee(payload)
503
+ // ✅ updateEmployee(id, payload)
504
+
505
+ // Sub-services:
506
+ // ✅ epicService.multiCarrierSchedule.*
507
+ // ✅ epicService.directBillCommission.*
508
+
509
+ // Removed/changed:
510
+ - epicService.job.* // JobEpicService not included
511
+
512
+ // New methods in cemiarlink-sdk:
513
+ // ➕ endorsePolicy(id, payload)
514
+ // ➕ copyActivity(id, payload)
515
+ // ➕ getPolicyLine(lineId)
516
+ // ➕ updatePolicyLine(lineId, payload)
517
+ // ➕ getPersonalAutoDrivers(queryParams)
518
+ // ➕ getCommercialAutoVehicles(queryParams)
519
+ // ➕ getCommercialAutoDrivers(queryParams)
520
+ // ➕ getPayableContracts(queryParams)
521
+ // ➕ getPayableContract(payableContractId, queryParams)
522
+ // ➕ getGeneralLedgerReconcileBanks(queryParams)
523
+ // ➕ getGeneralLedgerReconcileBank(bankId)
524
+ // ➕ createGeneralLedgerReconcileBank(payload)
525
+ // ➕ updateGeneralLedgerBank(bankId, payload)
526
+ // ➕ getAdditionalInterests(queryParams)
527
+ // ➕ getJournalEntry(journalEntryId)
528
+ // ➕ getJournalEntries(queryParams)
529
+ // ➕ createJournalEntry(payload)
530
+ // ➕ updateJournalEntry(journalEntryId, payload)
531
+ ```
532
+
533
+ ### Quick Migration Steps
534
+
535
+ 1. **Update package.json**:
536
+ ```diff
537
+ {
538
+ "dependencies": {
539
+ - "cemiar-mail-service": "^1.0.48",
540
+ - "cemiar-admin-service": "^1.0.61",
541
+ - "cemiar-epic-service": "^1.0.98",
542
+ - "cemiar-epic-service-common": "^1.0.140",
543
+ + "@cemiar/cemiarlink-sdk": "^1.0.0"
544
+ }
545
+ }
546
+ ```
547
+
548
+ 2. **Update imports**:
549
+ ```diff
550
+ - import MailService from "cemiar-mail-service";
551
+ - import AdminService from "cemiar-admin-service";
552
+ - import EpicService from "cemiar-epic-service";
553
+ - import EpicService from "cemiar-epic-service-common";
554
+ + import { MailService, AdminService, EpicService } from "@cemiar/cemiarlink-sdk";
555
+ ```
556
+
557
+ 3. **Install and test**:
558
+ ```bash
559
+ npm install
560
+ npm run build
561
+ npm test
562
+ ```
563
+
564
+ ## Models
565
+
566
+ All TypeScript models are exported and organized by service:
567
+
568
+ ```ts
569
+ import {
570
+ // Admin models
571
+ PdfReaderBody,
572
+ PdfReaderResponse,
573
+ ClassificationResult,
574
+ Email,
575
+ EmailAws,
576
+ SendMailResult,
577
+ Counter,
578
+ BusMessagePayload,
579
+
580
+ // Epic models
581
+ Activity,
582
+ Attachment,
583
+ Policy,
584
+ PolicyV2,
585
+ Customer,
586
+ Contact,
587
+ Transaction,
588
+ Employee,
589
+ Company,
590
+ Receipt,
591
+ Claim,
592
+ Opportunity,
593
+ Vehicle,
594
+ Driver,
595
+ Commission,
596
+ JournalEntry,
597
+
598
+ // Mail models
599
+ EmailReport,
600
+ EmailAttachment,
601
+ GMailFolder,
602
+ TransactionWatch,
603
+
604
+ // Google Ads models
605
+ GoogleAdsConversion,
606
+ GoogleAdsConversionUploadResponse,
607
+
608
+ // Sharepoint models
609
+ SharepointFileInfo,
610
+ SharepointDownloadResult
611
+ } from "@cemiar/cemiarlink-sdk";
612
+
613
+ // Or use namespaced imports
614
+ import { Models } from "@cemiar/cemiarlink-sdk";
615
+ const activity: Models.EpicModels.Activity = { /* ... */ };
616
+ ```
617
+
618
+ ## Exceptions
619
+
620
+ ```ts
621
+ import { EpicException, MissingInfo, NotProcessYet } from "@cemiar/cemiarlink-sdk";
622
+
623
+ try {
624
+ await epicService.getPolicy("invalid-id");
625
+ } catch (error) {
626
+ if (error instanceof EpicException) {
627
+ console.error("Epic API error:", error.message);
628
+ }
629
+ }
630
+ ```
631
+
632
+ ## Environment Variables
633
+
634
+ | Variable | Description |
635
+ |----------|-------------|
636
+ | `CEMIARLINK_BASE_URL` | Base CemiarLink API URL |
637
+ | `CEMIARLINK_MAIL_URL` | Mail service URL |
638
+ | `CEMIARLINK_ADMIN_URL` | Admin service URL |
639
+ | `CEMIARLINK_EPIC_URL` | Epic service URL |
640
+
641
+ ## Building
642
+
643
+ ```bash
644
+ cd cemiar-cemiarlink-sdk
645
+ npm install
646
+ npm run build # Linux/Mac
647
+ npm run buildWindows # Windows
648
+ ```
649
+
650
+ Output will be generated under `dist/`.
651
+
@@ -0,0 +1,4 @@
1
+ export interface CriteriaItem {
2
+ Code: string;
3
+ Description: string;
4
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,18 +1,68 @@
1
+ import { CriteriaItem } from './CriteriaItem';
2
+ import { OptionType } from './OptionType';
3
+ export declare enum DirectBillCommissionSearchStatus {
4
+ Suspended = 0,
5
+ Unpaid = 1,
6
+ Search = 2
7
+ }
8
+ export declare enum DirectBillCommissionComparisonType {
9
+ EqualTo = 0,
10
+ Containing = 1
11
+ }
1
12
  export interface DirectBillCommission {
2
- DirectBillCommissionId: string;
13
+ DirectBillCommissionID: number;
3
14
  IsReadOnly: boolean;
4
15
  PaidStatus: string;
5
- StatementStatus: string;
6
- StatementDescription: string;
7
- Description: string;
8
- MasterStatementNumber: string;
9
16
  ReconcileDetailItems: ReconcileDetailItem[];
17
+ StatementStatus: string;
18
+ SummaryValue: Summary;
19
+ Timestamp: string | null;
20
+ RecordDetailItems: RecordDetailItem[];
21
+ }
22
+ export interface DirectBillCommissionFilter {
23
+ AgencyCode?: string;
24
+ CreatedArea?: string;
25
+ DirectBillCommissionID?: number | null;
26
+ DirectBillCommissionStatus?: DirectBillCommissionSearchStatus;
27
+ EntityCode?: string;
28
+ EntityCodeType?: string;
29
+ EntityName?: string;
30
+ EntityNameComparisonType?: DirectBillCommissionComparisonType;
31
+ IncludeReversed?: boolean;
32
+ MasterStatementNumber?: string;
33
+ PaidArea?: string;
34
+ PaidStatus?: string;
35
+ PaymentID?: string;
36
+ ReferenceNumber?: string;
37
+ ReferenceNumberType?: string;
38
+ StatementNumber?: string;
10
39
  }
11
40
  export interface ReconcileDetailItem {
12
41
  Selected: boolean;
13
42
  TransactionID: number;
14
43
  }
15
- export interface Reconciliation {
16
- DirectBillCommissionId: number;
17
- ReconcileDetailItems: ReconcileDetailItem[];
44
+ export interface RecordDetailItem {
45
+ Selected: boolean;
46
+ TransactionID: number;
47
+ }
48
+ export interface Summary {
49
+ AccountingMonth: string;
50
+ AccountingMonthCriteria: string;
51
+ AgencyCriteriaValue: CriteriaItem;
52
+ BranchCriteriaValue: CriteriaItem;
53
+ BrokerExternalInternalBothCriteriaOption: OptionType;
54
+ CompanyBrokerOption: OptionType;
55
+ CreateSeparateStatements: boolean;
56
+ DefaultAsTransactionDescription: boolean;
57
+ DepartmentCriteriaValue: CriteriaItem;
58
+ DirectBillCommissionDescription: string;
59
+ EntityCriteriaValue: CriteriaItem;
60
+ IssuingCompanyCriteriaValue: CriteriaItem;
61
+ LineOfBusinessCriteriaValue: CriteriaItem;
62
+ MasterStatementNumber: string;
63
+ ProfitCenterCriteriaValue: CriteriaItem;
64
+ RecordReconcileCommissionsOption: OptionType;
65
+ StatementDescription: string;
66
+ StatementNumber: string;
67
+ StatementOwnerCode: string;
18
68
  }
@@ -1,2 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DirectBillCommissionComparisonType = exports.DirectBillCommissionSearchStatus = void 0;
4
+ var DirectBillCommissionSearchStatus;
5
+ (function (DirectBillCommissionSearchStatus) {
6
+ DirectBillCommissionSearchStatus[DirectBillCommissionSearchStatus["Suspended"] = 0] = "Suspended";
7
+ DirectBillCommissionSearchStatus[DirectBillCommissionSearchStatus["Unpaid"] = 1] = "Unpaid";
8
+ DirectBillCommissionSearchStatus[DirectBillCommissionSearchStatus["Search"] = 2] = "Search";
9
+ })(DirectBillCommissionSearchStatus || (exports.DirectBillCommissionSearchStatus = DirectBillCommissionSearchStatus = {}));
10
+ var DirectBillCommissionComparisonType;
11
+ (function (DirectBillCommissionComparisonType) {
12
+ DirectBillCommissionComparisonType[DirectBillCommissionComparisonType["EqualTo"] = 0] = "EqualTo";
13
+ DirectBillCommissionComparisonType[DirectBillCommissionComparisonType["Containing"] = 1] = "Containing";
14
+ })(DirectBillCommissionComparisonType || (exports.DirectBillCommissionComparisonType = DirectBillCommissionComparisonType = {}));
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BaseEpicService = void 0;
4
- const AxiosClient_1 = require("../utils/AxiosClient");
4
+ const AxiosClient_1 = require("../../utils/AxiosClient");
5
5
  /**
6
6
  * BaseEpicService provides common HTTP methods and error handling for Epic API services.
7
7
  * It wraps Axios and offers generic get, getOne, put, post, and delete methods for API communication.
@@ -0,0 +1,15 @@
1
+ import { DirectBillCommission, DirectBillCommissionFilter } from '../../models/epic/DirectBillCommission';
2
+ import { CallbackRequest } from '../../utils/CallbackRequest';
3
+ import { BaseEpicService } from './BaseEpicService';
4
+ /**
5
+ * DirectBillCommissionEpicService provides methods for direct bill commission-related Epic API operations.
6
+ * It extends BaseEpicService for common API functionality.
7
+ */
8
+ export declare class DirectBillCommissionEpicService extends BaseEpicService {
9
+ readonly baseUrl = "directBillCommission";
10
+ readonly asyncUrl: string;
11
+ getItem(id: number): Promise<DirectBillCommission>;
12
+ getList(queryParams: DirectBillCommissionFilter): Promise<DirectBillCommission[]>;
13
+ update(id: number, payload: Partial<DirectBillCommission>): Promise<string>;
14
+ updateAsync(id: number, request: CallbackRequest<Partial<DirectBillCommission>>): Promise<string>;
15
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DirectBillCommissionEpicService = void 0;
4
+ const BaseEpicService_1 = require("./BaseEpicService");
5
+ /**
6
+ * DirectBillCommissionEpicService provides methods for direct bill commission-related Epic API operations.
7
+ * It extends BaseEpicService for common API functionality.
8
+ */
9
+ class DirectBillCommissionEpicService extends BaseEpicService_1.BaseEpicService {
10
+ constructor() {
11
+ super(...arguments);
12
+ this.baseUrl = 'directBillCommission';
13
+ this.asyncUrl = `${this.baseUrl}/callback`;
14
+ }
15
+ async getItem(id) {
16
+ return this.getOne(this.baseUrl, id);
17
+ }
18
+ async getList(queryParams) {
19
+ return this.get(this.baseUrl, queryParams);
20
+ }
21
+ async update(id, payload) {
22
+ return await this.put(`${this.baseUrl}/${id}`, payload);
23
+ }
24
+ async updateAsync(id, request) {
25
+ return this.put(`${this.asyncUrl}/${id}`, request);
26
+ }
27
+ }
28
+ exports.DirectBillCommissionEpicService = DirectBillCommissionEpicService;
@@ -1,38 +1,33 @@
1
- import { Activity, CreateActivity } from '../models/epic/Activity';
2
- import { AdditionalInterest } from '../models/epic/AdditionalInterest';
3
- import { Attachment, AttachmentDetail, CreateAttachment } from '../models/epic/Attachment';
4
- import { Claim } from '../models/epic/Claim';
5
- import { Commission } from '../models/epic/Commission';
6
- import { Company } from '../models/epic/Company';
7
- import { Contact, CreateContact } from '../models/epic/Contact';
8
- import { CreateCustomer, Customer } from '../models/epic/Customer';
9
- import { DirectBillCommission } from '../models/epic/DirectBillCommission';
10
- import { Driver } from '../models/epic/Driver';
11
- import { GeneralLedgerReconcileBank } from '../models/epic/GeneralLedgerReconcileBank';
12
- import { Habitational } from '../models/epic/Habitational';
13
- import { Line } from '../models/epic/Line';
14
- import { LookUp } from '../models/epic/Lookup';
15
- import { Opportunity } from '../models/epic/Opportunity';
16
- import { PayableContract } from '../models/epic/PayableContract';
17
- import { CreatePolicy, Policy } from '../models/epic/Policy';
18
- import { PolicyV2, PolicyV2Model } from '../models/epic/PolicyV2';
19
- import { Receipt } from '../models/epic/Receipt';
20
- import { RenewalStage } from '../models/epic/RenewalStage';
1
+ import { Activity, CreateActivity } from '../../models/epic/Activity';
2
+ import { AdditionalInterest } from '../../models/epic/AdditionalInterest';
3
+ import { Attachment, AttachmentDetail, CreateAttachment } from '../../models/epic/Attachment';
4
+ import { Broker } from '../../models/epic/Broker';
5
+ import { Claim } from '../../models/epic/Claim';
6
+ import { Commission } from '../../models/epic/Commission';
7
+ import { Company } from '../../models/epic/Company';
8
+ import { Contact, CreateContact } from '../../models/epic/Contact';
9
+ import { CreateCustomer, Customer } from '../../models/epic/Customer';
10
+ import { Driver } from '../../models/epic/Driver';
11
+ import { Employee } from '../../models/epic/Employee';
12
+ import { GeneralLedgerReconcileBank } from '../../models/epic/GeneralLedgerReconcileBank';
13
+ import { Habitational } from '../../models/epic/Habitational';
14
+ import { CreateJournalEntry, JournalEntry } from '../../models/epic/JournalEntry';
15
+ import { Line } from '../../models/epic/Line';
16
+ import { LookUp } from '../../models/epic/Lookup';
17
+ import { Opportunity } from '../../models/epic/Opportunity';
18
+ import { PayableContract } from '../../models/epic/PayableContract';
19
+ import { CreatePolicy, Policy } from '../../models/epic/Policy';
20
+ import { PolicyV2, PolicyV2Model } from '../../models/epic/PolicyV2';
21
+ import { Receipt } from '../../models/epic/Receipt';
22
+ import { RenewalStage } from '../../models/epic/RenewalStage';
23
+ import { CreatePaymentTransaction, CreateTransaction, FinanceTransaction, FinanceTransactionResult, Transaction, TransactionApplyCreditsToDebits } from '../../models/epic/Transaction';
24
+ import { Vehicle } from '../../models/epic/Vehicle';
21
25
  import { BaseEpicService } from './BaseEpicService';
22
- import { JobEpicService } from './JobEpicService';
26
+ import { DirectBillCommissionEpicService } from './DirectBillCommissionEpicService';
23
27
  import { MultiCarrierScheduleEpicService } from './MultiCarrierScheduleEpicService';
24
- import { Broker } from '../models/epic/Broker';
25
- import { Employee } from '../models/epic/Employee';
26
- import { CreatePaymentTransaction, CreateTransaction, FinanceTransaction, FinanceTransactionResult, Transaction, TransactionApplyCreditsToDebits } from '../models/epic/Transaction';
27
- import { Vehicle } from '../models/epic/Vehicle';
28
- import { CreateJournalEntry, JournalEntry } from '../models/epic/JournalEntry';
29
- /**
30
- * EpicService provides methods to interact with the Epic API for activities, attachments, policies, transactions, and more.
31
- * It extends BaseEpicService and includes job and multi-carrier schedule services for specialized operations.
32
- */
33
28
  export declare class EpicService extends BaseEpicService {
34
- job: JobEpicService;
35
29
  multiCarrierSchedule: MultiCarrierScheduleEpicService;
30
+ directBillCommission: DirectBillCommissionEpicService;
36
31
  constructor(epicUrl: string | undefined, headers: any);
37
32
  getActivity(activityId: string): Promise<Activity>;
38
33
  getActivities(queryParams: object): Promise<Activity[]>;
@@ -106,9 +101,6 @@ export declare class EpicService extends BaseEpicService {
106
101
  getPolicyLines(queryParams: object): Promise<Line[]>;
107
102
  createPolicyLine(policyLine: object): Promise<string>;
108
103
  updatePolicyLine(lineId: string, payload: object): Promise<string>;
109
- getDirectBillCommission(commissionId: string): Promise<DirectBillCommission>;
110
- getDirectBillCommissions(queryParams: object): Promise<DirectBillCommission[]>;
111
- updateDirectBillCommission(commissionId: string, payload: object): Promise<string>;
112
104
  getReceipts(queryParams: object): Promise<Receipt[]>;
113
105
  getReceipt(receiptId: string): Promise<Receipt>;
114
106
  updateReceipt(receiptId: string, payload: object): Promise<string>;
@@ -1,19 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EpicService = void 0;
4
- const EpicException_1 = require("../exceptions/EpicException");
4
+ const EpicException_1 = require("../../exceptions/EpicException");
5
5
  const BaseEpicService_1 = require("./BaseEpicService");
6
- const JobEpicService_1 = require("./JobEpicService");
6
+ const DirectBillCommissionEpicService_1 = require("./DirectBillCommissionEpicService");
7
7
  const MultiCarrierScheduleEpicService_1 = require("./MultiCarrierScheduleEpicService");
8
- /**
9
- * EpicService provides methods to interact with the Epic API for activities, attachments, policies, transactions, and more.
10
- * It extends BaseEpicService and includes job and multi-carrier schedule services for specialized operations.
11
- */
12
8
  class EpicService extends BaseEpicService_1.BaseEpicService {
13
9
  constructor(epicUrl, headers) {
14
10
  super(epicUrl, headers);
15
- this.job = new JobEpicService_1.JobEpicService(epicUrl, headers);
16
11
  this.multiCarrierSchedule = new MultiCarrierScheduleEpicService_1.MultiCarrierScheduleEpicService(epicUrl, headers);
12
+ this.directBillCommission = new DirectBillCommissionEpicService_1.DirectBillCommissionEpicService(epicUrl, headers);
17
13
  }
18
14
  async getActivity(activityId) {
19
15
  return this.getOne('activity', activityId);
@@ -245,15 +241,6 @@ class EpicService extends BaseEpicService_1.BaseEpicService {
245
241
  async updatePolicyLine(lineId, payload) {
246
242
  return this.put(`policyLine/${lineId}`, payload);
247
243
  }
248
- async getDirectBillCommission(commissionId) {
249
- return this.getOne('directBillCommission', commissionId);
250
- }
251
- async getDirectBillCommissions(queryParams) {
252
- return this.get('directBillCommission', queryParams);
253
- }
254
- async updateDirectBillCommission(commissionId, payload) {
255
- return await this.put(`directBillCommission/${commissionId}`, payload);
256
- }
257
244
  async getReceipts(queryParams) {
258
245
  return await this.get('receipt', queryParams);
259
246
  }
@@ -1,5 +1,5 @@
1
- import { BaseEpicService } from "./BaseEpicService";
2
- import { MultiCarrierScheduleModel } from "../models/epic/MultiCarrierSchedule";
1
+ import { BaseEpicService } from './BaseEpicService';
2
+ import { MultiCarrierScheduleModel } from '../../models/epic/MultiCarrierSchedule';
3
3
  /**
4
4
  * MultiCarrierScheduleEpicService provides methods to manage multi-carrier schedules via the Epic API.
5
5
  * It extends BaseEpicService for common API functionality.
@@ -0,0 +1 @@
1
+ export * from './EpicService';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./EpicService"), exports);
@@ -1,8 +1,5 @@
1
1
  export * from './Admin';
2
- export * from './BaseEpicService';
3
- export * from './Epic';
2
+ export * from './epic';
4
3
  export * from './GoogleAdsService';
5
- export * from './JobEpicService';
6
4
  export * from './Mail';
7
- export * from './MultiCarrierScheduleEpicService';
8
5
  export * from './SharepointService';
@@ -15,10 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./Admin"), exports);
18
- __exportStar(require("./BaseEpicService"), exports);
19
- __exportStar(require("./Epic"), exports);
18
+ __exportStar(require("./epic"), exports);
20
19
  __exportStar(require("./GoogleAdsService"), exports);
21
- __exportStar(require("./JobEpicService"), exports);
22
20
  __exportStar(require("./Mail"), exports);
23
- __exportStar(require("./MultiCarrierScheduleEpicService"), exports);
24
21
  __exportStar(require("./SharepointService"), exports);
@@ -0,0 +1,5 @@
1
+ export interface CallbackRequest<T = unknown> {
2
+ callbackUrl: string;
3
+ callbackId: string;
4
+ payload?: T;
5
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,3 +1,4 @@
1
1
  export * from './AxiosClient';
2
2
  export * from './DeepPartial';
3
+ export * from './CallbackRequest';
3
4
  export { default as Excel } from './Excel';
@@ -20,5 +20,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
20
20
  exports.Excel = void 0;
21
21
  __exportStar(require("./AxiosClient"), exports);
22
22
  __exportStar(require("./DeepPartial"), exports);
23
+ __exportStar(require("./CallbackRequest"), exports);
23
24
  var Excel_1 = require("./Excel");
24
25
  Object.defineProperty(exports, "Excel", { enumerable: true, get: function () { return __importDefault(Excel_1).default; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cemiar/cemiarlink-sdk",
3
- "version": "1.0.40",
3
+ "version": "1.0.42",
4
4
  "description": "CemiarLink SDK to access CemiarLink API services",
5
5
  "engines": {
6
6
  "npm": ">=9.5.1",
@@ -1,11 +0,0 @@
1
- import { BaseEpicService } from "./BaseEpicService";
2
- import { DirectBillCommission, Reconciliation } from "../models/epic/DirectBillCommission";
3
- /**
4
- * JobEpicService provides methods for job-related Epic API operations such as reconciliation and direct bill commission updates.
5
- * It extends BaseEpicService for common API functionality.
6
- */
7
- export declare class JobEpicService extends BaseEpicService {
8
- readonly baseUrl = "job";
9
- reconcile(payload: Reconciliation): Promise<string>;
10
- updateDirectBillCommission(commissionId: string, payload: Partial<DirectBillCommission>): Promise<string>;
11
- }
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.JobEpicService = void 0;
4
- const BaseEpicService_1 = require("./BaseEpicService");
5
- /**
6
- * JobEpicService provides methods for job-related Epic API operations such as reconciliation and direct bill commission updates.
7
- * It extends BaseEpicService for common API functionality.
8
- */
9
- class JobEpicService extends BaseEpicService_1.BaseEpicService {
10
- constructor() {
11
- super(...arguments);
12
- this.baseUrl = 'job';
13
- }
14
- async reconcile(payload) {
15
- return this.post(`${this.baseUrl}/reconcile`, payload);
16
- }
17
- async updateDirectBillCommission(commissionId, payload) {
18
- return this.put(`${this.baseUrl}/directBillCommission/${commissionId}`, payload);
19
- }
20
- }
21
- exports.JobEpicService = JobEpicService;