@ripwords/myinvois-client 0.2.2 → 0.2.4

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 (41) hide show
  1. package/dist/api/documentManagement.d.ts +5 -5
  2. package/dist/api/documentSubmission.d.ts +5 -5
  3. package/dist/api/documentTypeManagement.d.ts +7 -7
  4. package/dist/api/notificationManagement.d.ts +6 -6
  5. package/dist/api/platformLogin.d.ts +5 -5
  6. package/dist/api/taxpayerValidation.d.ts +7 -7
  7. package/dist/api/taxpayerValidation.js +1 -1
  8. package/dist/documentTypeManagement-DXRLfTsW.cjs.map +1 -1
  9. package/dist/{documents-BqM9qOnB.d.cts → documents-DCOYxz61.d.cts} +6 -7
  10. package/dist/{documents-BgXt86Qp.d.ts → documents-zzL50wnG.d.ts} +5 -6
  11. package/dist/index.cjs +10 -10
  12. package/dist/index.cjs.map +1 -1
  13. package/dist/index.d.ts +20 -20
  14. package/dist/index.js +10 -10
  15. package/dist/index22.cjs +1 -1
  16. package/dist/index63.cts.map +1 -1
  17. package/dist/index64.cts.map +1 -1
  18. package/dist/index66.cts.map +1 -1
  19. package/dist/index67.cts.map +1 -1
  20. package/dist/notificationManagement-C_qrFwWL.cjs.map +1 -1
  21. package/dist/{signatures-hFbt_std.d.cts → signatures-CyDSZr_e.d.cts} +1 -1
  22. package/dist/{state-codes-BlILGZ9d.d.cts → state-codes-u3ppueWo.d.cts} +1 -1
  23. package/dist/{tax-types-B5sQ8UyN.d.cts → tax-types-fu5Q6dic.d.cts} +1 -1
  24. package/dist/{taxpayer-fpGIHNXp.d.ts → taxpayer-CxAVm7lJ.d.ts} +1 -1
  25. package/dist/{taxpayer-q6fVtwaA.d.cts → taxpayer-aaXyVf7B.d.cts} +2 -2
  26. package/dist/{taxpayerValidation-DdeXCvPT.cjs → taxpayerValidation-CSuifcY1.cjs} +2 -15
  27. package/dist/taxpayerValidation-CSuifcY1.cjs.map +1 -0
  28. package/dist/{taxpayerValidation-DI4B6kWx.js → taxpayerValidation-DiLGJg1l.js} +1 -14
  29. package/dist/types/documents.d.ts +4 -3
  30. package/dist/types/index.d.ts +5 -5
  31. package/dist/types/signatures.d.ts +1 -1
  32. package/dist/types/state-codes.d.ts +1 -1
  33. package/dist/types/tax-types.d.ts +1 -1
  34. package/dist/types/taxpayer.d.ts +5 -4
  35. package/dist/utils/document.d.ts +5 -5
  36. package/dist/utils/signature-diagnostics.d.ts +5 -5
  37. package/package.json +1 -1
  38. package/dist/taxpayerValidation-DdeXCvPT.cjs.map +0 -1
  39. /package/dist/{signatures-DOKNMiZI.d.ts → signatures-C-nCPDqt.d.ts} +0 -0
  40. /package/dist/{state-codes-VOFWhHA0.d.ts → state-codes-BaGjZcA8.d.ts} +0 -0
  41. /package/dist/{tax-types-ieqw5Ze7.d.ts → tax-types-BskcyNBv.d.ts} +0 -0
@@ -13,9 +13,9 @@ import "../7X-Ckv9bbzG.js";
13
13
  import "../8X-C37BJTl6.js";
14
14
  import "../9X-_XRgT2-_.js";
15
15
  import "../msic-codes-CiPeemFK.js";
16
- import "../signatures-DOKNMiZI.js";
17
- import "../tax-types-ieqw5Ze7.js";
18
- import { DocumentStatus, DocumentSummary, DocumentValidationResult, DocumentValidationStepResult } from "../documents-BgXt86Qp.js";
16
+ import "../tax-types-BskcyNBv.js";
17
+ import "../state-codes-BaGjZcA8.js";
18
+ import { DocumentStatus, DocumentSummary, DocumentValidationResult, DocumentValidationStepResult } from "../documents-zzL50wnG.js";
19
19
  import "../payment-modes-NpE3OcCV.js";
20
20
  import "../1X-C72Wa4pk.js";
21
21
  import "../2X-CH89y3Af.js";
@@ -53,9 +53,9 @@ import "../YX-F34sJ7Ik.js";
53
53
  import "../ZX-CDQOfsHh.js";
54
54
  import "../XX-DOA-10JW.js";
55
55
  import "../unit-types-VgYXIwTT.js";
56
- import "../state-codes-VOFWhHA0.js";
56
+ import "../signatures-C-nCPDqt.js";
57
57
  import "../notifications-B4l_qRj7.js";
58
- import "../taxpayer-fpGIHNXp.js";
58
+ import "../taxpayer-CxAVm7lJ.js";
59
59
  import { Fetch } from "../utils-B3mo51Zp.js";
60
60
  import "../index-FTgB2nM6.js";
61
61
 
@@ -13,9 +13,9 @@ import "../7X-Ckv9bbzG.js";
13
13
  import "../8X-C37BJTl6.js";
14
14
  import "../9X-_XRgT2-_.js";
15
15
  import "../msic-codes-CiPeemFK.js";
16
- import "../signatures-DOKNMiZI.js";
17
- import "../tax-types-ieqw5Ze7.js";
18
- import { DocumentSummary, InvoiceV1_1, SigningCredentials, StandardError, SubmissionResponse, SubmissionStatus } from "../documents-BgXt86Qp.js";
16
+ import "../tax-types-BskcyNBv.js";
17
+ import "../state-codes-BaGjZcA8.js";
18
+ import { DocumentSummary, InvoiceV1_1, SigningCredentials, StandardError, SubmissionResponse, SubmissionStatus } from "../documents-zzL50wnG.js";
19
19
  import "../payment-modes-NpE3OcCV.js";
20
20
  import "../1X-C72Wa4pk.js";
21
21
  import "../2X-CH89y3Af.js";
@@ -53,9 +53,9 @@ import "../YX-F34sJ7Ik.js";
53
53
  import "../ZX-CDQOfsHh.js";
54
54
  import "../XX-DOA-10JW.js";
55
55
  import "../unit-types-VgYXIwTT.js";
56
- import "../state-codes-VOFWhHA0.js";
56
+ import "../signatures-C-nCPDqt.js";
57
57
  import "../notifications-B4l_qRj7.js";
58
- import "../taxpayer-fpGIHNXp.js";
58
+ import "../taxpayer-CxAVm7lJ.js";
59
59
  import { Fetch } from "../utils-B3mo51Zp.js";
60
60
  import "../index-FTgB2nM6.js";
61
61
 
@@ -13,9 +13,9 @@ import "../7X-Ckv9bbzG.js";
13
13
  import "../8X-C37BJTl6.js";
14
14
  import "../9X-_XRgT2-_.js";
15
15
  import "../msic-codes-CiPeemFK.js";
16
- import "../signatures-DOKNMiZI.js";
17
- import "../tax-types-ieqw5Ze7.js";
18
- import { DocumentTypeResponse, DocumentTypeVersionResponse, DocumentTypesResponse, StandardError } from "../documents-BgXt86Qp.js";
16
+ import "../tax-types-BskcyNBv.js";
17
+ import "../state-codes-BaGjZcA8.js";
18
+ import { DocumentTypeResponse, DocumentTypeVersionResponse, DocumentTypesResponse } from "../documents-zzL50wnG.js";
19
19
  import "../payment-modes-NpE3OcCV.js";
20
20
  import "../1X-C72Wa4pk.js";
21
21
  import "../2X-CH89y3Af.js";
@@ -53,9 +53,9 @@ import "../YX-F34sJ7Ik.js";
53
53
  import "../ZX-CDQOfsHh.js";
54
54
  import "../XX-DOA-10JW.js";
55
55
  import "../unit-types-VgYXIwTT.js";
56
- import "../state-codes-VOFWhHA0.js";
56
+ import "../signatures-C-nCPDqt.js";
57
57
  import "../notifications-B4l_qRj7.js";
58
- import "../taxpayer-fpGIHNXp.js";
58
+ import "../taxpayer-CxAVm7lJ.js";
59
59
  import { Fetch } from "../utils-B3mo51Zp.js";
60
60
  import "../index-FTgB2nM6.js";
61
61
 
@@ -64,7 +64,7 @@ interface DocumentTypeContext {
64
64
  fetch: Fetch;
65
65
  }
66
66
  declare function getDocumentTypes(context: DocumentTypeContext): Promise<DocumentTypesResponse>;
67
- declare function getDocumentType(context: DocumentTypeContext, id: number): Promise<DocumentTypeResponse | StandardError>;
68
- declare function getDocumentTypeVersion(context: DocumentTypeContext, id: number, versionId: number): Promise<DocumentTypeVersionResponse | StandardError>;
67
+ declare function getDocumentType(context: DocumentTypeContext, id: number): Promise<DocumentTypeResponse>;
68
+ declare function getDocumentTypeVersion(context: DocumentTypeContext, id: number, versionId: number): Promise<DocumentTypeVersionResponse>;
69
69
  //#endregion
70
70
  export { getDocumentType, getDocumentTypeVersion, getDocumentTypes };
@@ -13,9 +13,9 @@ import "../7X-Ckv9bbzG.js";
13
13
  import "../8X-C37BJTl6.js";
14
14
  import "../9X-_XRgT2-_.js";
15
15
  import "../msic-codes-CiPeemFK.js";
16
- import "../signatures-DOKNMiZI.js";
17
- import "../tax-types-ieqw5Ze7.js";
18
- import { StandardError } from "../documents-BgXt86Qp.js";
16
+ import "../tax-types-BskcyNBv.js";
17
+ import "../state-codes-BaGjZcA8.js";
18
+ import "../documents-zzL50wnG.js";
19
19
  import "../payment-modes-NpE3OcCV.js";
20
20
  import "../1X-C72Wa4pk.js";
21
21
  import "../2X-CH89y3Af.js";
@@ -53,9 +53,9 @@ import "../YX-F34sJ7Ik.js";
53
53
  import "../ZX-CDQOfsHh.js";
54
54
  import "../XX-DOA-10JW.js";
55
55
  import "../unit-types-VgYXIwTT.js";
56
- import "../state-codes-VOFWhHA0.js";
56
+ import "../signatures-C-nCPDqt.js";
57
57
  import { NotificationResponse, NotificationSearchParams } from "../notifications-B4l_qRj7.js";
58
- import "../taxpayer-fpGIHNXp.js";
58
+ import "../taxpayer-CxAVm7lJ.js";
59
59
  import { Fetch } from "../utils-B3mo51Zp.js";
60
60
  import "../index-FTgB2nM6.js";
61
61
 
@@ -63,6 +63,6 @@ import "../index-FTgB2nM6.js";
63
63
  interface NotificationContext {
64
64
  fetch: Fetch;
65
65
  }
66
- declare function getNotifications(context: NotificationContext, params: NotificationSearchParams): Promise<NotificationResponse | StandardError>;
66
+ declare function getNotifications(context: NotificationContext, params: NotificationSearchParams): Promise<NotificationResponse>;
67
67
  //#endregion
68
68
  export { getNotifications };
@@ -13,9 +13,9 @@ import "../7X-Ckv9bbzG.js";
13
13
  import "../8X-C37BJTl6.js";
14
14
  import "../9X-_XRgT2-_.js";
15
15
  import "../msic-codes-CiPeemFK.js";
16
- import "../signatures-DOKNMiZI.js";
17
- import "../tax-types-ieqw5Ze7.js";
18
- import "../documents-BgXt86Qp.js";
16
+ import "../tax-types-BskcyNBv.js";
17
+ import "../state-codes-BaGjZcA8.js";
18
+ import "../documents-zzL50wnG.js";
19
19
  import "../payment-modes-NpE3OcCV.js";
20
20
  import "../1X-C72Wa4pk.js";
21
21
  import "../2X-CH89y3Af.js";
@@ -53,9 +53,9 @@ import "../YX-F34sJ7Ik.js";
53
53
  import "../ZX-CDQOfsHh.js";
54
54
  import "../XX-DOA-10JW.js";
55
55
  import "../unit-types-VgYXIwTT.js";
56
- import "../state-codes-VOFWhHA0.js";
56
+ import "../signatures-C-nCPDqt.js";
57
57
  import "../notifications-B4l_qRj7.js";
58
- import "../taxpayer-fpGIHNXp.js";
58
+ import "../taxpayer-CxAVm7lJ.js";
59
59
  import "../utils-B3mo51Zp.js";
60
60
  import { ClientCredentials } from "../index-FTgB2nM6.js";
61
61
 
@@ -13,9 +13,9 @@ import "../7X-Ckv9bbzG.js";
13
13
  import "../8X-C37BJTl6.js";
14
14
  import "../9X-_XRgT2-_.js";
15
15
  import "../msic-codes-CiPeemFK.js";
16
- import "../signatures-DOKNMiZI.js";
17
- import "../tax-types-ieqw5Ze7.js";
18
- import { RegistrationType, StandardError } from "../documents-BgXt86Qp.js";
16
+ import "../tax-types-BskcyNBv.js";
17
+ import "../state-codes-BaGjZcA8.js";
18
+ import { RegistrationType } from "../documents-zzL50wnG.js";
19
19
  import "../payment-modes-NpE3OcCV.js";
20
20
  import "../1X-C72Wa4pk.js";
21
21
  import "../2X-CH89y3Af.js";
@@ -53,9 +53,9 @@ import "../YX-F34sJ7Ik.js";
53
53
  import "../ZX-CDQOfsHh.js";
54
54
  import "../XX-DOA-10JW.js";
55
55
  import "../unit-types-VgYXIwTT.js";
56
- import "../state-codes-VOFWhHA0.js";
56
+ import "../signatures-C-nCPDqt.js";
57
57
  import "../notifications-B4l_qRj7.js";
58
- import { TaxpayerQRCodeResponse, TinSearchParams, TinSearchResponse } from "../taxpayer-fpGIHNXp.js";
58
+ import { TaxpayerQRCodeResponse, TinSearchParams, TinSearchResponse } from "../taxpayer-CxAVm7lJ.js";
59
59
  import { Fetch } from "../utils-B3mo51Zp.js";
60
60
  import "../index-FTgB2nM6.js";
61
61
 
@@ -64,8 +64,8 @@ interface TaxpayerContext {
64
64
  fetch: Fetch;
65
65
  debug: boolean;
66
66
  }
67
- declare function tinSearch(context: TaxpayerContext, params: TinSearchParams): Promise<TinSearchResponse | StandardError>;
67
+ declare function tinSearch(context: TaxpayerContext, params: TinSearchParams): Promise<TinSearchResponse>;
68
68
  declare function verifyTin(context: TaxpayerContext, tin: string, idType: RegistrationType, idValue: string): Promise<boolean>;
69
- declare function taxpayerQRCode(context: TaxpayerContext, qrCodeText: string): Promise<TaxpayerQRCodeResponse | StandardError>;
69
+ declare function taxpayerQRCode(context: TaxpayerContext, qrCodeText: string): Promise<TaxpayerQRCodeResponse>;
70
70
  //#endregion
71
71
  export { taxpayerQRCode, tinSearch, verifyTin };
@@ -1,3 +1,3 @@
1
- import { taxpayerQRCode, tinSearch, verifyTin } from "../taxpayerValidation-DI4B6kWx.js";
1
+ import { taxpayerQRCode, tinSearch, verifyTin } from "../taxpayerValidation-DiLGJg1l.js";
2
2
 
3
3
  export { taxpayerQRCode, tinSearch, verifyTin };
@@ -1 +1 @@
1
- {"version":3,"file":"documentTypeManagement-DXRLfTsW.cjs","names":["context: DocumentTypeContext","id: number","versionId: number"],"sources":["../src/api/documentTypeManagement.ts"],"sourcesContent":["import type {\n DocumentTypesResponse,\n DocumentTypeResponse,\n DocumentTypeVersionResponse,\n StandardError,\n Fetch,\n} from '../types'\n\ninterface DocumentTypeContext {\n fetch: Fetch\n}\n\nexport async function getDocumentTypes(\n context: DocumentTypeContext,\n): Promise<DocumentTypesResponse> {\n const { fetch } = context\n\n const response = await fetch('/api/v1.0/documenttypes')\n const data = (await response.json()) as DocumentTypesResponse\n\n return data\n}\n\nexport async function getDocumentType(\n context: DocumentTypeContext,\n id: number,\n): Promise<DocumentTypeResponse | StandardError> {\n const { fetch } = context\n\n const response = await fetch(`/api/v1.0/documenttypes/${id}`)\n const data = (await response.json()) as DocumentTypeResponse\n\n return data\n}\n\nexport async function getDocumentTypeVersion(\n context: DocumentTypeContext,\n id: number,\n versionId: number,\n): Promise<DocumentTypeVersionResponse | StandardError> {\n const { fetch } = context\n\n const response = await fetch(\n `/api/v1.0/documenttypes/${id}/versions/${versionId}`,\n )\n\n const data = (await response.json()) as DocumentTypeVersionResponse\n\n return data\n}\n"],"mappings":";;AAYA,eAAsB,iBACpBA,SACgC;CAChC,MAAM,EAAE,OAAO,GAAG;CAElB,MAAM,WAAW,MAAM,MAAM,0BAA0B;CACvD,MAAM,OAAQ,MAAM,SAAS,MAAM;AAEnC,QAAO;AACR;AAED,eAAsB,gBACpBA,SACAC,IAC+C;CAC/C,MAAM,EAAE,OAAO,GAAG;CAElB,MAAM,WAAW,MAAM,OAAO,0BAA0B,GAAG,EAAE;CAC7D,MAAM,OAAQ,MAAM,SAAS,MAAM;AAEnC,QAAO;AACR;AAED,eAAsB,uBACpBD,SACAC,IACAC,WACsD;CACtD,MAAM,EAAE,OAAO,GAAG;CAElB,MAAM,WAAW,MAAM,OACpB,0BAA0B,GAAG,YAAY,UAAU,EACrD;CAED,MAAM,OAAQ,MAAM,SAAS,MAAM;AAEnC,QAAO;AACR"}
1
+ {"version":3,"file":"documentTypeManagement-DXRLfTsW.cjs","names":["context: DocumentTypeContext","id: number","versionId: number"],"sources":["../src/api/documentTypeManagement.ts"],"sourcesContent":["import type {\n DocumentTypeResponse,\n DocumentTypesResponse,\n DocumentTypeVersionResponse,\n Fetch,\n} from '../types'\n\ninterface DocumentTypeContext {\n fetch: Fetch\n}\n\nexport async function getDocumentTypes(\n context: DocumentTypeContext,\n): Promise<DocumentTypesResponse> {\n const { fetch } = context\n\n const response = await fetch('/api/v1.0/documenttypes')\n const data = (await response.json()) as DocumentTypesResponse\n\n return data\n}\n\nexport async function getDocumentType(\n context: DocumentTypeContext,\n id: number,\n): Promise<DocumentTypeResponse> {\n const { fetch } = context\n\n const response = await fetch(`/api/v1.0/documenttypes/${id}`)\n const data = (await response.json()) as DocumentTypeResponse\n\n return data\n}\n\nexport async function getDocumentTypeVersion(\n context: DocumentTypeContext,\n id: number,\n versionId: number,\n): Promise<DocumentTypeVersionResponse> {\n const { fetch } = context\n\n const response = await fetch(\n `/api/v1.0/documenttypes/${id}/versions/${versionId}`,\n )\n\n const data = (await response.json()) as DocumentTypeVersionResponse\n\n return data\n}\n"],"mappings":";;AAWA,eAAsB,iBACpBA,SACgC;CAChC,MAAM,EAAE,OAAO,GAAG;CAElB,MAAM,WAAW,MAAM,MAAM,0BAA0B;CACvD,MAAM,OAAQ,MAAM,SAAS,MAAM;AAEnC,QAAO;AACR;AAED,eAAsB,gBACpBA,SACAC,IAC+B;CAC/B,MAAM,EAAE,OAAO,GAAG;CAElB,MAAM,WAAW,MAAM,OAAO,0BAA0B,GAAG,EAAE;CAC7D,MAAM,OAAQ,MAAM,SAAS,MAAM;AAEnC,QAAO;AACR;AAED,eAAsB,uBACpBD,SACAC,IACAC,WACsC;CACtC,MAAM,EAAE,OAAO,GAAG;CAElB,MAAM,WAAW,MAAM,OACpB,0BAA0B,GAAG,YAAY,UAAU,EACrD;CAED,MAAM,OAAQ,MAAM,SAAS,MAAM;AAEnC,QAAO;AACR"}
@@ -1,9 +1,10 @@
1
1
  import { ClassificationCode } from "./classification-codes-B15PbWxz.cjs";
2
+ import { CountryCode } from "./country-code-DPeNFMMi.cjs";
2
3
  import { CurrencyCode } from "./currencies-S5g1gzBU.cjs";
3
4
  import { EInvoiceTypeCode } from "./e-invoice-BuwtFnlI.cjs";
4
5
  import { MSICCode } from "./msic-codes-CIKdPqag.cjs";
5
- import { IssuerDigitalSignature } from "./signatures-hFbt_std.cjs";
6
- import { TaxTypeCode } from "./tax-types-B5sQ8UyN.cjs";
6
+ import { TaxTypeCode } from "./tax-types-fu5Q6dic.cjs";
7
+ import { StateCode } from "./state-codes-u3ppueWo.cjs";
7
8
 
8
9
  //#region src/types/documents.d.ts
9
10
  type RegistrationType = 'BRN' | 'NRIC' | 'PASSPORT' | 'ARMY';
@@ -22,9 +23,9 @@ interface Address {
22
23
  /** City name. Max 50 chars. */
23
24
  cityName: string;
24
25
  /** State code. Refer to /codes/state-codes/. Max 50 chars. */
25
- state: string;
26
+ state: StateCode;
26
27
  /** Country code (ISO 3166-1). Refer to /codes/countries/. Max 3 chars. */
27
- country: string; // MYS
28
+ country: CountryCode; // MYS
28
29
  }
29
30
 
30
31
  /**
@@ -221,8 +222,6 @@ interface InvoiceV1_1 {
221
222
  eInvoiceDate: string; // e.g., '2017-11-26'
222
223
  /** Time of issuance (HH:mm:ssZ) in UTC. Max 9 chars. */
223
224
  eInvoiceTime: string; // e.g., '15:30:00Z'
224
- /** Issuer's digital signature. Refer to /signature/ documentation. */
225
- issuerDigitalSignature: IssuerDigitalSignature;
226
225
  /** Invoice currency code. Refer to /codes/currencies/. Max 3 chars. */
227
226
  invoiceCurrencyCode: CurrencyCode; // e.g., 'MYR'
228
227
  /** Invoice line items. */
@@ -892,4 +891,4 @@ interface DocumentTypeVersionResponse {
892
891
  }
893
892
  //#endregion
894
893
  export { Address, Buyer, CompleteInvoice, DocumentStatus, DocumentSummary, DocumentTypeResponse, DocumentTypeVersion, DocumentTypeVersionResponse, DocumentTypesResponse, DocumentValidationResult, DocumentValidationStepResult, FinalDocumentData, GetSubmissionResponse, InvoiceLineItem, InvoiceSubmission, InvoiceV1_1, LegalMonetaryTotal, RegistrationType, ResponseDocument, SignedInfoObject, SignedInvoiceSubmission, SignedPropertiesData, SignedPropertiesObject, SigningCredentials, StandardError, SubmissionResponse, SubmissionStatus, Supplier, TaxCategory, TaxSubtotal, TaxTotal, UBLDocument, WorkflowParameter };
895
- //# sourceMappingURL=documents-BqM9qOnB.d.cts.map
894
+ //# sourceMappingURL=documents-DCOYxz61.d.cts.map
@@ -1,9 +1,10 @@
1
1
  import { ClassificationCode } from "./classification-codes-B1D5xbq5.js";
2
+ import { CountryCode } from "./country-code-D42kAyNH.js";
2
3
  import { CurrencyCode } from "./currencies-CDveO_yz.js";
3
4
  import { EInvoiceTypeCode } from "./e-invoice-BxNC6V_j.js";
4
5
  import { MSICCode } from "./msic-codes-CiPeemFK.js";
5
- import { IssuerDigitalSignature } from "./signatures-DOKNMiZI.js";
6
- import { TaxTypeCode } from "./tax-types-ieqw5Ze7.js";
6
+ import { TaxTypeCode } from "./tax-types-BskcyNBv.js";
7
+ import { StateCode } from "./state-codes-BaGjZcA8.js";
7
8
 
8
9
  //#region src/types/documents.d.ts
9
10
  type RegistrationType = 'BRN' | 'NRIC' | 'PASSPORT' | 'ARMY';
@@ -22,9 +23,9 @@ interface Address {
22
23
  /** City name. Max 50 chars. */
23
24
  cityName: string;
24
25
  /** State code. Refer to /codes/state-codes/. Max 50 chars. */
25
- state: string;
26
+ state: StateCode;
26
27
  /** Country code (ISO 3166-1). Refer to /codes/countries/. Max 3 chars. */
27
- country: string; // MYS
28
+ country: CountryCode; // MYS
28
29
  }
29
30
 
30
31
  /**
@@ -221,8 +222,6 @@ interface InvoiceV1_1 {
221
222
  eInvoiceDate: string; // e.g., '2017-11-26'
222
223
  /** Time of issuance (HH:mm:ssZ) in UTC. Max 9 chars. */
223
224
  eInvoiceTime: string; // e.g., '15:30:00Z'
224
- /** Issuer's digital signature. Refer to /signature/ documentation. */
225
- issuerDigitalSignature: IssuerDigitalSignature;
226
225
  /** Invoice currency code. Refer to /codes/currencies/. Max 3 chars. */
227
226
  invoiceCurrencyCode: CurrencyCode; // e.g., 'MYR'
228
227
  /** Invoice line items. */
package/dist/index.cjs CHANGED
@@ -4,7 +4,7 @@ const require_documentSubmission = require('./documentSubmission-D5TC0MPC.cjs');
4
4
  const require_documentTypeManagement = require('./documentTypeManagement-DXRLfTsW.cjs');
5
5
  const require_notificationManagement = require('./notificationManagement-C_qrFwWL.cjs');
6
6
  const require_platformLogin = require('./platformLogin-CPiPiVUh.cjs');
7
- const require_taxpayerValidation = require('./taxpayerValidation-DdeXCvPT.cjs');
7
+ const require_taxpayerValidation = require('./taxpayerValidation-CSuifcY1.cjs');
8
8
  const require_certificate = require('./certificate-CxsfE91s.cjs');
9
9
  const require_getBaseUrl = require('./getBaseUrl-D2iJdUGL.cjs');
10
10
 
@@ -141,13 +141,13 @@ var MyInvoisClient = class {
141
141
  }
142
142
  /**
143
143
  * Retrieves taxpayer information from a QR code.
144
- *
144
+ *
145
145
  * This method decodes a QR code containing taxpayer information and returns
146
146
  * detailed taxpayer data including TIN, name, contact details, and business information.
147
- *
147
+ *
148
148
  * @param qrCodeText - The QR code text to decode
149
149
  * @returns Promise resolving to taxpayer QR code response or standard error
150
- *
150
+ *
151
151
  * @example
152
152
  * ```typescript
153
153
  * // Get taxpayer info from QR code
@@ -158,7 +158,7 @@ var MyInvoisClient = class {
158
158
  * console.log('Address:', taxpayerInfo.addressLine1);
159
159
  * }
160
160
  * ```
161
- *
161
+ *
162
162
  * @remarks
163
163
  * - QR code must be in the correct format specified by MyInvois
164
164
  * - Returns StandardError if QR code is invalid or cannot be decoded
@@ -172,16 +172,16 @@ var MyInvoisClient = class {
172
172
  }
173
173
  /**
174
174
  * Performs an action on a document such as rejection or cancellation.
175
- *
175
+ *
176
176
  * This method allows updating the status of a document to either rejected or cancelled,
177
177
  * along with providing a reason for the action. Useful for managing document workflow
178
178
  * and maintaining audit trails.
179
- *
179
+ *
180
180
  * @param documentUid - The unique identifier of the document
181
181
  * @param status - The new status to set ('rejected' or 'cancelled')
182
182
  * @param reason - The reason for the status change
183
183
  * @returns Promise resolving to document action response containing UUID, status, and any errors
184
- *
184
+ *
185
185
  * @example
186
186
  * ```typescript
187
187
  * // Reject a document with reason
@@ -190,7 +190,7 @@ var MyInvoisClient = class {
190
190
  * 'rejected',
191
191
  * 'Invalid tax calculation'
192
192
  * );
193
- *
193
+ *
194
194
  * // Cancel a document
195
195
  * const result = await client.performDocumentAction(
196
196
  * 'doc-456',
@@ -198,7 +198,7 @@ var MyInvoisClient = class {
198
198
  * 'Duplicate submission'
199
199
  * );
200
200
  * ```
201
- *
201
+ *
202
202
  * @remarks
203
203
  * - Only valid for documents in appropriate states
204
204
  * - Reason is required and should be descriptive
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["clientId: string","clientSecret: string","environment: 'sandbox' | 'production'","certificatePem: string","privateKeyPem: string","onBehalfOf?: string","debug?: boolean","path: string","options: Parameters<typeof fetch>[1]","tin: string","idType: RegistrationType","idValue: string","params: TinSearchParams","qrCodeText: string","documentUid: string","status: 'rejected' | 'cancelled'","reason: string","documents: InvoiceV1_1[]","submissionUid: string","pollInterval: number","maxRetries: number","id: number","versionId: number"],"sources":["../src/index.ts"],"sourcesContent":["import {\n DocumentStatus,\n DocumentSummary,\n DocumentTypeResponse,\n DocumentTypesResponse,\n DocumentTypeVersionResponse,\n DocumentValidationResult,\n DocumentValidationStepResult,\n EInvoiceTypeCode,\n InvoiceV1_1,\n NotificationResponse,\n NotificationSearchParams,\n RegistrationType,\n SigningCredentials,\n StandardError,\n SubmissionResponse,\n SubmissionStatus,\n TaxpayerQRCodeResponse,\n TinSearchParams,\n TinSearchResponse,\n} from './types'\n\nimport * as DocumentManagementAPI from './api/documentManagement'\nimport * as DocumentSubmissionAPI from './api/documentSubmission'\nimport * as DocumentTypeManagementAPI from './api/documentTypeManagement'\nimport * as NotificationManagementAPI from './api/notificationManagement'\nimport { platformLogin } from './api/platformLogin'\nimport * as TaxpayerValidationAPI from './api/taxpayerValidation'\nimport { extractCertificateInfo, validateKeyPair } from './utils/certificate'\nimport { getBaseUrl } from './utils/getBaseUrl'\n\nexport type * from './types/index.d.ts'\nexport class MyInvoisClient {\n private readonly baseUrl: string\n private readonly clientId: string\n private readonly clientSecret: string\n private readonly onBehalfOf?: string\n private readonly signingCredentials: SigningCredentials\n private readonly debug: boolean\n private token = ''\n private tokenExpiration: Date | undefined = undefined\n\n constructor(\n clientId: string,\n clientSecret: string,\n environment: 'sandbox' | 'production',\n certificatePem: string,\n privateKeyPem: string,\n onBehalfOf?: string,\n debug?: boolean,\n ) {\n // Check if basic signing credentials are available\n if (!privateKeyPem || !certificatePem) {\n throw new Error(\n 'Missing required environment variables: PRIVATE_KEY and CERTIFICATE',\n )\n }\n\n // Validate that the key pair matches\n if (!validateKeyPair(certificatePem, privateKeyPem)) {\n throw new Error('Certificate and private key do not match')\n }\n\n this.clientId = clientId\n this.clientSecret = clientSecret\n this.baseUrl = getBaseUrl(environment)\n this.onBehalfOf = onBehalfOf\n this.debug = (debug ?? process.env.MYINVOIS_DEBUG === 'true') ? true : false\n\n // Extract certificate information\n const { issuerName, serialNumber } = extractCertificateInfo(certificatePem)\n\n this.signingCredentials = {\n privateKeyPem,\n certificatePem,\n issuerName,\n serialNumber,\n }\n }\n\n private async refreshToken() {\n const tokenResponse = await platformLogin({\n clientId: this.clientId,\n clientSecret: this.clientSecret,\n baseUrl: this.baseUrl,\n onBehalfOf: this.onBehalfOf,\n debug: this.debug,\n })\n\n this.token = tokenResponse.token\n this.tokenExpiration = tokenResponse.tokenExpiration\n }\n\n private async getToken() {\n if (\n !this.tokenExpiration ||\n this.tokenExpiration < new Date() ||\n isNaN(this.tokenExpiration.getTime())\n ) {\n if (this.debug) {\n console.log('Token expired')\n console.log('Refreshing token')\n }\n await this.refreshToken()\n }\n\n return this.token\n }\n\n private async fetch(path: string, options: Parameters<typeof fetch>[1] = {}) {\n const token = await this.getToken()\n\n return fetch(`${this.baseUrl}${path}`, {\n ...options,\n headers: { ...options.headers, Authorization: `Bearer ${token}` },\n })\n }\n\n /**\n * Validates a TIN against a NRIC/ARMY/PASSPORT/BRN (Business Registration Number)\n *\n * This method verifies if a given Tax Identification Number (TIN) is valid by checking it against\n * the provided identification type and value through the MyInvois platform's validation service.\n *\n * @param tin - The TIN to validate\n * @param idType - The type of ID to validate against ('NRIC', 'ARMY', 'PASSPORT', or 'BRN')\n * @param idValue - The value of the ID to validate against\n * @returns Promise resolving to true if the TIN is valid, false otherwise\n *\n * @example\n * ```typescript\n * // Validate TIN against NRIC\n * const isValid = await client.verifyTin('C12345678901234', 'NRIC', '123456789012');\n * if (isValid) {\n * console.log('TIN is valid');\n * }\n *\n * // Validate TIN against Business Registration Number\n * const isValidBusiness = await client.verifyTin('C98765432109876', 'BRN', '123456-K');\n * ```\n *\n * @remarks\n * - Returns false if validation fails due to network errors or invalid credentials\n * - Debug mode provides error logging for troubleshooting validation failures\n * - This is a non-blocking validation that won't throw exceptions on failure\n */\n async verifyTin(\n tin: string,\n idType: RegistrationType,\n idValue: string,\n ): Promise<boolean> {\n return TaxpayerValidationAPI.verifyTin(\n { fetch: this.fetch.bind(this), debug: this.debug },\n tin,\n idType,\n idValue,\n )\n }\n\n /**\n * Searches for a Tax Identification Number (TIN) using taxpayer information.\n *\n * This method allows searching for a TIN using either a taxpayer name or a combination\n * of identification type and value. The search is flexible and supports multiple\n * identification types including NRIC, ARMY, PASSPORT, and BRN.\n *\n * @param params - Search parameters object\n * @param params.taxpayerName - Optional name of the taxpayer to search for\n * @param params.idType - Optional type of ID to search with (NRIC, ARMY, PASSPORT, BRN)\n * @param params.idValue - Optional value of the ID to search with\n * @returns Promise resolving to TIN search response or standard error\n *\n * @example\n * ```typescript\n * // Search by taxpayer name\n * const result = await client.searchTin({ taxpayerName: 'John Doe' });\n * if ('tin' in result) {\n * console.log('Found TIN:', result.tin);\n * }\n *\n * // Search by ID type and value\n * const result = await client.searchTin({\n * idType: 'NRIC',\n * idValue: '123456789012'\n * });\n * ```\n *\n * @remarks\n * - Either taxpayerName or both idType and idValue must be provided\n * - Returns StandardError object if search criteria are invalid or inconclusive\n * - Debug mode provides detailed error logging for troubleshooting\n * - Search results are not guaranteed to be unique\n */\n async searchTin(\n params: TinSearchParams,\n ): Promise<TinSearchResponse | StandardError> {\n return TaxpayerValidationAPI.tinSearch(\n { fetch: this.fetch.bind(this), debug: this.debug },\n params,\n )\n }\n\n /**\n * Retrieves taxpayer information from a QR code.\n * \n * This method decodes a QR code containing taxpayer information and returns\n * detailed taxpayer data including TIN, name, contact details, and business information.\n * \n * @param qrCodeText - The QR code text to decode\n * @returns Promise resolving to taxpayer QR code response or standard error\n * \n * @example\n * ```typescript\n * // Get taxpayer info from QR code\n * const taxpayerInfo = await client.getTaxpayerQRCode('QR_CODE_TEXT');\n * if ('tin' in taxpayerInfo) {\n * console.log('Taxpayer TIN:', taxpayerInfo.tin);\n * console.log('Business Name:', taxpayerInfo.name);\n * console.log('Address:', taxpayerInfo.addressLine1);\n * }\n * ```\n * \n * @remarks\n * - QR code must be in the correct format specified by MyInvois\n * - Returns StandardError if QR code is invalid or cannot be decoded\n * - Debug mode provides detailed error logging\n */\n async getTaxpayerQRCode(\n qrCodeText: string,\n ): Promise<TaxpayerQRCodeResponse | StandardError> {\n return TaxpayerValidationAPI.taxpayerQRCode(\n { fetch: this.fetch.bind(this), debug: this.debug },\n qrCodeText,\n )\n }\n\n /**\n * Performs an action on a document such as rejection or cancellation.\n * \n * This method allows updating the status of a document to either rejected or cancelled,\n * along with providing a reason for the action. Useful for managing document workflow\n * and maintaining audit trails.\n * \n * @param documentUid - The unique identifier of the document\n * @param status - The new status to set ('rejected' or 'cancelled')\n * @param reason - The reason for the status change\n * @returns Promise resolving to document action response containing UUID, status, and any errors\n * \n * @example\n * ```typescript\n * // Reject a document with reason\n * const result = await client.performDocumentAction(\n * 'doc-123',\n * 'rejected',\n * 'Invalid tax calculation'\n * );\n * \n * // Cancel a document\n * const result = await client.performDocumentAction(\n * 'doc-456',\n * 'cancelled',\n * 'Duplicate submission'\n * );\n * ```\n * \n * @remarks\n * - Only valid for documents in appropriate states\n * - Reason is required and should be descriptive\n * - Action is irreversible once completed\n * - Returns error if document cannot be found or action is invalid\n */\n async performDocumentAction(\n documentUid: string,\n status: 'rejected' | 'cancelled',\n reason: string,\n ): Promise<{\n uuid: string\n status: string\n error: StandardError\n }> {\n return DocumentSubmissionAPI.performDocumentAction(\n documentUid,\n status,\n reason,\n )\n }\n\n /**\n * Submits one or more e-invoice documents to the MyInvois platform for processing.\n *\n * This method digitally signs each document using the provided certificate and private key,\n * generates document hashes, encodes them for submission, and sends them to the platform.\n * The method includes comprehensive validation warnings for document size and count limits.\n *\n * @param documents - Array of InvoiceV1_1 documents to be submitted\n * @returns Promise resolving to submission response containing the submission data and HTTP status\n * @throws {Error} If PRIVATE_KEY or CERTIFICATE environment variables are missing\n * @throws {Error} If document signing, encoding, or API submission fails\n *\n * @example\n * ```typescript\n * // Submit a single invoice\n * const result = await client.submitDocument([invoiceData]);\n * console.log(result.data.submissionUid); // Track submission with this UID\n *\n * // Submit multiple invoices\n * const result = await client.submitDocument([invoice1, invoice2, invoice3]);\n * if (result.status === 202) {\n * console.log('Documents submitted successfully');\n * }\n * ```\n *\n * @remarks\n * - Requires PRIVATE_KEY and CERTIFICATE environment variables for document signing\n * - Each document is digitally signed with XML-DSIG before submission\n * - Documents are base64-encoded for transmission\n * - API limits: Max 100 documents per submission, 5MB total payload, 300KB per document\n * - Debug mode provides detailed logging of payload sizes and validation warnings\n * - Returns HTTP 202 for successful submissions that require processing\n */\n async submitDocument(documents: InvoiceV1_1[]): Promise<{\n data: SubmissionResponse\n status: number\n }> {\n return DocumentSubmissionAPI.submitDocument(\n {\n fetch: this.fetch.bind(this),\n debug: this.debug,\n signingCredentials: this.signingCredentials,\n },\n documents,\n )\n }\n\n /**\n * Polls the MyInvois platform to get the current status of a document submission.\n *\n * This method continuously checks the submission status until it receives a final result\n * (Valid or Invalid) or reaches the maximum retry limit. It's designed to handle the\n * asynchronous nature of document processing on the MyInvois platform.\n *\n * @param submissionUid - The unique identifier of the submission to check\n * @param pollInterval - Time in milliseconds between status checks (default: 1000ms)\n * @param maxRetries - Maximum number of retry attempts (default: 10)\n * @returns Promise resolving to submission status object with document summary and any errors\n *\n * @example\n * ```typescript\n * // Check submission status with default polling\n * const result = await client.getSubmissionStatus('submission-uid-123');\n * if (result.status === 'Valid') {\n * console.log('All documents processed successfully');\n * console.log('Document summaries:', result.documentSummary);\n * }\n *\n * // Custom polling interval and retry count\n * const result = await client.getSubmissionStatus(\n * 'submission-uid-123',\n * 2000, // Poll every 2 seconds\n * 20 // Try up to 20 times\n * );\n * ```\n *\n * @remarks\n * - Automatically retries on network errors until maxRetries is reached\n * - Returns 'Invalid' status with timeout error if submission processing takes too long\n * - Debug mode provides detailed logging of polling attempts and responses\n * - Use reasonable poll intervals to avoid overwhelming the API\n */\n async getSubmissionStatus(\n submissionUid: string,\n pollInterval: number = 1000,\n maxRetries: number = 10,\n ): Promise<{\n status: SubmissionStatus\n documentSummary?: DocumentSummary[]\n error?: {\n code: string\n message: string | null\n target: string\n details: {\n code: string\n message: string\n target: string\n }[]\n }\n }> {\n return DocumentSubmissionAPI.getSubmissionStatus(\n { fetch: this.fetch.bind(this), debug: this.debug },\n submissionUid,\n pollInterval,\n maxRetries,\n )\n }\n\n /**\n * Retrieves a document by its unique identifier with the raw document content.\n *\n * @param documentUid - The unique identifier of the document to retrieve\n * @returns Promise resolving to document summary with raw document content as a string\n * @throws {Error} If the document is not found or request fails\n *\n * @example\n * ```typescript\n * const document = await client.getDocument('doc-uuid-123');\n * console.log(document.document); // Raw XML/JSON content\n * console.log(document.uuid); // Document UUID\n * ```\n */\n async getDocument(\n documentUid: string,\n ): Promise<DocumentSummary & { document: string }> {\n return DocumentManagementAPI.getDocument(\n { fetch: this.fetch.bind(this) },\n documentUid,\n )\n }\n\n /**\n * Retrieves detailed information about a document including validation results.\n *\n * @param documentUid - The unique identifier of the document to get details for\n * @returns Promise resolving to document summary with detailed validation results\n * @throws {Error} If the document is not found or request fails\n *\n * @example\n * ```typescript\n * const details = await client.getDocumentDetails('doc-uuid-123');\n * console.log(details.validationResults.status); // 'Valid' | 'Invalid' | 'Processing'\n * console.log(details.validationResults.validationSteps); // Array of validation step results\n * ```\n */\n async getDocumentDetails(documentUid: string): Promise<\n DocumentSummary & {\n validationResults: {\n status: DocumentValidationResult\n validationSteps: DocumentValidationStepResult[]\n }\n }\n > {\n return DocumentManagementAPI.getDocumentDetails(\n { fetch: this.fetch.bind(this) },\n documentUid,\n )\n }\n\n /**\n * Searches for documents based on various filter criteria.\n *\n * @param params - Search parameters object\n * @param params.uuid - Optional specific document UUID to search for\n * @param params.submissionDateFrom - Required start date for submission date range (ISO date string)\n * @param params.submissionDateTo - Optional end date for submission date range (ISO date string)\n * @param params.pageSize - Optional number of results per page (default handled by API)\n * @param params.pageNo - Optional page number for pagination (0-based)\n * @param params.issueDateFrom - Optional start date for issue date range (ISO date string)\n * @param params.issueDateTo - Optional end date for issue date range (ISO date string)\n * @param params.invoiceDirection - Optional filter by invoice direction ('Sent' or 'Received')\n * @param params.status - Optional filter by document status\n * @param params.documentType - Optional filter by e-invoice type code\n * @param params.searchQuery - Optional text search across uuid, buyerTIN, supplierTIN, buyerName, supplierName, internalID, total\n * @returns Promise resolving to array of document summaries matching the search criteria\n * @throws {Error} If the search request fails\n *\n * @example\n * ```typescript\n * // Search for documents submitted in the last 30 days\n * const documents = await client.searchDocuments({\n * submissionDateFrom: '2024-01-01',\n * submissionDateTo: '2024-01-31',\n * status: 'Valid',\n * pageSize: 10\n * });\n *\n * // Search by supplier name\n * const supplierDocs = await client.searchDocuments({\n * submissionDateFrom: '2024-01-01',\n * searchQuery: 'ACME Corp',\n * invoiceDirection: 'Received'\n * });\n * ```\n */\n async searchDocuments({\n uuid,\n submissionDateFrom,\n submissionDateTo,\n pageSize,\n pageNo,\n issueDateFrom,\n issueDateTo,\n invoiceDirection,\n status,\n documentType,\n searchQuery,\n }: {\n uuid?: string\n submissionDateFrom: string\n submissionDateTo?: string\n pageSize?: number\n pageNo?: number\n issueDateFrom?: string\n issueDateTo?: string\n invoiceDirection?: 'Sent' | 'Received'\n status?: DocumentStatus\n documentType?: EInvoiceTypeCode\n searchQuery?: string // Search by uuid, buyerTIN, supplierTIN, buyerName, supplierName, internalID, total\n }): Promise<DocumentSummary[]> {\n return DocumentManagementAPI.searchDocuments(\n { fetch: this.fetch.bind(this) },\n {\n uuid,\n submissionDateFrom,\n submissionDateTo,\n pageSize,\n pageNo,\n issueDateFrom,\n issueDateTo,\n invoiceDirection,\n status,\n documentType,\n searchQuery,\n },\n )\n }\n\n /**\n * Retrieves notifications from the MyInvois platform based on specified search criteria.\n *\n * This method allows you to search for system notifications, alerts, and messages\n * sent by the MyInvois platform regarding document processing, system updates,\n * or account-related information.\n *\n * @param params - Search parameters object for filtering notifications\n * @param params.dateFrom - Optional start date for notification date range (ISO date string)\n * @param params.dateTo - Optional end date for notification date range (ISO date string)\n * @param params.type - Optional notification type filter\n * @param params.language - Optional language preference for notifications\n * @param params.status - Optional notification status filter\n * @param params.pageNo - Optional page number for pagination (0-based)\n * @param params.pageSize - Optional number of results per page\n * @returns Promise resolving to notification response object or standard error\n *\n * @example\n * ```typescript\n * // Get all notifications from the last 7 days\n * const notifications = await client.getNotifications({\n * dateFrom: '2024-01-01',\n * dateTo: '2024-01-07',\n * pageSize: 20\n * });\n *\n * // Get unread notifications only\n * const unreadNotifications = await client.getNotifications({\n * status: 0, // Assuming 0 = unread\n * language: 'en'\n * });\n *\n * // Paginated notification retrieval\n * const firstPage = await client.getNotifications({\n * dateFrom: '2024-01-01',\n * pageNo: 0,\n * pageSize: 10\n * });\n * ```\n *\n * @remarks\n * - All parameters are optional, allowing flexible filtering\n * - Returns paginated results when pageNo and pageSize are specified\n * - Date parameters should be in ISO format (YYYY-MM-DD)\n * - May return StandardError object if the request fails\n */\n async getNotifications({\n dateFrom,\n dateTo,\n type,\n language,\n status,\n pageNo,\n pageSize,\n }: NotificationSearchParams): Promise<NotificationResponse | StandardError> {\n return NotificationManagementAPI.getNotifications(\n { fetch: this.fetch.bind(this) },\n {\n dateFrom,\n dateTo,\n type,\n language,\n status,\n pageNo,\n pageSize,\n },\n )\n }\n\n async getDocumentTypes(): Promise<DocumentTypesResponse | StandardError> {\n return DocumentTypeManagementAPI.getDocumentTypes({\n fetch: this.fetch.bind(this),\n })\n }\n\n /**\n * Retrieves detailed information about a specific document type from the MyInvois platform.\n *\n * This method fetches metadata and configuration details for a specific document type,\n * including supported versions, validation rules, and structural requirements.\n * Useful for understanding document format requirements before submission.\n *\n * @param id - The unique identifier of the document type to retrieve\n * @returns Promise resolving to document type response object or standard error\n *\n * @example\n * ```typescript\n * // Get details for e-invoice document type\n * const invoiceType = await client.getDocumentType(1);\n * if ('id' in invoiceType) {\n * console.log('Document type name:', invoiceType.name);\n * console.log('Available versions:', invoiceType.versionNumber);\n * console.log('Description:', invoiceType.description);\n * }\n *\n * // Handle potential errors\n * const documentType = await client.getDocumentType(999);\n * if ('error' in documentType) {\n * console.error('Failed to retrieve document type:', documentType.error.message);\n * }\n * ```\n *\n * @remarks\n * - Returns StandardError object if the document type ID doesn't exist\n * - Document type information includes validation schemas and business rules\n * - Use this method to discover supported document formats and versions\n * - Essential for understanding submission requirements for different document types\n */\n async getDocumentType(\n id: number,\n ): Promise<DocumentTypeResponse | StandardError> {\n return DocumentTypeManagementAPI.getDocumentType(\n { fetch: this.fetch.bind(this) },\n id,\n )\n }\n\n /**\n * Retrieves detailed information about a specific version of a document type.\n *\n * This method fetches version-specific metadata, schema definitions, and validation rules\n * for a particular document type version. Essential for understanding the exact format\n * and requirements for document submission in a specific version.\n *\n * @param id - The unique identifier of the document type\n * @param versionId - The unique identifier of the specific version to retrieve\n * @returns Promise resolving to document type version response object or standard error\n *\n * @example\n * ```typescript\n * // Get specific version details for e-invoice\n * const invoiceV1_1 = await client.getDocumentTypeVersion(1, 1);\n * if ('id' in invoiceV1_1) {\n * console.log('Version number:', invoiceV1_1.versionNumber);\n * console.log('Schema:', invoiceV1_1.jsonSchema);\n * console.log('Status:', invoiceV1_1.status);\n * }\n *\n * // Compare different versions\n * const [v1_0, v1_1] = await Promise.all([\n * client.getDocumentTypeVersion(1, 0),\n * client.getDocumentTypeVersion(1, 1)\n * ]);\n *\n * // Handle version not found\n * const result = await client.getDocumentTypeVersion(1, 999);\n * if ('error' in result) {\n * console.error('Version not found:', result.error.message);\n * }\n * ```\n *\n * @remarks\n * - Returns StandardError object if document type ID or version ID doesn't exist\n * - Version information includes JSON schema for validation\n * - Different versions may have different validation rules and field requirements\n * - Use this to ensure your documents conform to the specific version requirements\n * - Version status indicates if the version is active, deprecated, or under development\n */\n async getDocumentTypeVersion(\n id: number,\n versionId: number,\n ): Promise<DocumentTypeVersionResponse | StandardError> {\n return DocumentTypeManagementAPI.getDocumentTypeVersion(\n { fetch: this.fetch.bind(this) },\n id,\n versionId,\n )\n }\n}\n"],"mappings":";;;;;;;;;;;AAgCA,IAAa,iBAAb,MAA4B;CAC1B,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAQ,QAAQ;CAChB,AAAQ;CAER,YACEA,UACAC,cACAC,aACAC,gBACAC,eACAC,YACAC,OACA;AAEA,OAAK,kBAAkB,eACrB,OAAM,IAAI,MACR;AAKJ,OAAK,oCAAgB,gBAAgB,cAAc,CACjD,OAAM,IAAI,MAAM;AAGlB,OAAK,WAAW;AAChB,OAAK,eAAe;AACpB,OAAK,UAAU,8BAAW,YAAY;AACtC,OAAK,aAAa;AAClB,OAAK,QAAS,SAAS,QAAQ,IAAI,mBAAmB,SAAU,OAAO;EAGvE,MAAM,EAAE,YAAY,cAAc,GAAG,2CAAuB,eAAe;AAE3E,OAAK,qBAAqB;GACxB;GACA;GACA;GACA;EACD;CACF;CAED,MAAc,eAAe;EAC3B,MAAM,gBAAgB,MAAM,oCAAc;GACxC,UAAU,KAAK;GACf,cAAc,KAAK;GACnB,SAAS,KAAK;GACd,YAAY,KAAK;GACjB,OAAO,KAAK;EACb,EAAC;AAEF,OAAK,QAAQ,cAAc;AAC3B,OAAK,kBAAkB,cAAc;CACtC;CAED,MAAc,WAAW;AACvB,OACG,KAAK,mBACN,KAAK,kCAAkB,IAAI,UAC3B,MAAM,KAAK,gBAAgB,SAAS,CAAC,EACrC;AACA,OAAI,KAAK,OAAO;AACd,YAAQ,IAAI,gBAAgB;AAC5B,YAAQ,IAAI,mBAAmB;GAChC;AACD,SAAM,KAAK,cAAc;EAC1B;AAED,SAAO,KAAK;CACb;CAED,MAAc,MAAMC,MAAcC,UAAuC,CAAE,GAAE;EAC3E,MAAM,QAAQ,MAAM,KAAK,UAAU;AAEnC,SAAO,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,GAAG;GACrC,GAAG;GACH,SAAS;IAAE,GAAG,QAAQ;IAAS,gBAAgB,SAAS,MAAM;GAAG;EAClE,EAAC;CACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8BD,MAAM,UACJC,KACAC,QACAC,SACkB;AAClB,SAAO,qCACL;GAAE,OAAO,KAAK,MAAM,KAAK,KAAK;GAAE,OAAO,KAAK;EAAO,GACnD,KACA,QACA,QACD;CACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoCD,MAAM,UACJC,QAC4C;AAC5C,SAAO,qCACL;GAAE,OAAO,KAAK,MAAM,KAAK,KAAK;GAAE,OAAO,KAAK;EAAO,GACnD,OACD;CACF;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BD,MAAM,kBACJC,YACiD;AACjD,SAAO,0CACL;GAAE,OAAO,KAAK,MAAM,KAAK,KAAK;GAAE,OAAO,KAAK;EAAO,GACnD,WACD;CACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqCD,MAAM,sBACJC,aACAC,QACAC,QAKC;AACD,SAAO,iDACL,aACA,QACA,OACD;CACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmCD,MAAM,eAAeC,WAGlB;AACD,SAAO,0CACL;GACE,OAAO,KAAK,MAAM,KAAK,KAAK;GAC5B,OAAO,KAAK;GACZ,oBAAoB,KAAK;EAC1B,GACD,UACD;CACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqCD,MAAM,oBACJC,eACAC,eAAuB,KACvBC,aAAqB,IAcpB;AACD,SAAO,+CACL;GAAE,OAAO,KAAK,MAAM,KAAK,KAAK;GAAE,OAAO,KAAK;EAAO,GACnD,eACA,cACA,WACD;CACF;;;;;;;;;;;;;;;CAgBD,MAAM,YACJN,aACiD;AACjD,SAAO,uCACL,EAAE,OAAO,KAAK,MAAM,KAAK,KAAK,CAAE,GAChC,YACD;CACF;;;;;;;;;;;;;;;CAgBD,MAAM,mBAAmBA,aAOvB;AACA,SAAO,8CACL,EAAE,OAAO,KAAK,MAAM,KAAK,KAAK,CAAE,GAChC,YACD;CACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsCD,MAAM,gBAAgB,EACpB,MACA,oBACA,kBACA,UACA,QACA,eACA,aACA,kBACA,QACA,cACA,aAaD,EAA8B;AAC7B,SAAO,2CACL,EAAE,OAAO,KAAK,MAAM,KAAK,KAAK,CAAE,GAChC;GACE;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACD,EACF;CACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgDD,MAAM,iBAAiB,EACrB,UACA,QACA,MACA,UACA,QACA,QACA,UACyB,EAAiD;AAC1E,SAAO,gDACL,EAAE,OAAO,KAAK,MAAM,KAAK,KAAK,CAAE,GAChC;GACE;GACA;GACA;GACA;GACA;GACA;GACA;EACD,EACF;CACF;CAED,MAAM,mBAAmE;AACvE,SAAO,gDAA2C,EAChD,OAAO,KAAK,MAAM,KAAK,KAAK,CAC7B,EAAC;CACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmCD,MAAM,gBACJO,IAC+C;AAC/C,SAAO,+CACL,EAAE,OAAO,KAAK,MAAM,KAAK,KAAK,CAAE,GAChC,GACD;CACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2CD,MAAM,uBACJA,IACAC,WACsD;AACtD,SAAO,sDACL,EAAE,OAAO,KAAK,MAAM,KAAK,KAAK,CAAE,GAChC,IACA,UACD;CACF;AACF"}
1
+ {"version":3,"file":"index.cjs","names":["clientId: string","clientSecret: string","environment: 'sandbox' | 'production'","certificatePem: string","privateKeyPem: string","onBehalfOf?: string","debug?: boolean","path: string","options: Parameters<typeof fetch>[1]","tin: string","idType: RegistrationType","idValue: string","params: TinSearchParams","qrCodeText: string","documentUid: string","status: 'rejected' | 'cancelled'","reason: string","documents: InvoiceV1_1[]","submissionUid: string","pollInterval: number","maxRetries: number","id: number","versionId: number"],"sources":["../src/index.ts"],"sourcesContent":["import {\n DocumentStatus,\n DocumentSummary,\n DocumentTypeResponse,\n DocumentTypesResponse,\n DocumentTypeVersionResponse,\n DocumentValidationResult,\n DocumentValidationStepResult,\n EInvoiceTypeCode,\n InvoiceV1_1,\n NotificationResponse,\n NotificationSearchParams,\n RegistrationType,\n SigningCredentials,\n StandardError,\n SubmissionResponse,\n SubmissionStatus,\n TaxpayerQRCodeResponse,\n TinSearchParams,\n TinSearchResponse,\n} from './types'\n\nimport * as DocumentManagementAPI from './api/documentManagement'\nimport * as DocumentSubmissionAPI from './api/documentSubmission'\nimport * as DocumentTypeManagementAPI from './api/documentTypeManagement'\nimport * as NotificationManagementAPI from './api/notificationManagement'\nimport { platformLogin } from './api/platformLogin'\nimport * as TaxpayerValidationAPI from './api/taxpayerValidation'\nimport { extractCertificateInfo, validateKeyPair } from './utils/certificate'\nimport { getBaseUrl } from './utils/getBaseUrl'\n\nexport type * from './types/index.d.ts'\nexport class MyInvoisClient {\n private readonly baseUrl: string\n private readonly clientId: string\n private readonly clientSecret: string\n private readonly onBehalfOf?: string\n private readonly signingCredentials: SigningCredentials\n private readonly debug: boolean\n private token = ''\n private tokenExpiration: Date | undefined = undefined\n\n constructor(\n clientId: string,\n clientSecret: string,\n environment: 'sandbox' | 'production',\n certificatePem: string,\n privateKeyPem: string,\n onBehalfOf?: string,\n debug?: boolean,\n ) {\n // Check if basic signing credentials are available\n if (!privateKeyPem || !certificatePem) {\n throw new Error(\n 'Missing required environment variables: PRIVATE_KEY and CERTIFICATE',\n )\n }\n\n // Validate that the key pair matches\n if (!validateKeyPair(certificatePem, privateKeyPem)) {\n throw new Error('Certificate and private key do not match')\n }\n\n this.clientId = clientId\n this.clientSecret = clientSecret\n this.baseUrl = getBaseUrl(environment)\n this.onBehalfOf = onBehalfOf\n this.debug = (debug ?? process.env.MYINVOIS_DEBUG === 'true') ? true : false\n\n // Extract certificate information\n const { issuerName, serialNumber } = extractCertificateInfo(certificatePem)\n\n this.signingCredentials = {\n privateKeyPem,\n certificatePem,\n issuerName,\n serialNumber,\n }\n }\n\n private async refreshToken() {\n const tokenResponse = await platformLogin({\n clientId: this.clientId,\n clientSecret: this.clientSecret,\n baseUrl: this.baseUrl,\n onBehalfOf: this.onBehalfOf,\n debug: this.debug,\n })\n\n this.token = tokenResponse.token\n this.tokenExpiration = tokenResponse.tokenExpiration\n }\n\n private async getToken() {\n if (\n !this.tokenExpiration ||\n this.tokenExpiration < new Date() ||\n isNaN(this.tokenExpiration.getTime())\n ) {\n if (this.debug) {\n console.log('Token expired')\n console.log('Refreshing token')\n }\n await this.refreshToken()\n }\n\n return this.token\n }\n\n private async fetch(path: string, options: Parameters<typeof fetch>[1] = {}) {\n const token = await this.getToken()\n\n return fetch(`${this.baseUrl}${path}`, {\n ...options,\n headers: { ...options.headers, Authorization: `Bearer ${token}` },\n })\n }\n\n /**\n * Validates a TIN against a NRIC/ARMY/PASSPORT/BRN (Business Registration Number)\n *\n * This method verifies if a given Tax Identification Number (TIN) is valid by checking it against\n * the provided identification type and value through the MyInvois platform's validation service.\n *\n * @param tin - The TIN to validate\n * @param idType - The type of ID to validate against ('NRIC', 'ARMY', 'PASSPORT', or 'BRN')\n * @param idValue - The value of the ID to validate against\n * @returns Promise resolving to true if the TIN is valid, false otherwise\n *\n * @example\n * ```typescript\n * // Validate TIN against NRIC\n * const isValid = await client.verifyTin('C12345678901234', 'NRIC', '123456789012');\n * if (isValid) {\n * console.log('TIN is valid');\n * }\n *\n * // Validate TIN against Business Registration Number\n * const isValidBusiness = await client.verifyTin('C98765432109876', 'BRN', '123456-K');\n * ```\n *\n * @remarks\n * - Returns false if validation fails due to network errors or invalid credentials\n * - Debug mode provides error logging for troubleshooting validation failures\n * - This is a non-blocking validation that won't throw exceptions on failure\n */\n async verifyTin(\n tin: string,\n idType: RegistrationType,\n idValue: string,\n ): Promise<boolean> {\n return TaxpayerValidationAPI.verifyTin(\n { fetch: this.fetch.bind(this), debug: this.debug },\n tin,\n idType,\n idValue,\n )\n }\n\n /**\n * Searches for a Tax Identification Number (TIN) using taxpayer information.\n *\n * This method allows searching for a TIN using either a taxpayer name or a combination\n * of identification type and value. The search is flexible and supports multiple\n * identification types including NRIC, ARMY, PASSPORT, and BRN.\n *\n * @param params - Search parameters object\n * @param params.taxpayerName - Optional name of the taxpayer to search for\n * @param params.idType - Optional type of ID to search with (NRIC, ARMY, PASSPORT, BRN)\n * @param params.idValue - Optional value of the ID to search with\n * @returns Promise resolving to TIN search response or standard error\n *\n * @example\n * ```typescript\n * // Search by taxpayer name\n * const result = await client.searchTin({ taxpayerName: 'John Doe' });\n * if ('tin' in result) {\n * console.log('Found TIN:', result.tin);\n * }\n *\n * // Search by ID type and value\n * const result = await client.searchTin({\n * idType: 'NRIC',\n * idValue: '123456789012'\n * });\n * ```\n *\n * @remarks\n * - Either taxpayerName or both idType and idValue must be provided\n * - Returns StandardError object if search criteria are invalid or inconclusive\n * - Debug mode provides detailed error logging for troubleshooting\n * - Search results are not guaranteed to be unique\n */\n async searchTin(params: TinSearchParams): Promise<TinSearchResponse> {\n return TaxpayerValidationAPI.tinSearch(\n { fetch: this.fetch.bind(this), debug: this.debug },\n params,\n )\n }\n\n /**\n * Retrieves taxpayer information from a QR code.\n *\n * This method decodes a QR code containing taxpayer information and returns\n * detailed taxpayer data including TIN, name, contact details, and business information.\n *\n * @param qrCodeText - The QR code text to decode\n * @returns Promise resolving to taxpayer QR code response or standard error\n *\n * @example\n * ```typescript\n * // Get taxpayer info from QR code\n * const taxpayerInfo = await client.getTaxpayerQRCode('QR_CODE_TEXT');\n * if ('tin' in taxpayerInfo) {\n * console.log('Taxpayer TIN:', taxpayerInfo.tin);\n * console.log('Business Name:', taxpayerInfo.name);\n * console.log('Address:', taxpayerInfo.addressLine1);\n * }\n * ```\n *\n * @remarks\n * - QR code must be in the correct format specified by MyInvois\n * - Returns StandardError if QR code is invalid or cannot be decoded\n * - Debug mode provides detailed error logging\n */\n async getTaxpayerQRCode(qrCodeText: string): Promise<TaxpayerQRCodeResponse> {\n return TaxpayerValidationAPI.taxpayerQRCode(\n { fetch: this.fetch.bind(this), debug: this.debug },\n qrCodeText,\n )\n }\n\n /**\n * Performs an action on a document such as rejection or cancellation.\n *\n * This method allows updating the status of a document to either rejected or cancelled,\n * along with providing a reason for the action. Useful for managing document workflow\n * and maintaining audit trails.\n *\n * @param documentUid - The unique identifier of the document\n * @param status - The new status to set ('rejected' or 'cancelled')\n * @param reason - The reason for the status change\n * @returns Promise resolving to document action response containing UUID, status, and any errors\n *\n * @example\n * ```typescript\n * // Reject a document with reason\n * const result = await client.performDocumentAction(\n * 'doc-123',\n * 'rejected',\n * 'Invalid tax calculation'\n * );\n *\n * // Cancel a document\n * const result = await client.performDocumentAction(\n * 'doc-456',\n * 'cancelled',\n * 'Duplicate submission'\n * );\n * ```\n *\n * @remarks\n * - Only valid for documents in appropriate states\n * - Reason is required and should be descriptive\n * - Action is irreversible once completed\n * - Returns error if document cannot be found or action is invalid\n */\n async performDocumentAction(\n documentUid: string,\n status: 'rejected' | 'cancelled',\n reason: string,\n ): Promise<{\n uuid: string\n status: string\n error: StandardError\n }> {\n return DocumentSubmissionAPI.performDocumentAction(\n documentUid,\n status,\n reason,\n )\n }\n\n /**\n * Submits one or more e-invoice documents to the MyInvois platform for processing.\n *\n * This method digitally signs each document using the provided certificate and private key,\n * generates document hashes, encodes them for submission, and sends them to the platform.\n * The method includes comprehensive validation warnings for document size and count limits.\n *\n * @param documents - Array of InvoiceV1_1 documents to be submitted\n * @returns Promise resolving to submission response containing the submission data and HTTP status\n * @throws {Error} If PRIVATE_KEY or CERTIFICATE environment variables are missing\n * @throws {Error} If document signing, encoding, or API submission fails\n *\n * @example\n * ```typescript\n * // Submit a single invoice\n * const result = await client.submitDocument([invoiceData]);\n * console.log(result.data.submissionUid); // Track submission with this UID\n *\n * // Submit multiple invoices\n * const result = await client.submitDocument([invoice1, invoice2, invoice3]);\n * if (result.status === 202) {\n * console.log('Documents submitted successfully');\n * }\n * ```\n *\n * @remarks\n * - Requires PRIVATE_KEY and CERTIFICATE environment variables for document signing\n * - Each document is digitally signed with XML-DSIG before submission\n * - Documents are base64-encoded for transmission\n * - API limits: Max 100 documents per submission, 5MB total payload, 300KB per document\n * - Debug mode provides detailed logging of payload sizes and validation warnings\n * - Returns HTTP 202 for successful submissions that require processing\n */\n async submitDocument(documents: InvoiceV1_1[]): Promise<{\n data: SubmissionResponse\n status: number\n }> {\n return DocumentSubmissionAPI.submitDocument(\n {\n fetch: this.fetch.bind(this),\n debug: this.debug,\n signingCredentials: this.signingCredentials,\n },\n documents,\n )\n }\n\n /**\n * Polls the MyInvois platform to get the current status of a document submission.\n *\n * This method continuously checks the submission status until it receives a final result\n * (Valid or Invalid) or reaches the maximum retry limit. It's designed to handle the\n * asynchronous nature of document processing on the MyInvois platform.\n *\n * @param submissionUid - The unique identifier of the submission to check\n * @param pollInterval - Time in milliseconds between status checks (default: 1000ms)\n * @param maxRetries - Maximum number of retry attempts (default: 10)\n * @returns Promise resolving to submission status object with document summary and any errors\n *\n * @example\n * ```typescript\n * // Check submission status with default polling\n * const result = await client.getSubmissionStatus('submission-uid-123');\n * if (result.status === 'Valid') {\n * console.log('All documents processed successfully');\n * console.log('Document summaries:', result.documentSummary);\n * }\n *\n * // Custom polling interval and retry count\n * const result = await client.getSubmissionStatus(\n * 'submission-uid-123',\n * 2000, // Poll every 2 seconds\n * 20 // Try up to 20 times\n * );\n * ```\n *\n * @remarks\n * - Automatically retries on network errors until maxRetries is reached\n * - Returns 'Invalid' status with timeout error if submission processing takes too long\n * - Debug mode provides detailed logging of polling attempts and responses\n * - Use reasonable poll intervals to avoid overwhelming the API\n */\n async getSubmissionStatus(\n submissionUid: string,\n pollInterval: number = 1000,\n maxRetries: number = 10,\n ): Promise<{\n status: SubmissionStatus\n documentSummary?: DocumentSummary[]\n error?: {\n code: string\n message: string | null\n target: string\n details: {\n code: string\n message: string\n target: string\n }[]\n }\n }> {\n return DocumentSubmissionAPI.getSubmissionStatus(\n { fetch: this.fetch.bind(this), debug: this.debug },\n submissionUid,\n pollInterval,\n maxRetries,\n )\n }\n\n /**\n * Retrieves a document by its unique identifier with the raw document content.\n *\n * @param documentUid - The unique identifier of the document to retrieve\n * @returns Promise resolving to document summary with raw document content as a string\n * @throws {Error} If the document is not found or request fails\n *\n * @example\n * ```typescript\n * const document = await client.getDocument('doc-uuid-123');\n * console.log(document.document); // Raw XML/JSON content\n * console.log(document.uuid); // Document UUID\n * ```\n */\n async getDocument(\n documentUid: string,\n ): Promise<DocumentSummary & { document: string }> {\n return DocumentManagementAPI.getDocument(\n { fetch: this.fetch.bind(this) },\n documentUid,\n )\n }\n\n /**\n * Retrieves detailed information about a document including validation results.\n *\n * @param documentUid - The unique identifier of the document to get details for\n * @returns Promise resolving to document summary with detailed validation results\n * @throws {Error} If the document is not found or request fails\n *\n * @example\n * ```typescript\n * const details = await client.getDocumentDetails('doc-uuid-123');\n * console.log(details.validationResults.status); // 'Valid' | 'Invalid' | 'Processing'\n * console.log(details.validationResults.validationSteps); // Array of validation step results\n * ```\n */\n async getDocumentDetails(documentUid: string): Promise<\n DocumentSummary & {\n validationResults: {\n status: DocumentValidationResult\n validationSteps: DocumentValidationStepResult[]\n }\n }\n > {\n return DocumentManagementAPI.getDocumentDetails(\n { fetch: this.fetch.bind(this) },\n documentUid,\n )\n }\n\n /**\n * Searches for documents based on various filter criteria.\n *\n * @param params - Search parameters object\n * @param params.uuid - Optional specific document UUID to search for\n * @param params.submissionDateFrom - Required start date for submission date range (ISO date string)\n * @param params.submissionDateTo - Optional end date for submission date range (ISO date string)\n * @param params.pageSize - Optional number of results per page (default handled by API)\n * @param params.pageNo - Optional page number for pagination (0-based)\n * @param params.issueDateFrom - Optional start date for issue date range (ISO date string)\n * @param params.issueDateTo - Optional end date for issue date range (ISO date string)\n * @param params.invoiceDirection - Optional filter by invoice direction ('Sent' or 'Received')\n * @param params.status - Optional filter by document status\n * @param params.documentType - Optional filter by e-invoice type code\n * @param params.searchQuery - Optional text search across uuid, buyerTIN, supplierTIN, buyerName, supplierName, internalID, total\n * @returns Promise resolving to array of document summaries matching the search criteria\n * @throws {Error} If the search request fails\n *\n * @example\n * ```typescript\n * // Search for documents submitted in the last 30 days\n * const documents = await client.searchDocuments({\n * submissionDateFrom: '2024-01-01',\n * submissionDateTo: '2024-01-31',\n * status: 'Valid',\n * pageSize: 10\n * });\n *\n * // Search by supplier name\n * const supplierDocs = await client.searchDocuments({\n * submissionDateFrom: '2024-01-01',\n * searchQuery: 'ACME Corp',\n * invoiceDirection: 'Received'\n * });\n * ```\n */\n async searchDocuments({\n uuid,\n submissionDateFrom,\n submissionDateTo,\n pageSize,\n pageNo,\n issueDateFrom,\n issueDateTo,\n invoiceDirection,\n status,\n documentType,\n searchQuery,\n }: {\n uuid?: string\n submissionDateFrom: string\n submissionDateTo?: string\n pageSize?: number\n pageNo?: number\n issueDateFrom?: string\n issueDateTo?: string\n invoiceDirection?: 'Sent' | 'Received'\n status?: DocumentStatus\n documentType?: EInvoiceTypeCode\n searchQuery?: string // Search by uuid, buyerTIN, supplierTIN, buyerName, supplierName, internalID, total\n }): Promise<DocumentSummary[]> {\n return DocumentManagementAPI.searchDocuments(\n { fetch: this.fetch.bind(this) },\n {\n uuid,\n submissionDateFrom,\n submissionDateTo,\n pageSize,\n pageNo,\n issueDateFrom,\n issueDateTo,\n invoiceDirection,\n status,\n documentType,\n searchQuery,\n },\n )\n }\n\n /**\n * Retrieves notifications from the MyInvois platform based on specified search criteria.\n *\n * This method allows you to search for system notifications, alerts, and messages\n * sent by the MyInvois platform regarding document processing, system updates,\n * or account-related information.\n *\n * @param params - Search parameters object for filtering notifications\n * @param params.dateFrom - Optional start date for notification date range (ISO date string)\n * @param params.dateTo - Optional end date for notification date range (ISO date string)\n * @param params.type - Optional notification type filter\n * @param params.language - Optional language preference for notifications\n * @param params.status - Optional notification status filter\n * @param params.pageNo - Optional page number for pagination (0-based)\n * @param params.pageSize - Optional number of results per page\n * @returns Promise resolving to notification response object or standard error\n *\n * @example\n * ```typescript\n * // Get all notifications from the last 7 days\n * const notifications = await client.getNotifications({\n * dateFrom: '2024-01-01',\n * dateTo: '2024-01-07',\n * pageSize: 20\n * });\n *\n * // Get unread notifications only\n * const unreadNotifications = await client.getNotifications({\n * status: 0, // Assuming 0 = unread\n * language: 'en'\n * });\n *\n * // Paginated notification retrieval\n * const firstPage = await client.getNotifications({\n * dateFrom: '2024-01-01',\n * pageNo: 0,\n * pageSize: 10\n * });\n * ```\n *\n * @remarks\n * - All parameters are optional, allowing flexible filtering\n * - Returns paginated results when pageNo and pageSize are specified\n * - Date parameters should be in ISO format (YYYY-MM-DD)\n * - May return StandardError object if the request fails\n */\n async getNotifications({\n dateFrom,\n dateTo,\n type,\n language,\n status,\n pageNo,\n pageSize,\n }: NotificationSearchParams): Promise<NotificationResponse> {\n return NotificationManagementAPI.getNotifications(\n { fetch: this.fetch.bind(this) },\n {\n dateFrom,\n dateTo,\n type,\n language,\n status,\n pageNo,\n pageSize,\n },\n )\n }\n\n async getDocumentTypes(): Promise<DocumentTypesResponse> {\n return DocumentTypeManagementAPI.getDocumentTypes({\n fetch: this.fetch.bind(this),\n })\n }\n\n /**\n * Retrieves detailed information about a specific document type from the MyInvois platform.\n *\n * This method fetches metadata and configuration details for a specific document type,\n * including supported versions, validation rules, and structural requirements.\n * Useful for understanding document format requirements before submission.\n *\n * @param id - The unique identifier of the document type to retrieve\n * @returns Promise resolving to document type response object or standard error\n *\n * @example\n * ```typescript\n * // Get details for e-invoice document type\n * const invoiceType = await client.getDocumentType(1);\n * if ('id' in invoiceType) {\n * console.log('Document type name:', invoiceType.name);\n * console.log('Available versions:', invoiceType.versionNumber);\n * console.log('Description:', invoiceType.description);\n * }\n *\n * // Handle potential errors\n * const documentType = await client.getDocumentType(999);\n * if ('error' in documentType) {\n * console.error('Failed to retrieve document type:', documentType.error.message);\n * }\n * ```\n *\n * @remarks\n * - Returns StandardError object if the document type ID doesn't exist\n * - Document type information includes validation schemas and business rules\n * - Use this method to discover supported document formats and versions\n * - Essential for understanding submission requirements for different document types\n */\n async getDocumentType(id: number): Promise<DocumentTypeResponse> {\n return DocumentTypeManagementAPI.getDocumentType(\n { fetch: this.fetch.bind(this) },\n id,\n )\n }\n\n /**\n * Retrieves detailed information about a specific version of a document type.\n *\n * This method fetches version-specific metadata, schema definitions, and validation rules\n * for a particular document type version. Essential for understanding the exact format\n * and requirements for document submission in a specific version.\n *\n * @param id - The unique identifier of the document type\n * @param versionId - The unique identifier of the specific version to retrieve\n * @returns Promise resolving to document type version response object or standard error\n *\n * @example\n * ```typescript\n * // Get specific version details for e-invoice\n * const invoiceV1_1 = await client.getDocumentTypeVersion(1, 1);\n * if ('id' in invoiceV1_1) {\n * console.log('Version number:', invoiceV1_1.versionNumber);\n * console.log('Schema:', invoiceV1_1.jsonSchema);\n * console.log('Status:', invoiceV1_1.status);\n * }\n *\n * // Compare different versions\n * const [v1_0, v1_1] = await Promise.all([\n * client.getDocumentTypeVersion(1, 0),\n * client.getDocumentTypeVersion(1, 1)\n * ]);\n *\n * // Handle version not found\n * const result = await client.getDocumentTypeVersion(1, 999);\n * if ('error' in result) {\n * console.error('Version not found:', result.error.message);\n * }\n * ```\n *\n * @remarks\n * - Returns StandardError object if document type ID or version ID doesn't exist\n * - Version information includes JSON schema for validation\n * - Different versions may have different validation rules and field requirements\n * - Use this to ensure your documents conform to the specific version requirements\n * - Version status indicates if the version is active, deprecated, or under development\n */\n async getDocumentTypeVersion(\n id: number,\n versionId: number,\n ): Promise<DocumentTypeVersionResponse> {\n return DocumentTypeManagementAPI.getDocumentTypeVersion(\n { fetch: this.fetch.bind(this) },\n id,\n versionId,\n )\n }\n}\n"],"mappings":";;;;;;;;;;;AAgCA,IAAa,iBAAb,MAA4B;CAC1B,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAQ,QAAQ;CAChB,AAAQ;CAER,YACEA,UACAC,cACAC,aACAC,gBACAC,eACAC,YACAC,OACA;AAEA,OAAK,kBAAkB,eACrB,OAAM,IAAI,MACR;AAKJ,OAAK,oCAAgB,gBAAgB,cAAc,CACjD,OAAM,IAAI,MAAM;AAGlB,OAAK,WAAW;AAChB,OAAK,eAAe;AACpB,OAAK,UAAU,8BAAW,YAAY;AACtC,OAAK,aAAa;AAClB,OAAK,QAAS,SAAS,QAAQ,IAAI,mBAAmB,SAAU,OAAO;EAGvE,MAAM,EAAE,YAAY,cAAc,GAAG,2CAAuB,eAAe;AAE3E,OAAK,qBAAqB;GACxB;GACA;GACA;GACA;EACD;CACF;CAED,MAAc,eAAe;EAC3B,MAAM,gBAAgB,MAAM,oCAAc;GACxC,UAAU,KAAK;GACf,cAAc,KAAK;GACnB,SAAS,KAAK;GACd,YAAY,KAAK;GACjB,OAAO,KAAK;EACb,EAAC;AAEF,OAAK,QAAQ,cAAc;AAC3B,OAAK,kBAAkB,cAAc;CACtC;CAED,MAAc,WAAW;AACvB,OACG,KAAK,mBACN,KAAK,kCAAkB,IAAI,UAC3B,MAAM,KAAK,gBAAgB,SAAS,CAAC,EACrC;AACA,OAAI,KAAK,OAAO;AACd,YAAQ,IAAI,gBAAgB;AAC5B,YAAQ,IAAI,mBAAmB;GAChC;AACD,SAAM,KAAK,cAAc;EAC1B;AAED,SAAO,KAAK;CACb;CAED,MAAc,MAAMC,MAAcC,UAAuC,CAAE,GAAE;EAC3E,MAAM,QAAQ,MAAM,KAAK,UAAU;AAEnC,SAAO,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,GAAG;GACrC,GAAG;GACH,SAAS;IAAE,GAAG,QAAQ;IAAS,gBAAgB,SAAS,MAAM;GAAG;EAClE,EAAC;CACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8BD,MAAM,UACJC,KACAC,QACAC,SACkB;AAClB,SAAO,qCACL;GAAE,OAAO,KAAK,MAAM,KAAK,KAAK;GAAE,OAAO,KAAK;EAAO,GACnD,KACA,QACA,QACD;CACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoCD,MAAM,UAAUC,QAAqD;AACnE,SAAO,qCACL;GAAE,OAAO,KAAK,MAAM,KAAK,KAAK;GAAE,OAAO,KAAK;EAAO,GACnD,OACD;CACF;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BD,MAAM,kBAAkBC,YAAqD;AAC3E,SAAO,0CACL;GAAE,OAAO,KAAK,MAAM,KAAK,KAAK;GAAE,OAAO,KAAK;EAAO,GACnD,WACD;CACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqCD,MAAM,sBACJC,aACAC,QACAC,QAKC;AACD,SAAO,iDACL,aACA,QACA,OACD;CACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmCD,MAAM,eAAeC,WAGlB;AACD,SAAO,0CACL;GACE,OAAO,KAAK,MAAM,KAAK,KAAK;GAC5B,OAAO,KAAK;GACZ,oBAAoB,KAAK;EAC1B,GACD,UACD;CACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqCD,MAAM,oBACJC,eACAC,eAAuB,KACvBC,aAAqB,IAcpB;AACD,SAAO,+CACL;GAAE,OAAO,KAAK,MAAM,KAAK,KAAK;GAAE,OAAO,KAAK;EAAO,GACnD,eACA,cACA,WACD;CACF;;;;;;;;;;;;;;;CAgBD,MAAM,YACJN,aACiD;AACjD,SAAO,uCACL,EAAE,OAAO,KAAK,MAAM,KAAK,KAAK,CAAE,GAChC,YACD;CACF;;;;;;;;;;;;;;;CAgBD,MAAM,mBAAmBA,aAOvB;AACA,SAAO,8CACL,EAAE,OAAO,KAAK,MAAM,KAAK,KAAK,CAAE,GAChC,YACD;CACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsCD,MAAM,gBAAgB,EACpB,MACA,oBACA,kBACA,UACA,QACA,eACA,aACA,kBACA,QACA,cACA,aAaD,EAA8B;AAC7B,SAAO,2CACL,EAAE,OAAO,KAAK,MAAM,KAAK,KAAK,CAAE,GAChC;GACE;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACD,EACF;CACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgDD,MAAM,iBAAiB,EACrB,UACA,QACA,MACA,UACA,QACA,QACA,UACyB,EAAiC;AAC1D,SAAO,gDACL,EAAE,OAAO,KAAK,MAAM,KAAK,KAAK,CAAE,GAChC;GACE;GACA;GACA;GACA;GACA;GACA;GACA;EACD,EACF;CACF;CAED,MAAM,mBAAmD;AACvD,SAAO,gDAA2C,EAChD,OAAO,KAAK,MAAM,KAAK,KAAK,CAC7B,EAAC;CACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmCD,MAAM,gBAAgBO,IAA2C;AAC/D,SAAO,+CACL,EAAE,OAAO,KAAK,MAAM,KAAK,KAAK,CAAE,GAChC,GACD;CACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2CD,MAAM,uBACJA,IACAC,WACsC;AACtC,SAAO,sDACL,EAAE,OAAO,KAAK,MAAM,KAAK,KAAK,CAAE,GAChC,IACA,UACD;CACF;AACF"}
package/dist/index.d.ts CHANGED
@@ -13,9 +13,9 @@ import "./7X-Ckv9bbzG.js";
13
13
  import "./8X-C37BJTl6.js";
14
14
  import "./9X-_XRgT2-_.js";
15
15
  import { MSICCode } from "./msic-codes-CiPeemFK.js";
16
- import { CanonicalizationMethod, Cert, CertDigest, DigestMethod, IssuerDigitalSignature, IssuerSerial, KeyInfo, QualifyingProperties, Reference, SignatureMethod, SignedInfo, SignedProperties, SignedSignatureProperties, SigningCertificate, Transform, X509Data } from "./signatures-DOKNMiZI.js";
17
- import { TaxType, TaxTypeCode, TaxTypeCodeEnum } from "./tax-types-ieqw5Ze7.js";
18
- import { Address, Buyer, CompleteInvoice, DocumentStatus, DocumentSummary, DocumentTypeResponse, DocumentTypeVersion, DocumentTypeVersionResponse, DocumentTypesResponse, DocumentValidationResult, DocumentValidationStepResult, FinalDocumentData, GetSubmissionResponse, InvoiceLineItem, InvoiceSubmission, InvoiceV1_1, LegalMonetaryTotal, RegistrationType, ResponseDocument, SignedInfoObject, SignedInvoiceSubmission, SignedPropertiesData, SignedPropertiesObject, SigningCredentials, StandardError, SubmissionResponse, SubmissionStatus, Supplier, TaxCategory, TaxSubtotal, TaxTotal, UBLDocument, WorkflowParameter } from "./documents-BgXt86Qp.js";
16
+ import { TaxType, TaxTypeCode, TaxTypeCodeEnum } from "./tax-types-BskcyNBv.js";
17
+ import { State, StateCode, StateCodeEnum } from "./state-codes-BaGjZcA8.js";
18
+ import { Address, Buyer, CompleteInvoice, DocumentStatus, DocumentSummary, DocumentTypeResponse, DocumentTypeVersion, DocumentTypeVersionResponse, DocumentTypesResponse, DocumentValidationResult, DocumentValidationStepResult, FinalDocumentData, GetSubmissionResponse, InvoiceLineItem, InvoiceSubmission, InvoiceV1_1, LegalMonetaryTotal, RegistrationType, ResponseDocument, SignedInfoObject, SignedInvoiceSubmission, SignedPropertiesData, SignedPropertiesObject, SigningCredentials, StandardError, SubmissionResponse, SubmissionStatus, Supplier, TaxCategory, TaxSubtotal, TaxTotal, UBLDocument, WorkflowParameter } from "./documents-zzL50wnG.js";
19
19
  import { PaymentMode, PaymentModeCode, PaymentModeCodeEnum } from "./payment-modes-NpE3OcCV.js";
20
20
  import "./1X-C72Wa4pk.js";
21
21
  import "./2X-CH89y3Af.js";
@@ -53,9 +53,9 @@ import "./YX-F34sJ7Ik.js";
53
53
  import "./ZX-CDQOfsHh.js";
54
54
  import "./XX-DOA-10JW.js";
55
55
  import { UnitType, UnitTypeCode } from "./unit-types-VgYXIwTT.js";
56
- import { State, StateCode, StateCodeEnum } from "./state-codes-VOFWhHA0.js";
56
+ import { CanonicalizationMethod, Cert, CertDigest, DigestMethod, IssuerDigitalSignature, IssuerSerial, KeyInfo, QualifyingProperties, Reference, SignatureMethod, SignedInfo, SignedProperties, SignedSignatureProperties, SigningCertificate, Transform, X509Data } from "./signatures-C-nCPDqt.js";
57
57
  import { Notification, NotificationDeliveryAttempt, NotificationMetadata, NotificationResponse, NotificationSearchParams, NotificationStatus, NotificationStatusEnum, NotificationType, NotificationTypeEnum } from "./notifications-B4l_qRj7.js";
58
- import { TaxpayerQRCodeResponse, TinSearchParams, TinSearchResponse } from "./taxpayer-fpGIHNXp.js";
58
+ import { TaxpayerQRCodeResponse, TinSearchParams, TinSearchResponse } from "./taxpayer-CxAVm7lJ.js";
59
59
  import { Fetch } from "./utils-B3mo51Zp.js";
60
60
  import { ClientCredentials, TokenResponse } from "./index-FTgB2nM6.js";
61
61
 
@@ -136,16 +136,16 @@ declare class MyInvoisClient {
136
136
  * - Debug mode provides detailed error logging for troubleshooting
137
137
  * - Search results are not guaranteed to be unique
138
138
  */
139
- searchTin(params: TinSearchParams): Promise<TinSearchResponse | StandardError>;
139
+ searchTin(params: TinSearchParams): Promise<TinSearchResponse>;
140
140
  /**
141
141
  * Retrieves taxpayer information from a QR code.
142
- *
142
+ *
143
143
  * This method decodes a QR code containing taxpayer information and returns
144
144
  * detailed taxpayer data including TIN, name, contact details, and business information.
145
- *
145
+ *
146
146
  * @param qrCodeText - The QR code text to decode
147
147
  * @returns Promise resolving to taxpayer QR code response or standard error
148
- *
148
+ *
149
149
  * @example
150
150
  * ```typescript
151
151
  * // Get taxpayer info from QR code
@@ -156,25 +156,25 @@ declare class MyInvoisClient {
156
156
  * console.log('Address:', taxpayerInfo.addressLine1);
157
157
  * }
158
158
  * ```
159
- *
159
+ *
160
160
  * @remarks
161
161
  * - QR code must be in the correct format specified by MyInvois
162
162
  * - Returns StandardError if QR code is invalid or cannot be decoded
163
163
  * - Debug mode provides detailed error logging
164
164
  */
165
- getTaxpayerQRCode(qrCodeText: string): Promise<TaxpayerQRCodeResponse | StandardError>;
165
+ getTaxpayerQRCode(qrCodeText: string): Promise<TaxpayerQRCodeResponse>;
166
166
  /**
167
167
  * Performs an action on a document such as rejection or cancellation.
168
- *
168
+ *
169
169
  * This method allows updating the status of a document to either rejected or cancelled,
170
170
  * along with providing a reason for the action. Useful for managing document workflow
171
171
  * and maintaining audit trails.
172
- *
172
+ *
173
173
  * @param documentUid - The unique identifier of the document
174
174
  * @param status - The new status to set ('rejected' or 'cancelled')
175
175
  * @param reason - The reason for the status change
176
176
  * @returns Promise resolving to document action response containing UUID, status, and any errors
177
- *
177
+ *
178
178
  * @example
179
179
  * ```typescript
180
180
  * // Reject a document with reason
@@ -183,7 +183,7 @@ declare class MyInvoisClient {
183
183
  * 'rejected',
184
184
  * 'Invalid tax calculation'
185
185
  * );
186
- *
186
+ *
187
187
  * // Cancel a document
188
188
  * const result = await client.performDocumentAction(
189
189
  * 'doc-456',
@@ -191,7 +191,7 @@ declare class MyInvoisClient {
191
191
  * 'Duplicate submission'
192
192
  * );
193
193
  * ```
194
- *
194
+ *
195
195
  * @remarks
196
196
  * - Only valid for documents in appropriate states
197
197
  * - Reason is required and should be descriptive
@@ -441,8 +441,8 @@ declare class MyInvoisClient {
441
441
  status,
442
442
  pageNo,
443
443
  pageSize
444
- }: NotificationSearchParams): Promise<NotificationResponse | StandardError>;
445
- getDocumentTypes(): Promise<DocumentTypesResponse | StandardError>;
444
+ }: NotificationSearchParams): Promise<NotificationResponse>;
445
+ getDocumentTypes(): Promise<DocumentTypesResponse>;
446
446
  /**
447
447
  * Retrieves detailed information about a specific document type from the MyInvois platform.
448
448
  *
@@ -476,7 +476,7 @@ declare class MyInvoisClient {
476
476
  * - Use this method to discover supported document formats and versions
477
477
  * - Essential for understanding submission requirements for different document types
478
478
  */
479
- getDocumentType(id: number): Promise<DocumentTypeResponse | StandardError>;
479
+ getDocumentType(id: number): Promise<DocumentTypeResponse>;
480
480
  /**
481
481
  * Retrieves detailed information about a specific version of a document type.
482
482
  *
@@ -518,7 +518,7 @@ declare class MyInvoisClient {
518
518
  * - Use this to ensure your documents conform to the specific version requirements
519
519
  * - Version status indicates if the version is active, deprecated, or under development
520
520
  */
521
- getDocumentTypeVersion(id: number, versionId: number): Promise<DocumentTypeVersionResponse | StandardError>;
521
+ getDocumentTypeVersion(id: number, versionId: number): Promise<DocumentTypeVersionResponse>;
522
522
  }
523
523
  //#endregion
524
524
  export { Address, Buyer, CanonicalizationMethod, Cert, CertDigest, Classification, ClassificationCode, ClassificationCodeEnum, ClientCredentials, CompleteInvoice, Country, CountryCode, CountryCodeEnum, CountryNameEnum, Currency, CurrencyCode, CurrencyCodeEnum, DigestMethod, DocumentStatus, DocumentSummary, DocumentTypeResponse, DocumentTypeVersion, DocumentTypeVersionResponse, DocumentTypesResponse, DocumentValidationResult, DocumentValidationStepResult, EInvoiceType, EInvoiceTypeCode, EInvoiceTypeCodeEnum, Fetch, FinalDocumentData, GetSubmissionResponse, InvoiceLineItem, InvoiceSubmission, InvoiceV1_1, IssuerDigitalSignature, IssuerSerial, KeyInfo, LegalMonetaryTotal, MSICCode, MyInvoisClient, Notification, NotificationDeliveryAttempt, NotificationMetadata, NotificationResponse, NotificationSearchParams, NotificationStatus, NotificationStatusEnum, NotificationType, NotificationTypeEnum, PaymentMode, PaymentModeCode, PaymentModeCodeEnum, QualifyingProperties, Reference, RegistrationType, ResponseDocument, SignatureMethod, SignedInfo, SignedInfoObject, SignedInvoiceSubmission, SignedProperties, SignedPropertiesData, SignedPropertiesObject, SignedSignatureProperties, SigningCertificate, SigningCredentials, StandardError, State, StateCode, StateCodeEnum, SubmissionResponse, SubmissionStatus, Supplier, TaxCategory, TaxSubtotal, TaxTotal, TaxType, TaxTypeCode, TaxTypeCodeEnum, TaxpayerQRCodeResponse, TinSearchParams, TinSearchResponse, TokenResponse, Transform, UBLDocument, UnitType, UnitTypeCode, WorkflowParameter, X509Data };
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import { getSubmissionStatus, performDocumentAction, submitDocument } from "./do
4
4
  import { getDocumentType, getDocumentTypeVersion, getDocumentTypes } from "./documentTypeManagement-tojgXfm9.js";
5
5
  import { getNotifications } from "./notificationManagement-CHDRVy8J.js";
6
6
  import { platformLogin } from "./platformLogin-Ck1Fge2n.js";
7
- import { taxpayerQRCode, tinSearch, verifyTin } from "./taxpayerValidation-DI4B6kWx.js";
7
+ import { taxpayerQRCode, tinSearch, verifyTin } from "./taxpayerValidation-DiLGJg1l.js";
8
8
  import { extractCertificateInfo, validateKeyPair } from "./certificate-BDECQL9C.js";
9
9
  import { getBaseUrl } from "./getBaseUrl-BYkBwhQP.js";
10
10
 
@@ -141,13 +141,13 @@ var MyInvoisClient = class {
141
141
  }
142
142
  /**
143
143
  * Retrieves taxpayer information from a QR code.
144
- *
144
+ *
145
145
  * This method decodes a QR code containing taxpayer information and returns
146
146
  * detailed taxpayer data including TIN, name, contact details, and business information.
147
- *
147
+ *
148
148
  * @param qrCodeText - The QR code text to decode
149
149
  * @returns Promise resolving to taxpayer QR code response or standard error
150
- *
150
+ *
151
151
  * @example
152
152
  * ```typescript
153
153
  * // Get taxpayer info from QR code
@@ -158,7 +158,7 @@ var MyInvoisClient = class {
158
158
  * console.log('Address:', taxpayerInfo.addressLine1);
159
159
  * }
160
160
  * ```
161
- *
161
+ *
162
162
  * @remarks
163
163
  * - QR code must be in the correct format specified by MyInvois
164
164
  * - Returns StandardError if QR code is invalid or cannot be decoded
@@ -172,16 +172,16 @@ var MyInvoisClient = class {
172
172
  }
173
173
  /**
174
174
  * Performs an action on a document such as rejection or cancellation.
175
- *
175
+ *
176
176
  * This method allows updating the status of a document to either rejected or cancelled,
177
177
  * along with providing a reason for the action. Useful for managing document workflow
178
178
  * and maintaining audit trails.
179
- *
179
+ *
180
180
  * @param documentUid - The unique identifier of the document
181
181
  * @param status - The new status to set ('rejected' or 'cancelled')
182
182
  * @param reason - The reason for the status change
183
183
  * @returns Promise resolving to document action response containing UUID, status, and any errors
184
- *
184
+ *
185
185
  * @example
186
186
  * ```typescript
187
187
  * // Reject a document with reason
@@ -190,7 +190,7 @@ var MyInvoisClient = class {
190
190
  * 'rejected',
191
191
  * 'Invalid tax calculation'
192
192
  * );
193
- *
193
+ *
194
194
  * // Cancel a document
195
195
  * const result = await client.performDocumentAction(
196
196
  * 'doc-456',
@@ -198,7 +198,7 @@ var MyInvoisClient = class {
198
198
  * 'Duplicate submission'
199
199
  * );
200
200
  * ```
201
- *
201
+ *
202
202
  * @remarks
203
203
  * - Only valid for documents in appropriate states
204
204
  * - Reason is required and should be descriptive
package/dist/index22.cjs CHANGED
@@ -1,4 +1,4 @@
1
- const require_taxpayerValidation = require('./taxpayerValidation-DdeXCvPT.cjs');
1
+ const require_taxpayerValidation = require('./taxpayerValidation-CSuifcY1.cjs');
2
2
 
3
3
  exports.taxpayerQRCode = require_taxpayerValidation.taxpayerQRCode;
4
4
  exports.tinSearch = require_taxpayerValidation.tinSearch;
@@ -1 +1 @@
1
- {"version":3,"file":"index63.cts","names":[],"sources":["../src/api/documentTypeManagement.d.ts"],"sourcesContent":["import type { DocumentTypesResponse, DocumentTypeResponse, DocumentTypeVersionResponse, StandardError, Fetch } from '../types';\ninterface DocumentTypeContext {\n fetch: Fetch;\n}\nexport declare function getDocumentTypes(context: DocumentTypeContext): Promise<DocumentTypesResponse>;\nexport declare function getDocumentType(context: DocumentTypeContext, id: number): Promise<DocumentTypeResponse | StandardError>;\nexport declare function getDocumentTypeVersion(context: DocumentTypeContext, id: number, versionId: number): Promise<DocumentTypeVersionResponse | StandardError>;\nexport {};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,IAAI,sBAAsB,CAAC,KAAG,MAAA,KAAA;AAC9B,IAAW,mBAAK;CAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;AAAA;AAChB,IAAA,kBAAA;CAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;AAAA;AACA,IAAW,yBAAyB;CAAC;CAAK,MAAM;CAAqB,MAAM;CAA2B,MAAA;CAAA,MAAA;AAAA"}
1
+ {"version":3,"file":"index63.cts","names":[],"sources":["../src/api/documentTypeManagement.d.ts"],"sourcesContent":["import type { DocumentTypeResponse, DocumentTypesResponse, DocumentTypeVersionResponse, Fetch } from '../types';\ninterface DocumentTypeContext {\n fetch: Fetch;\n}\nexport declare function getDocumentTypes(context: DocumentTypeContext): Promise<DocumentTypesResponse>;\nexport declare function getDocumentType(context: DocumentTypeContext, id: number): Promise<DocumentTypeResponse>;\nexport declare function getDocumentTypeVersion(context: DocumentTypeContext, id: number, versionId: number): Promise<DocumentTypeVersionResponse>;\nexport {};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,IAAI,sBAAsB,CAAC,KAAG,MAAA,KAAA;AAC9B,IAAW,mBAAK;CAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;AAAA;AAChB,IAAA,kBAAA;CAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;AAAA;AACA,IAAW,yBAAyB;CAAC;CAAK,MAAM;CAAqB,MAAM;CAA2B,MAAA;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"index64.cts","names":[],"sources":["../src/api/notificationManagement.d.ts"],"sourcesContent":["import type { NotificationResponse, NotificationSearchParams, StandardError, Fetch } from '../types';\ninterface NotificationContext {\n fetch: Fetch;\n}\nexport declare function getNotifications(context: NotificationContext, params: NotificationSearchParams): Promise<NotificationResponse | StandardError>;\nexport {};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,IAAI,sBAAsB,CAAC,KAAG,MAAA,KAAA;AAC9B,IAAW,mBAAK;CAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;AAAA"}
1
+ {"version":3,"file":"index64.cts","names":[],"sources":["../src/api/notificationManagement.d.ts"],"sourcesContent":["import type { Fetch, NotificationResponse, NotificationSearchParams } from '../types';\ninterface NotificationContext {\n fetch: Fetch;\n}\nexport declare function getNotifications(context: NotificationContext, params: NotificationSearchParams): Promise<NotificationResponse>;\nexport {};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,IAAI,sBAAsB,CAAC,KAAG,MAAA,KAAA;AAC9B,IAAW,mBAAK;CAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"index66.cts","names":[],"sources":["../src/api/taxpayerValidation.d.ts"],"sourcesContent":["import type { Fetch, RegistrationType, StandardError, TaxpayerQRCodeResponse, TinSearchParams, TinSearchResponse } from '../types';\ninterface TaxpayerContext {\n fetch: Fetch;\n debug: boolean;\n}\nexport declare function tinSearch(context: TaxpayerContext, params: TinSearchParams): Promise<TinSearchResponse | StandardError>;\nexport declare function verifyTin(context: TaxpayerContext, tin: string, idType: RegistrationType, idValue: string): Promise<boolean>;\nexport declare function taxpayerQRCode(context: TaxpayerContext, qrCodeText: string): Promise<TaxpayerQRCodeResponse | StandardError>;\nexport {};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,IAAI,kBAAkB,CAAC,KAAG,MAAA,KAAA;AAC1B,IAAW,YAAK;CAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;AAAA;AAChB,IAAW,YAAO;CAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;AAAA;AAClB,IAAA,iBAAA;CAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;AAAA"}
1
+ {"version":3,"file":"index66.cts","names":[],"sources":["../src/api/taxpayerValidation.d.ts"],"sourcesContent":["import type { Fetch, RegistrationType, TaxpayerQRCodeResponse, TinSearchParams, TinSearchResponse } from '../types';\ninterface TaxpayerContext {\n fetch: Fetch;\n debug: boolean;\n}\nexport declare function tinSearch(context: TaxpayerContext, params: TinSearchParams): Promise<TinSearchResponse>;\nexport declare function verifyTin(context: TaxpayerContext, tin: string, idType: RegistrationType, idValue: string): Promise<boolean>;\nexport declare function taxpayerQRCode(context: TaxpayerContext, qrCodeText: string): Promise<TaxpayerQRCodeResponse>;\nexport {};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,IAAI,kBAAkB,CAAC,KAAG,MAAA,KAAA;AAC1B,IAAW,YAAK;CAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;AAAA;AAChB,IAAW,YAAO;CAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;AAAA;AAClB,IAAA,iBAAA;CAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"index67.cts","names":[],"sources":["../src/index.d.ts"],"sourcesContent":["import { DocumentStatus, DocumentSummary, DocumentTypeResponse, DocumentTypesResponse, DocumentTypeVersionResponse, DocumentValidationResult, DocumentValidationStepResult, EInvoiceTypeCode, InvoiceV1_1, NotificationResponse, NotificationSearchParams, RegistrationType, StandardError, SubmissionResponse, SubmissionStatus, TaxpayerQRCodeResponse, TinSearchParams, TinSearchResponse } from './types';\nexport type * from './types/index.d.ts';\nexport declare class MyInvoisClient {\n private readonly baseUrl;\n private readonly clientId;\n private readonly clientSecret;\n private readonly onBehalfOf?;\n private readonly signingCredentials;\n private readonly debug;\n private token;\n private tokenExpiration;\n constructor(clientId: string, clientSecret: string, environment: 'sandbox' | 'production', certificatePem: string, privateKeyPem: string, onBehalfOf?: string, debug?: boolean);\n private refreshToken;\n private getToken;\n private fetch;\n /**\n * Validates a TIN against a NRIC/ARMY/PASSPORT/BRN (Business Registration Number)\n *\n * This method verifies if a given Tax Identification Number (TIN) is valid by checking it against\n * the provided identification type and value through the MyInvois platform's validation service.\n *\n * @param tin - The TIN to validate\n * @param idType - The type of ID to validate against ('NRIC', 'ARMY', 'PASSPORT', or 'BRN')\n * @param idValue - The value of the ID to validate against\n * @returns Promise resolving to true if the TIN is valid, false otherwise\n *\n * @example\n * ```typescript\n * // Validate TIN against NRIC\n * const isValid = await client.verifyTin('C12345678901234', 'NRIC', '123456789012');\n * if (isValid) {\n * console.log('TIN is valid');\n * }\n *\n * // Validate TIN against Business Registration Number\n * const isValidBusiness = await client.verifyTin('C98765432109876', 'BRN', '123456-K');\n * ```\n *\n * @remarks\n * - Returns false if validation fails due to network errors or invalid credentials\n * - Debug mode provides error logging for troubleshooting validation failures\n * - This is a non-blocking validation that won't throw exceptions on failure\n */\n verifyTin(tin: string, idType: RegistrationType, idValue: string): Promise<boolean>;\n /**\n * Searches for a Tax Identification Number (TIN) using taxpayer information.\n *\n * This method allows searching for a TIN using either a taxpayer name or a combination\n * of identification type and value. The search is flexible and supports multiple\n * identification types including NRIC, ARMY, PASSPORT, and BRN.\n *\n * @param params - Search parameters object\n * @param params.taxpayerName - Optional name of the taxpayer to search for\n * @param params.idType - Optional type of ID to search with (NRIC, ARMY, PASSPORT, BRN)\n * @param params.idValue - Optional value of the ID to search with\n * @returns Promise resolving to TIN search response or standard error\n *\n * @example\n * ```typescript\n * // Search by taxpayer name\n * const result = await client.searchTin({ taxpayerName: 'John Doe' });\n * if ('tin' in result) {\n * console.log('Found TIN:', result.tin);\n * }\n *\n * // Search by ID type and value\n * const result = await client.searchTin({\n * idType: 'NRIC',\n * idValue: '123456789012'\n * });\n * ```\n *\n * @remarks\n * - Either taxpayerName or both idType and idValue must be provided\n * - Returns StandardError object if search criteria are invalid or inconclusive\n * - Debug mode provides detailed error logging for troubleshooting\n * - Search results are not guaranteed to be unique\n */\n searchTin(params: TinSearchParams): Promise<TinSearchResponse | StandardError>;\n /**\n * Retrieves taxpayer information from a QR code.\n *\n * This method decodes a QR code containing taxpayer information and returns\n * detailed taxpayer data including TIN, name, contact details, and business information.\n *\n * @param qrCodeText - The QR code text to decode\n * @returns Promise resolving to taxpayer QR code response or standard error\n *\n * @example\n * ```typescript\n * // Get taxpayer info from QR code\n * const taxpayerInfo = await client.getTaxpayerQRCode('QR_CODE_TEXT');\n * if ('tin' in taxpayerInfo) {\n * console.log('Taxpayer TIN:', taxpayerInfo.tin);\n * console.log('Business Name:', taxpayerInfo.name);\n * console.log('Address:', taxpayerInfo.addressLine1);\n * }\n * ```\n *\n * @remarks\n * - QR code must be in the correct format specified by MyInvois\n * - Returns StandardError if QR code is invalid or cannot be decoded\n * - Debug mode provides detailed error logging\n */\n getTaxpayerQRCode(qrCodeText: string): Promise<TaxpayerQRCodeResponse | StandardError>;\n /**\n * Performs an action on a document such as rejection or cancellation.\n *\n * This method allows updating the status of a document to either rejected or cancelled,\n * along with providing a reason for the action. Useful for managing document workflow\n * and maintaining audit trails.\n *\n * @param documentUid - The unique identifier of the document\n * @param status - The new status to set ('rejected' or 'cancelled')\n * @param reason - The reason for the status change\n * @returns Promise resolving to document action response containing UUID, status, and any errors\n *\n * @example\n * ```typescript\n * // Reject a document with reason\n * const result = await client.performDocumentAction(\n * 'doc-123',\n * 'rejected',\n * 'Invalid tax calculation'\n * );\n *\n * // Cancel a document\n * const result = await client.performDocumentAction(\n * 'doc-456',\n * 'cancelled',\n * 'Duplicate submission'\n * );\n * ```\n *\n * @remarks\n * - Only valid for documents in appropriate states\n * - Reason is required and should be descriptive\n * - Action is irreversible once completed\n * - Returns error if document cannot be found or action is invalid\n */\n performDocumentAction(documentUid: string, status: 'rejected' | 'cancelled', reason: string): Promise<{\n uuid: string;\n status: string;\n error: StandardError;\n }>;\n /**\n * Submits one or more e-invoice documents to the MyInvois platform for processing.\n *\n * This method digitally signs each document using the provided certificate and private key,\n * generates document hashes, encodes them for submission, and sends them to the platform.\n * The method includes comprehensive validation warnings for document size and count limits.\n *\n * @param documents - Array of InvoiceV1_1 documents to be submitted\n * @returns Promise resolving to submission response containing the submission data and HTTP status\n * @throws {Error} If PRIVATE_KEY or CERTIFICATE environment variables are missing\n * @throws {Error} If document signing, encoding, or API submission fails\n *\n * @example\n * ```typescript\n * // Submit a single invoice\n * const result = await client.submitDocument([invoiceData]);\n * console.log(result.data.submissionUid); // Track submission with this UID\n *\n * // Submit multiple invoices\n * const result = await client.submitDocument([invoice1, invoice2, invoice3]);\n * if (result.status === 202) {\n * console.log('Documents submitted successfully');\n * }\n * ```\n *\n * @remarks\n * - Requires PRIVATE_KEY and CERTIFICATE environment variables for document signing\n * - Each document is digitally signed with XML-DSIG before submission\n * - Documents are base64-encoded for transmission\n * - API limits: Max 100 documents per submission, 5MB total payload, 300KB per document\n * - Debug mode provides detailed logging of payload sizes and validation warnings\n * - Returns HTTP 202 for successful submissions that require processing\n */\n submitDocument(documents: InvoiceV1_1[]): Promise<{\n data: SubmissionResponse;\n status: number;\n }>;\n /**\n * Polls the MyInvois platform to get the current status of a document submission.\n *\n * This method continuously checks the submission status until it receives a final result\n * (Valid or Invalid) or reaches the maximum retry limit. It's designed to handle the\n * asynchronous nature of document processing on the MyInvois platform.\n *\n * @param submissionUid - The unique identifier of the submission to check\n * @param pollInterval - Time in milliseconds between status checks (default: 1000ms)\n * @param maxRetries - Maximum number of retry attempts (default: 10)\n * @returns Promise resolving to submission status object with document summary and any errors\n *\n * @example\n * ```typescript\n * // Check submission status with default polling\n * const result = await client.getSubmissionStatus('submission-uid-123');\n * if (result.status === 'Valid') {\n * console.log('All documents processed successfully');\n * console.log('Document summaries:', result.documentSummary);\n * }\n *\n * // Custom polling interval and retry count\n * const result = await client.getSubmissionStatus(\n * 'submission-uid-123',\n * 2000, // Poll every 2 seconds\n * 20 // Try up to 20 times\n * );\n * ```\n *\n * @remarks\n * - Automatically retries on network errors until maxRetries is reached\n * - Returns 'Invalid' status with timeout error if submission processing takes too long\n * - Debug mode provides detailed logging of polling attempts and responses\n * - Use reasonable poll intervals to avoid overwhelming the API\n */\n getSubmissionStatus(submissionUid: string, pollInterval?: number, maxRetries?: number): Promise<{\n status: SubmissionStatus;\n documentSummary?: DocumentSummary[];\n error?: {\n code: string;\n message: string | null;\n target: string;\n details: {\n code: string;\n message: string;\n target: string;\n }[];\n };\n }>;\n /**\n * Retrieves a document by its unique identifier with the raw document content.\n *\n * @param documentUid - The unique identifier of the document to retrieve\n * @returns Promise resolving to document summary with raw document content as a string\n * @throws {Error} If the document is not found or request fails\n *\n * @example\n * ```typescript\n * const document = await client.getDocument('doc-uuid-123');\n * console.log(document.document); // Raw XML/JSON content\n * console.log(document.uuid); // Document UUID\n * ```\n */\n getDocument(documentUid: string): Promise<DocumentSummary & {\n document: string;\n }>;\n /**\n * Retrieves detailed information about a document including validation results.\n *\n * @param documentUid - The unique identifier of the document to get details for\n * @returns Promise resolving to document summary with detailed validation results\n * @throws {Error} If the document is not found or request fails\n *\n * @example\n * ```typescript\n * const details = await client.getDocumentDetails('doc-uuid-123');\n * console.log(details.validationResults.status); // 'Valid' | 'Invalid' | 'Processing'\n * console.log(details.validationResults.validationSteps); // Array of validation step results\n * ```\n */\n getDocumentDetails(documentUid: string): Promise<DocumentSummary & {\n validationResults: {\n status: DocumentValidationResult;\n validationSteps: DocumentValidationStepResult[];\n };\n }>;\n /**\n * Searches for documents based on various filter criteria.\n *\n * @param params - Search parameters object\n * @param params.uuid - Optional specific document UUID to search for\n * @param params.submissionDateFrom - Required start date for submission date range (ISO date string)\n * @param params.submissionDateTo - Optional end date for submission date range (ISO date string)\n * @param params.pageSize - Optional number of results per page (default handled by API)\n * @param params.pageNo - Optional page number for pagination (0-based)\n * @param params.issueDateFrom - Optional start date for issue date range (ISO date string)\n * @param params.issueDateTo - Optional end date for issue date range (ISO date string)\n * @param params.invoiceDirection - Optional filter by invoice direction ('Sent' or 'Received')\n * @param params.status - Optional filter by document status\n * @param params.documentType - Optional filter by e-invoice type code\n * @param params.searchQuery - Optional text search across uuid, buyerTIN, supplierTIN, buyerName, supplierName, internalID, total\n * @returns Promise resolving to array of document summaries matching the search criteria\n * @throws {Error} If the search request fails\n *\n * @example\n * ```typescript\n * // Search for documents submitted in the last 30 days\n * const documents = await client.searchDocuments({\n * submissionDateFrom: '2024-01-01',\n * submissionDateTo: '2024-01-31',\n * status: 'Valid',\n * pageSize: 10\n * });\n *\n * // Search by supplier name\n * const supplierDocs = await client.searchDocuments({\n * submissionDateFrom: '2024-01-01',\n * searchQuery: 'ACME Corp',\n * invoiceDirection: 'Received'\n * });\n * ```\n */\n searchDocuments({ uuid, submissionDateFrom, submissionDateTo, pageSize, pageNo, issueDateFrom, issueDateTo, invoiceDirection, status, documentType, searchQuery, }: {\n uuid?: string;\n submissionDateFrom: string;\n submissionDateTo?: string;\n pageSize?: number;\n pageNo?: number;\n issueDateFrom?: string;\n issueDateTo?: string;\n invoiceDirection?: 'Sent' | 'Received';\n status?: DocumentStatus;\n documentType?: EInvoiceTypeCode;\n searchQuery?: string;\n }): Promise<DocumentSummary[]>;\n /**\n * Retrieves notifications from the MyInvois platform based on specified search criteria.\n *\n * This method allows you to search for system notifications, alerts, and messages\n * sent by the MyInvois platform regarding document processing, system updates,\n * or account-related information.\n *\n * @param params - Search parameters object for filtering notifications\n * @param params.dateFrom - Optional start date for notification date range (ISO date string)\n * @param params.dateTo - Optional end date for notification date range (ISO date string)\n * @param params.type - Optional notification type filter\n * @param params.language - Optional language preference for notifications\n * @param params.status - Optional notification status filter\n * @param params.pageNo - Optional page number for pagination (0-based)\n * @param params.pageSize - Optional number of results per page\n * @returns Promise resolving to notification response object or standard error\n *\n * @example\n * ```typescript\n * // Get all notifications from the last 7 days\n * const notifications = await client.getNotifications({\n * dateFrom: '2024-01-01',\n * dateTo: '2024-01-07',\n * pageSize: 20\n * });\n *\n * // Get unread notifications only\n * const unreadNotifications = await client.getNotifications({\n * status: 0, // Assuming 0 = unread\n * language: 'en'\n * });\n *\n * // Paginated notification retrieval\n * const firstPage = await client.getNotifications({\n * dateFrom: '2024-01-01',\n * pageNo: 0,\n * pageSize: 10\n * });\n * ```\n *\n * @remarks\n * - All parameters are optional, allowing flexible filtering\n * - Returns paginated results when pageNo and pageSize are specified\n * - Date parameters should be in ISO format (YYYY-MM-DD)\n * - May return StandardError object if the request fails\n */\n getNotifications({ dateFrom, dateTo, type, language, status, pageNo, pageSize, }: NotificationSearchParams): Promise<NotificationResponse | StandardError>;\n getDocumentTypes(): Promise<DocumentTypesResponse | StandardError>;\n /**\n * Retrieves detailed information about a specific document type from the MyInvois platform.\n *\n * This method fetches metadata and configuration details for a specific document type,\n * including supported versions, validation rules, and structural requirements.\n * Useful for understanding document format requirements before submission.\n *\n * @param id - The unique identifier of the document type to retrieve\n * @returns Promise resolving to document type response object or standard error\n *\n * @example\n * ```typescript\n * // Get details for e-invoice document type\n * const invoiceType = await client.getDocumentType(1);\n * if ('id' in invoiceType) {\n * console.log('Document type name:', invoiceType.name);\n * console.log('Available versions:', invoiceType.versionNumber);\n * console.log('Description:', invoiceType.description);\n * }\n *\n * // Handle potential errors\n * const documentType = await client.getDocumentType(999);\n * if ('error' in documentType) {\n * console.error('Failed to retrieve document type:', documentType.error.message);\n * }\n * ```\n *\n * @remarks\n * - Returns StandardError object if the document type ID doesn't exist\n * - Document type information includes validation schemas and business rules\n * - Use this method to discover supported document formats and versions\n * - Essential for understanding submission requirements for different document types\n */\n getDocumentType(id: number): Promise<DocumentTypeResponse | StandardError>;\n /**\n * Retrieves detailed information about a specific version of a document type.\n *\n * This method fetches version-specific metadata, schema definitions, and validation rules\n * for a particular document type version. Essential for understanding the exact format\n * and requirements for document submission in a specific version.\n *\n * @param id - The unique identifier of the document type\n * @param versionId - The unique identifier of the specific version to retrieve\n * @returns Promise resolving to document type version response object or standard error\n *\n * @example\n * ```typescript\n * // Get specific version details for e-invoice\n * const invoiceV1_1 = await client.getDocumentTypeVersion(1, 1);\n * if ('id' in invoiceV1_1) {\n * console.log('Version number:', invoiceV1_1.versionNumber);\n * console.log('Schema:', invoiceV1_1.jsonSchema);\n * console.log('Status:', invoiceV1_1.status);\n * }\n *\n * // Compare different versions\n * const [v1_0, v1_1] = await Promise.all([\n * client.getDocumentTypeVersion(1, 0),\n * client.getDocumentTypeVersion(1, 1)\n * ]);\n *\n * // Handle version not found\n * const result = await client.getDocumentTypeVersion(1, 999);\n * if ('error' in result) {\n * console.error('Version not found:', result.error.message);\n * }\n * ```\n *\n * @remarks\n * - Returns StandardError object if document type ID or version ID doesn't exist\n * - Version information includes JSON schema for validation\n * - Different versions may have different validation rules and field requirements\n * - Use this to ensure your documents conform to the specific version requirements\n * - Version status indicates if the version is active, deprecated, or under development\n */\n getDocumentTypeVersion(id: number, versionId: number): Promise<DocumentTypeVersionResponse | StandardError>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAW,iBAAiB;CAAC;CAAK,MAAE;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;AAAA"}
1
+ {"version":3,"file":"index67.cts","names":[],"sources":["../src/index.d.ts"],"sourcesContent":["import { DocumentStatus, DocumentSummary, DocumentTypeResponse, DocumentTypesResponse, DocumentTypeVersionResponse, DocumentValidationResult, DocumentValidationStepResult, EInvoiceTypeCode, InvoiceV1_1, NotificationResponse, NotificationSearchParams, RegistrationType, StandardError, SubmissionResponse, SubmissionStatus, TaxpayerQRCodeResponse, TinSearchParams, TinSearchResponse } from './types';\nexport type * from './types/index.d.ts';\nexport declare class MyInvoisClient {\n private readonly baseUrl;\n private readonly clientId;\n private readonly clientSecret;\n private readonly onBehalfOf?;\n private readonly signingCredentials;\n private readonly debug;\n private token;\n private tokenExpiration;\n constructor(clientId: string, clientSecret: string, environment: 'sandbox' | 'production', certificatePem: string, privateKeyPem: string, onBehalfOf?: string, debug?: boolean);\n private refreshToken;\n private getToken;\n private fetch;\n /**\n * Validates a TIN against a NRIC/ARMY/PASSPORT/BRN (Business Registration Number)\n *\n * This method verifies if a given Tax Identification Number (TIN) is valid by checking it against\n * the provided identification type and value through the MyInvois platform's validation service.\n *\n * @param tin - The TIN to validate\n * @param idType - The type of ID to validate against ('NRIC', 'ARMY', 'PASSPORT', or 'BRN')\n * @param idValue - The value of the ID to validate against\n * @returns Promise resolving to true if the TIN is valid, false otherwise\n *\n * @example\n * ```typescript\n * // Validate TIN against NRIC\n * const isValid = await client.verifyTin('C12345678901234', 'NRIC', '123456789012');\n * if (isValid) {\n * console.log('TIN is valid');\n * }\n *\n * // Validate TIN against Business Registration Number\n * const isValidBusiness = await client.verifyTin('C98765432109876', 'BRN', '123456-K');\n * ```\n *\n * @remarks\n * - Returns false if validation fails due to network errors or invalid credentials\n * - Debug mode provides error logging for troubleshooting validation failures\n * - This is a non-blocking validation that won't throw exceptions on failure\n */\n verifyTin(tin: string, idType: RegistrationType, idValue: string): Promise<boolean>;\n /**\n * Searches for a Tax Identification Number (TIN) using taxpayer information.\n *\n * This method allows searching for a TIN using either a taxpayer name or a combination\n * of identification type and value. The search is flexible and supports multiple\n * identification types including NRIC, ARMY, PASSPORT, and BRN.\n *\n * @param params - Search parameters object\n * @param params.taxpayerName - Optional name of the taxpayer to search for\n * @param params.idType - Optional type of ID to search with (NRIC, ARMY, PASSPORT, BRN)\n * @param params.idValue - Optional value of the ID to search with\n * @returns Promise resolving to TIN search response or standard error\n *\n * @example\n * ```typescript\n * // Search by taxpayer name\n * const result = await client.searchTin({ taxpayerName: 'John Doe' });\n * if ('tin' in result) {\n * console.log('Found TIN:', result.tin);\n * }\n *\n * // Search by ID type and value\n * const result = await client.searchTin({\n * idType: 'NRIC',\n * idValue: '123456789012'\n * });\n * ```\n *\n * @remarks\n * - Either taxpayerName or both idType and idValue must be provided\n * - Returns StandardError object if search criteria are invalid or inconclusive\n * - Debug mode provides detailed error logging for troubleshooting\n * - Search results are not guaranteed to be unique\n */\n searchTin(params: TinSearchParams): Promise<TinSearchResponse>;\n /**\n * Retrieves taxpayer information from a QR code.\n *\n * This method decodes a QR code containing taxpayer information and returns\n * detailed taxpayer data including TIN, name, contact details, and business information.\n *\n * @param qrCodeText - The QR code text to decode\n * @returns Promise resolving to taxpayer QR code response or standard error\n *\n * @example\n * ```typescript\n * // Get taxpayer info from QR code\n * const taxpayerInfo = await client.getTaxpayerQRCode('QR_CODE_TEXT');\n * if ('tin' in taxpayerInfo) {\n * console.log('Taxpayer TIN:', taxpayerInfo.tin);\n * console.log('Business Name:', taxpayerInfo.name);\n * console.log('Address:', taxpayerInfo.addressLine1);\n * }\n * ```\n *\n * @remarks\n * - QR code must be in the correct format specified by MyInvois\n * - Returns StandardError if QR code is invalid or cannot be decoded\n * - Debug mode provides detailed error logging\n */\n getTaxpayerQRCode(qrCodeText: string): Promise<TaxpayerQRCodeResponse>;\n /**\n * Performs an action on a document such as rejection or cancellation.\n *\n * This method allows updating the status of a document to either rejected or cancelled,\n * along with providing a reason for the action. Useful for managing document workflow\n * and maintaining audit trails.\n *\n * @param documentUid - The unique identifier of the document\n * @param status - The new status to set ('rejected' or 'cancelled')\n * @param reason - The reason for the status change\n * @returns Promise resolving to document action response containing UUID, status, and any errors\n *\n * @example\n * ```typescript\n * // Reject a document with reason\n * const result = await client.performDocumentAction(\n * 'doc-123',\n * 'rejected',\n * 'Invalid tax calculation'\n * );\n *\n * // Cancel a document\n * const result = await client.performDocumentAction(\n * 'doc-456',\n * 'cancelled',\n * 'Duplicate submission'\n * );\n * ```\n *\n * @remarks\n * - Only valid for documents in appropriate states\n * - Reason is required and should be descriptive\n * - Action is irreversible once completed\n * - Returns error if document cannot be found or action is invalid\n */\n performDocumentAction(documentUid: string, status: 'rejected' | 'cancelled', reason: string): Promise<{\n uuid: string;\n status: string;\n error: StandardError;\n }>;\n /**\n * Submits one or more e-invoice documents to the MyInvois platform for processing.\n *\n * This method digitally signs each document using the provided certificate and private key,\n * generates document hashes, encodes them for submission, and sends them to the platform.\n * The method includes comprehensive validation warnings for document size and count limits.\n *\n * @param documents - Array of InvoiceV1_1 documents to be submitted\n * @returns Promise resolving to submission response containing the submission data and HTTP status\n * @throws {Error} If PRIVATE_KEY or CERTIFICATE environment variables are missing\n * @throws {Error} If document signing, encoding, or API submission fails\n *\n * @example\n * ```typescript\n * // Submit a single invoice\n * const result = await client.submitDocument([invoiceData]);\n * console.log(result.data.submissionUid); // Track submission with this UID\n *\n * // Submit multiple invoices\n * const result = await client.submitDocument([invoice1, invoice2, invoice3]);\n * if (result.status === 202) {\n * console.log('Documents submitted successfully');\n * }\n * ```\n *\n * @remarks\n * - Requires PRIVATE_KEY and CERTIFICATE environment variables for document signing\n * - Each document is digitally signed with XML-DSIG before submission\n * - Documents are base64-encoded for transmission\n * - API limits: Max 100 documents per submission, 5MB total payload, 300KB per document\n * - Debug mode provides detailed logging of payload sizes and validation warnings\n * - Returns HTTP 202 for successful submissions that require processing\n */\n submitDocument(documents: InvoiceV1_1[]): Promise<{\n data: SubmissionResponse;\n status: number;\n }>;\n /**\n * Polls the MyInvois platform to get the current status of a document submission.\n *\n * This method continuously checks the submission status until it receives a final result\n * (Valid or Invalid) or reaches the maximum retry limit. It's designed to handle the\n * asynchronous nature of document processing on the MyInvois platform.\n *\n * @param submissionUid - The unique identifier of the submission to check\n * @param pollInterval - Time in milliseconds between status checks (default: 1000ms)\n * @param maxRetries - Maximum number of retry attempts (default: 10)\n * @returns Promise resolving to submission status object with document summary and any errors\n *\n * @example\n * ```typescript\n * // Check submission status with default polling\n * const result = await client.getSubmissionStatus('submission-uid-123');\n * if (result.status === 'Valid') {\n * console.log('All documents processed successfully');\n * console.log('Document summaries:', result.documentSummary);\n * }\n *\n * // Custom polling interval and retry count\n * const result = await client.getSubmissionStatus(\n * 'submission-uid-123',\n * 2000, // Poll every 2 seconds\n * 20 // Try up to 20 times\n * );\n * ```\n *\n * @remarks\n * - Automatically retries on network errors until maxRetries is reached\n * - Returns 'Invalid' status with timeout error if submission processing takes too long\n * - Debug mode provides detailed logging of polling attempts and responses\n * - Use reasonable poll intervals to avoid overwhelming the API\n */\n getSubmissionStatus(submissionUid: string, pollInterval?: number, maxRetries?: number): Promise<{\n status: SubmissionStatus;\n documentSummary?: DocumentSummary[];\n error?: {\n code: string;\n message: string | null;\n target: string;\n details: {\n code: string;\n message: string;\n target: string;\n }[];\n };\n }>;\n /**\n * Retrieves a document by its unique identifier with the raw document content.\n *\n * @param documentUid - The unique identifier of the document to retrieve\n * @returns Promise resolving to document summary with raw document content as a string\n * @throws {Error} If the document is not found or request fails\n *\n * @example\n * ```typescript\n * const document = await client.getDocument('doc-uuid-123');\n * console.log(document.document); // Raw XML/JSON content\n * console.log(document.uuid); // Document UUID\n * ```\n */\n getDocument(documentUid: string): Promise<DocumentSummary & {\n document: string;\n }>;\n /**\n * Retrieves detailed information about a document including validation results.\n *\n * @param documentUid - The unique identifier of the document to get details for\n * @returns Promise resolving to document summary with detailed validation results\n * @throws {Error} If the document is not found or request fails\n *\n * @example\n * ```typescript\n * const details = await client.getDocumentDetails('doc-uuid-123');\n * console.log(details.validationResults.status); // 'Valid' | 'Invalid' | 'Processing'\n * console.log(details.validationResults.validationSteps); // Array of validation step results\n * ```\n */\n getDocumentDetails(documentUid: string): Promise<DocumentSummary & {\n validationResults: {\n status: DocumentValidationResult;\n validationSteps: DocumentValidationStepResult[];\n };\n }>;\n /**\n * Searches for documents based on various filter criteria.\n *\n * @param params - Search parameters object\n * @param params.uuid - Optional specific document UUID to search for\n * @param params.submissionDateFrom - Required start date for submission date range (ISO date string)\n * @param params.submissionDateTo - Optional end date for submission date range (ISO date string)\n * @param params.pageSize - Optional number of results per page (default handled by API)\n * @param params.pageNo - Optional page number for pagination (0-based)\n * @param params.issueDateFrom - Optional start date for issue date range (ISO date string)\n * @param params.issueDateTo - Optional end date for issue date range (ISO date string)\n * @param params.invoiceDirection - Optional filter by invoice direction ('Sent' or 'Received')\n * @param params.status - Optional filter by document status\n * @param params.documentType - Optional filter by e-invoice type code\n * @param params.searchQuery - Optional text search across uuid, buyerTIN, supplierTIN, buyerName, supplierName, internalID, total\n * @returns Promise resolving to array of document summaries matching the search criteria\n * @throws {Error} If the search request fails\n *\n * @example\n * ```typescript\n * // Search for documents submitted in the last 30 days\n * const documents = await client.searchDocuments({\n * submissionDateFrom: '2024-01-01',\n * submissionDateTo: '2024-01-31',\n * status: 'Valid',\n * pageSize: 10\n * });\n *\n * // Search by supplier name\n * const supplierDocs = await client.searchDocuments({\n * submissionDateFrom: '2024-01-01',\n * searchQuery: 'ACME Corp',\n * invoiceDirection: 'Received'\n * });\n * ```\n */\n searchDocuments({ uuid, submissionDateFrom, submissionDateTo, pageSize, pageNo, issueDateFrom, issueDateTo, invoiceDirection, status, documentType, searchQuery, }: {\n uuid?: string;\n submissionDateFrom: string;\n submissionDateTo?: string;\n pageSize?: number;\n pageNo?: number;\n issueDateFrom?: string;\n issueDateTo?: string;\n invoiceDirection?: 'Sent' | 'Received';\n status?: DocumentStatus;\n documentType?: EInvoiceTypeCode;\n searchQuery?: string;\n }): Promise<DocumentSummary[]>;\n /**\n * Retrieves notifications from the MyInvois platform based on specified search criteria.\n *\n * This method allows you to search for system notifications, alerts, and messages\n * sent by the MyInvois platform regarding document processing, system updates,\n * or account-related information.\n *\n * @param params - Search parameters object for filtering notifications\n * @param params.dateFrom - Optional start date for notification date range (ISO date string)\n * @param params.dateTo - Optional end date for notification date range (ISO date string)\n * @param params.type - Optional notification type filter\n * @param params.language - Optional language preference for notifications\n * @param params.status - Optional notification status filter\n * @param params.pageNo - Optional page number for pagination (0-based)\n * @param params.pageSize - Optional number of results per page\n * @returns Promise resolving to notification response object or standard error\n *\n * @example\n * ```typescript\n * // Get all notifications from the last 7 days\n * const notifications = await client.getNotifications({\n * dateFrom: '2024-01-01',\n * dateTo: '2024-01-07',\n * pageSize: 20\n * });\n *\n * // Get unread notifications only\n * const unreadNotifications = await client.getNotifications({\n * status: 0, // Assuming 0 = unread\n * language: 'en'\n * });\n *\n * // Paginated notification retrieval\n * const firstPage = await client.getNotifications({\n * dateFrom: '2024-01-01',\n * pageNo: 0,\n * pageSize: 10\n * });\n * ```\n *\n * @remarks\n * - All parameters are optional, allowing flexible filtering\n * - Returns paginated results when pageNo and pageSize are specified\n * - Date parameters should be in ISO format (YYYY-MM-DD)\n * - May return StandardError object if the request fails\n */\n getNotifications({ dateFrom, dateTo, type, language, status, pageNo, pageSize, }: NotificationSearchParams): Promise<NotificationResponse>;\n getDocumentTypes(): Promise<DocumentTypesResponse>;\n /**\n * Retrieves detailed information about a specific document type from the MyInvois platform.\n *\n * This method fetches metadata and configuration details for a specific document type,\n * including supported versions, validation rules, and structural requirements.\n * Useful for understanding document format requirements before submission.\n *\n * @param id - The unique identifier of the document type to retrieve\n * @returns Promise resolving to document type response object or standard error\n *\n * @example\n * ```typescript\n * // Get details for e-invoice document type\n * const invoiceType = await client.getDocumentType(1);\n * if ('id' in invoiceType) {\n * console.log('Document type name:', invoiceType.name);\n * console.log('Available versions:', invoiceType.versionNumber);\n * console.log('Description:', invoiceType.description);\n * }\n *\n * // Handle potential errors\n * const documentType = await client.getDocumentType(999);\n * if ('error' in documentType) {\n * console.error('Failed to retrieve document type:', documentType.error.message);\n * }\n * ```\n *\n * @remarks\n * - Returns StandardError object if the document type ID doesn't exist\n * - Document type information includes validation schemas and business rules\n * - Use this method to discover supported document formats and versions\n * - Essential for understanding submission requirements for different document types\n */\n getDocumentType(id: number): Promise<DocumentTypeResponse>;\n /**\n * Retrieves detailed information about a specific version of a document type.\n *\n * This method fetches version-specific metadata, schema definitions, and validation rules\n * for a particular document type version. Essential for understanding the exact format\n * and requirements for document submission in a specific version.\n *\n * @param id - The unique identifier of the document type\n * @param versionId - The unique identifier of the specific version to retrieve\n * @returns Promise resolving to document type version response object or standard error\n *\n * @example\n * ```typescript\n * // Get specific version details for e-invoice\n * const invoiceV1_1 = await client.getDocumentTypeVersion(1, 1);\n * if ('id' in invoiceV1_1) {\n * console.log('Version number:', invoiceV1_1.versionNumber);\n * console.log('Schema:', invoiceV1_1.jsonSchema);\n * console.log('Status:', invoiceV1_1.status);\n * }\n *\n * // Compare different versions\n * const [v1_0, v1_1] = await Promise.all([\n * client.getDocumentTypeVersion(1, 0),\n * client.getDocumentTypeVersion(1, 1)\n * ]);\n *\n * // Handle version not found\n * const result = await client.getDocumentTypeVersion(1, 999);\n * if ('error' in result) {\n * console.error('Version not found:', result.error.message);\n * }\n * ```\n *\n * @remarks\n * - Returns StandardError object if document type ID or version ID doesn't exist\n * - Version information includes JSON schema for validation\n * - Different versions may have different validation rules and field requirements\n * - Use this to ensure your documents conform to the specific version requirements\n * - Version status indicates if the version is active, deprecated, or under development\n */\n getDocumentTypeVersion(id: number, versionId: number): Promise<DocumentTypeVersionResponse>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAW,iBAAiB;CAAC;CAAK,MAAE;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;CAAA,MAAA;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"notificationManagement-C_qrFwWL.cjs","names":["context: NotificationContext","params: NotificationSearchParams"],"sources":["../src/api/notificationManagement.ts"],"sourcesContent":["import type {\n NotificationResponse,\n NotificationSearchParams,\n StandardError,\n Fetch,\n} from '../types'\n\ninterface NotificationContext {\n fetch: Fetch\n}\n\nexport async function getNotifications(\n context: NotificationContext,\n params: NotificationSearchParams,\n): Promise<NotificationResponse | StandardError> {\n const { fetch } = context\n const { dateFrom, dateTo, type, language, status, pageNo, pageSize } = params\n\n const queryParams = new URLSearchParams()\n if (dateFrom) queryParams.set('dateFrom', dateFrom)\n if (dateTo) queryParams.set('dateTo', dateTo)\n if (type) queryParams.set('type', type.toString())\n if (language) queryParams.set('language', language)\n if (status) queryParams.set('status', status.toString())\n if (pageNo) queryParams.set('pageNo', pageNo.toString())\n if (pageSize) queryParams.set('pageSize', pageSize.toString())\n\n const response = await fetch(\n `/api/v1.0/notifications/taxpayer?${queryParams.toString()}`,\n )\n\n const data = (await response.json()) as NotificationResponse\n\n return data\n}\n"],"mappings":";;AAWA,eAAsB,iBACpBA,SACAC,QAC+C;CAC/C,MAAM,EAAE,OAAO,GAAG;CAClB,MAAM,EAAE,UAAU,QAAQ,MAAM,UAAU,QAAQ,QAAQ,UAAU,GAAG;CAEvE,MAAM,cAAc,IAAI;AACxB,KAAI,SAAU,aAAY,IAAI,YAAY,SAAS;AACnD,KAAI,OAAQ,aAAY,IAAI,UAAU,OAAO;AAC7C,KAAI,KAAM,aAAY,IAAI,QAAQ,KAAK,UAAU,CAAC;AAClD,KAAI,SAAU,aAAY,IAAI,YAAY,SAAS;AACnD,KAAI,OAAQ,aAAY,IAAI,UAAU,OAAO,UAAU,CAAC;AACxD,KAAI,OAAQ,aAAY,IAAI,UAAU,OAAO,UAAU,CAAC;AACxD,KAAI,SAAU,aAAY,IAAI,YAAY,SAAS,UAAU,CAAC;CAE9D,MAAM,WAAW,MAAM,OACpB,mCAAmC,YAAY,UAAU,CAAC,EAC5D;CAED,MAAM,OAAQ,MAAM,SAAS,MAAM;AAEnC,QAAO;AACR"}
1
+ {"version":3,"file":"notificationManagement-C_qrFwWL.cjs","names":["context: NotificationContext","params: NotificationSearchParams"],"sources":["../src/api/notificationManagement.ts"],"sourcesContent":["import type {\n Fetch,\n NotificationResponse,\n NotificationSearchParams,\n} from '../types'\n\ninterface NotificationContext {\n fetch: Fetch\n}\n\nexport async function getNotifications(\n context: NotificationContext,\n params: NotificationSearchParams,\n): Promise<NotificationResponse> {\n const { fetch } = context\n const { dateFrom, dateTo, type, language, status, pageNo, pageSize } = params\n\n const queryParams = new URLSearchParams()\n if (dateFrom) queryParams.set('dateFrom', dateFrom)\n if (dateTo) queryParams.set('dateTo', dateTo)\n if (type) queryParams.set('type', type.toString())\n if (language) queryParams.set('language', language)\n if (status) queryParams.set('status', status.toString())\n if (pageNo) queryParams.set('pageNo', pageNo.toString())\n if (pageSize) queryParams.set('pageSize', pageSize.toString())\n\n const response = await fetch(\n `/api/v1.0/notifications/taxpayer?${queryParams.toString()}`,\n )\n\n const data = (await response.json()) as NotificationResponse\n\n return data\n}\n"],"mappings":";;AAUA,eAAsB,iBACpBA,SACAC,QAC+B;CAC/B,MAAM,EAAE,OAAO,GAAG;CAClB,MAAM,EAAE,UAAU,QAAQ,MAAM,UAAU,QAAQ,QAAQ,UAAU,GAAG;CAEvE,MAAM,cAAc,IAAI;AACxB,KAAI,SAAU,aAAY,IAAI,YAAY,SAAS;AACnD,KAAI,OAAQ,aAAY,IAAI,UAAU,OAAO;AAC7C,KAAI,KAAM,aAAY,IAAI,QAAQ,KAAK,UAAU,CAAC;AAClD,KAAI,SAAU,aAAY,IAAI,YAAY,SAAS;AACnD,KAAI,OAAQ,aAAY,IAAI,UAAU,OAAO,UAAU,CAAC;AACxD,KAAI,OAAQ,aAAY,IAAI,UAAU,OAAO,UAAU,CAAC;AACxD,KAAI,SAAU,aAAY,IAAI,YAAY,SAAS,UAAU,CAAC;CAE9D,MAAM,WAAW,MAAM,OACpB,mCAAmC,YAAY,UAAU,CAAC,EAC5D;CAED,MAAM,OAAQ,MAAM,SAAS,MAAM;AAEnC,QAAO;AACR"}
@@ -170,4 +170,4 @@ interface IssuerDigitalSignature {
170
170
  }
171
171
  //#endregion
172
172
  export { CanonicalizationMethod, Cert, CertDigest, DigestMethod, IssuerDigitalSignature, IssuerSerial, KeyInfo, QualifyingProperties, Reference, SignatureMethod, SignedInfo, SignedProperties, SignedSignatureProperties, SigningCertificate, Transform, X509Data };
173
- //# sourceMappingURL=signatures-hFbt_std.d.cts.map
173
+ //# sourceMappingURL=signatures-CyDSZr_e.d.cts.map
@@ -59,4 +59,4 @@ interface State {
59
59
  }
60
60
  //#endregion
61
61
  export { State, StateCode, StateCodeEnum };
62
- //# sourceMappingURL=state-codes-BlILGZ9d.d.cts.map
62
+ //# sourceMappingURL=state-codes-u3ppueWo.d.cts.map
@@ -39,4 +39,4 @@ interface TaxType {
39
39
  }
40
40
  //#endregion
41
41
  export { TaxType, TaxTypeCode, TaxTypeCodeEnum };
42
- //# sourceMappingURL=tax-types-B5sQ8UyN.d.cts.map
42
+ //# sourceMappingURL=tax-types-fu5Q6dic.d.cts.map
@@ -1,5 +1,5 @@
1
1
  import { MSICCode } from "./msic-codes-CiPeemFK.js";
2
- import { RegistrationType } from "./documents-BgXt86Qp.js";
2
+ import { RegistrationType } from "./documents-zzL50wnG.js";
3
3
 
4
4
  //#region src/types/taxpayer.d.ts
5
5
  interface TaxpayerQRCodeResponse {
@@ -1,5 +1,5 @@
1
1
  import { MSICCode } from "./msic-codes-CIKdPqag.cjs";
2
- import { RegistrationType } from "./documents-BqM9qOnB.cjs";
2
+ import { RegistrationType } from "./documents-DCOYxz61.cjs";
3
3
 
4
4
  //#region src/types/taxpayer.d.ts
5
5
  interface TaxpayerQRCodeResponse {
@@ -32,4 +32,4 @@ interface TinSearchResponse {
32
32
  }
33
33
  //#endregion
34
34
  export { TaxpayerQRCodeResponse, TinSearchParams, TinSearchResponse };
35
- //# sourceMappingURL=taxpayer-q6fVtwaA.d.cts.map
35
+ //# sourceMappingURL=taxpayer-aaXyVf7B.d.cts.map
@@ -14,20 +14,7 @@ async function tinSearch(context, params) {
14
14
  const queryString = queryParams.toString();
15
15
  try {
16
16
  const response = await fetch(`/api/v1.0/taxpayer/search/tin?${queryString}`, { method: "GET" });
17
- if (response.status === 200) return await response.json();
18
- if (response.status === 400) {
19
- const errorData$1 = await response.json();
20
- if (debug) console.error("TIN search failed - search criteria not conclusive or invalid parameters:", errorData$1);
21
- return errorData$1;
22
- }
23
- if (response.status === 404) {
24
- const errorData$1 = await response.json();
25
- if (debug) console.error("TIN search failed - no TIN found for given search criteria:", errorData$1);
26
- return errorData$1;
27
- }
28
- const errorData = await response.json();
29
- if (debug) console.error("TIN search failed with status:", response.status, errorData);
30
- return errorData;
17
+ return await response.json();
31
18
  } catch (error) {
32
19
  if (debug) console.error("TIN search error:", error);
33
20
  throw error;
@@ -70,4 +57,4 @@ Object.defineProperty(exports, 'verifyTin', {
70
57
  return verifyTin;
71
58
  }
72
59
  });
73
- //# sourceMappingURL=taxpayerValidation-DdeXCvPT.cjs.map
60
+ //# sourceMappingURL=taxpayerValidation-CSuifcY1.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"taxpayerValidation-CSuifcY1.cjs","names":["context: TaxpayerContext","params: TinSearchParams","tin: string","idType: RegistrationType","idValue: string","qrCodeText: string"],"sources":["../src/api/taxpayerValidation.ts"],"sourcesContent":["import type {\n Fetch,\n RegistrationType,\n TaxpayerQRCodeResponse,\n TinSearchParams,\n TinSearchResponse,\n} from '../types'\n\ninterface TaxpayerContext {\n fetch: Fetch\n debug: boolean\n}\n\nexport async function tinSearch(\n context: TaxpayerContext,\n params: TinSearchParams,\n): Promise<TinSearchResponse> {\n const { fetch, debug } = context\n const { taxpayerName, idType, idValue } = params\n\n // Validate input parameters according to API requirements\n if (!taxpayerName && (!idType || !idValue)) {\n throw new Error(\n 'Either taxpayerName must be provided, or both idType and idValue must be provided',\n )\n }\n\n if ((idType && !idValue) || (!idType && idValue)) {\n throw new Error('idType and idValue must be provided together')\n }\n\n // Build query parameters\n const queryParams = new URLSearchParams()\n\n if (taxpayerName) {\n queryParams.append('taxpayerName', taxpayerName)\n }\n\n if (idType && idValue) {\n queryParams.append('idType', idType)\n queryParams.append('idValue', idValue)\n }\n\n const queryString = queryParams.toString()\n\n try {\n const response = await fetch(\n `/api/v1.0/taxpayer/search/tin?${queryString}`,\n {\n method: 'GET',\n },\n )\n return (await response.json()) as TinSearchResponse\n } catch (error) {\n if (debug) {\n console.error('TIN search error:', error)\n }\n throw error\n }\n}\n\nexport async function verifyTin(\n context: TaxpayerContext,\n tin: string,\n idType: RegistrationType,\n idValue: string,\n): Promise<boolean> {\n const { fetch, debug } = context\n\n try {\n const response = await fetch(\n `/api/v1.0/taxpayer/validate/${tin}?idType=${idType}&idValue=${idValue}`,\n {\n method: 'GET',\n },\n )\n\n if (response.status === 200) {\n return true\n }\n\n return false\n } catch (error) {\n if (debug) {\n console.error(error)\n }\n return false\n }\n}\n\nexport async function taxpayerQRCode(\n context: TaxpayerContext,\n qrCodeText: string,\n): Promise<TaxpayerQRCodeResponse> {\n const { fetch } = context\n\n const base64EncodedQRCodeText = Buffer.from(qrCodeText).toString('base64')\n\n const response = await fetch(\n `/api/v1.0/taxpayer/qrcodeinfo/${base64EncodedQRCodeText}`,\n )\n\n return response.json()\n}\n"],"mappings":";;AAaA,eAAsB,UACpBA,SACAC,QAC4B;CAC5B,MAAM,EAAE,OAAO,OAAO,GAAG;CACzB,MAAM,EAAE,cAAc,QAAQ,SAAS,GAAG;AAG1C,MAAK,kBAAkB,WAAW,SAChC,OAAM,IAAI,MACR;AAIJ,KAAK,WAAW,YAAc,UAAU,QACtC,OAAM,IAAI,MAAM;CAIlB,MAAM,cAAc,IAAI;AAExB,KAAI,aACF,aAAY,OAAO,gBAAgB,aAAa;AAGlD,KAAI,UAAU,SAAS;AACrB,cAAY,OAAO,UAAU,OAAO;AACpC,cAAY,OAAO,WAAW,QAAQ;CACvC;CAED,MAAM,cAAc,YAAY,UAAU;AAE1C,KAAI;EACF,MAAM,WAAW,MAAM,OACpB,gCAAgC,YAAY,GAC7C,EACE,QAAQ,MACT,EACF;AACD,SAAQ,MAAM,SAAS,MAAM;CAC9B,SAAQ,OAAO;AACd,MAAI,MACF,SAAQ,MAAM,qBAAqB,MAAM;AAE3C,QAAM;CACP;AACF;AAED,eAAsB,UACpBD,SACAE,KACAC,QACAC,SACkB;CAClB,MAAM,EAAE,OAAO,OAAO,GAAG;AAEzB,KAAI;EACF,MAAM,WAAW,MAAM,OACpB,8BAA8B,IAAI,UAAU,OAAO,WAAW,QAAQ,GACvE,EACE,QAAQ,MACT,EACF;AAED,MAAI,SAAS,WAAW,IACtB,QAAO;AAGT,SAAO;CACR,SAAQ,OAAO;AACd,MAAI,MACF,SAAQ,MAAM,MAAM;AAEtB,SAAO;CACR;AACF;AAED,eAAsB,eACpBJ,SACAK,YACiC;CACjC,MAAM,EAAE,OAAO,GAAG;CAElB,MAAM,0BAA0B,OAAO,KAAK,WAAW,CAAC,SAAS,SAAS;CAE1E,MAAM,WAAW,MAAM,OACpB,gCAAgC,wBAAwB,EAC1D;AAED,QAAO,SAAS,MAAM;AACvB"}
@@ -13,20 +13,7 @@ async function tinSearch(context, params) {
13
13
  const queryString = queryParams.toString();
14
14
  try {
15
15
  const response = await fetch(`/api/v1.0/taxpayer/search/tin?${queryString}`, { method: "GET" });
16
- if (response.status === 200) return await response.json();
17
- if (response.status === 400) {
18
- const errorData$1 = await response.json();
19
- if (debug) console.error("TIN search failed - search criteria not conclusive or invalid parameters:", errorData$1);
20
- return errorData$1;
21
- }
22
- if (response.status === 404) {
23
- const errorData$1 = await response.json();
24
- if (debug) console.error("TIN search failed - no TIN found for given search criteria:", errorData$1);
25
- return errorData$1;
26
- }
27
- const errorData = await response.json();
28
- if (debug) console.error("TIN search failed with status:", response.status, errorData);
29
- return errorData;
16
+ return await response.json();
30
17
  } catch (error) {
31
18
  if (debug) console.error("TIN search error:", error);
32
19
  throw error;
@@ -1,4 +1,5 @@
1
1
  import "../classification-codes-B1D5xbq5.js";
2
+ import "../country-code-D42kAyNH.js";
2
3
  import "../currencies-CDveO_yz.js";
3
4
  import "../e-invoice-BxNC6V_j.js";
4
5
  import "../0X-DZnB0al0.js";
@@ -12,7 +13,7 @@ import "../7X-Ckv9bbzG.js";
12
13
  import "../8X-C37BJTl6.js";
13
14
  import "../9X-_XRgT2-_.js";
14
15
  import "../msic-codes-CiPeemFK.js";
15
- import "../signatures-DOKNMiZI.js";
16
- import "../tax-types-ieqw5Ze7.js";
17
- import { Address, Buyer, CompleteInvoice, DocumentStatus, DocumentSummary, DocumentTypeResponse, DocumentTypeVersion, DocumentTypeVersionResponse, DocumentTypesResponse, DocumentValidationResult, DocumentValidationStepResult, FinalDocumentData, GetSubmissionResponse, InvoiceLineItem, InvoiceSubmission, InvoiceV1_1, LegalMonetaryTotal, RegistrationType, ResponseDocument, SignedInfoObject, SignedInvoiceSubmission, SignedPropertiesData, SignedPropertiesObject, SigningCredentials, StandardError, SubmissionResponse, SubmissionStatus, Supplier, TaxCategory, TaxSubtotal, TaxTotal, UBLDocument, WorkflowParameter } from "../documents-BgXt86Qp.js";
16
+ import "../tax-types-BskcyNBv.js";
17
+ import "../state-codes-BaGjZcA8.js";
18
+ import { Address, Buyer, CompleteInvoice, DocumentStatus, DocumentSummary, DocumentTypeResponse, DocumentTypeVersion, DocumentTypeVersionResponse, DocumentTypesResponse, DocumentValidationResult, DocumentValidationStepResult, FinalDocumentData, GetSubmissionResponse, InvoiceLineItem, InvoiceSubmission, InvoiceV1_1, LegalMonetaryTotal, RegistrationType, ResponseDocument, SignedInfoObject, SignedInvoiceSubmission, SignedPropertiesData, SignedPropertiesObject, SigningCredentials, StandardError, SubmissionResponse, SubmissionStatus, Supplier, TaxCategory, TaxSubtotal, TaxTotal, UBLDocument, WorkflowParameter } from "../documents-zzL50wnG.js";
18
19
  export { Address, Buyer, CompleteInvoice, DocumentStatus, DocumentSummary, DocumentTypeResponse, DocumentTypeVersion, DocumentTypeVersionResponse, DocumentTypesResponse, DocumentValidationResult, DocumentValidationStepResult, FinalDocumentData, GetSubmissionResponse, InvoiceLineItem, InvoiceSubmission, InvoiceV1_1, LegalMonetaryTotal, RegistrationType, ResponseDocument, SignedInfoObject, SignedInvoiceSubmission, SignedPropertiesData, SignedPropertiesObject, SigningCredentials, StandardError, SubmissionResponse, SubmissionStatus, Supplier, TaxCategory, TaxSubtotal, TaxTotal, UBLDocument, WorkflowParameter };
@@ -13,9 +13,9 @@ import "../7X-Ckv9bbzG.js";
13
13
  import "../8X-C37BJTl6.js";
14
14
  import "../9X-_XRgT2-_.js";
15
15
  import { MSICCode } from "../msic-codes-CiPeemFK.js";
16
- import { CanonicalizationMethod, Cert, CertDigest, DigestMethod, IssuerDigitalSignature, IssuerSerial, KeyInfo, QualifyingProperties, Reference, SignatureMethod, SignedInfo, SignedProperties, SignedSignatureProperties, SigningCertificate, Transform, X509Data } from "../signatures-DOKNMiZI.js";
17
- import { TaxType, TaxTypeCode, TaxTypeCodeEnum } from "../tax-types-ieqw5Ze7.js";
18
- import { Address, Buyer, CompleteInvoice, DocumentStatus, DocumentSummary, DocumentTypeResponse, DocumentTypeVersion, DocumentTypeVersionResponse, DocumentTypesResponse, DocumentValidationResult, DocumentValidationStepResult, FinalDocumentData, GetSubmissionResponse, InvoiceLineItem, InvoiceSubmission, InvoiceV1_1, LegalMonetaryTotal, RegistrationType, ResponseDocument, SignedInfoObject, SignedInvoiceSubmission, SignedPropertiesData, SignedPropertiesObject, SigningCredentials, StandardError, SubmissionResponse, SubmissionStatus, Supplier, TaxCategory, TaxSubtotal, TaxTotal, UBLDocument, WorkflowParameter } from "../documents-BgXt86Qp.js";
16
+ import { TaxType, TaxTypeCode, TaxTypeCodeEnum } from "../tax-types-BskcyNBv.js";
17
+ import { State, StateCode, StateCodeEnum } from "../state-codes-BaGjZcA8.js";
18
+ import { Address, Buyer, CompleteInvoice, DocumentStatus, DocumentSummary, DocumentTypeResponse, DocumentTypeVersion, DocumentTypeVersionResponse, DocumentTypesResponse, DocumentValidationResult, DocumentValidationStepResult, FinalDocumentData, GetSubmissionResponse, InvoiceLineItem, InvoiceSubmission, InvoiceV1_1, LegalMonetaryTotal, RegistrationType, ResponseDocument, SignedInfoObject, SignedInvoiceSubmission, SignedPropertiesData, SignedPropertiesObject, SigningCredentials, StandardError, SubmissionResponse, SubmissionStatus, Supplier, TaxCategory, TaxSubtotal, TaxTotal, UBLDocument, WorkflowParameter } from "../documents-zzL50wnG.js";
19
19
  import { PaymentMode, PaymentModeCode, PaymentModeCodeEnum } from "../payment-modes-NpE3OcCV.js";
20
20
  import "../1X-C72Wa4pk.js";
21
21
  import "../2X-CH89y3Af.js";
@@ -53,9 +53,9 @@ import "../YX-F34sJ7Ik.js";
53
53
  import "../ZX-CDQOfsHh.js";
54
54
  import "../XX-DOA-10JW.js";
55
55
  import { UnitType, UnitTypeCode } from "../unit-types-VgYXIwTT.js";
56
- import { State, StateCode, StateCodeEnum } from "../state-codes-VOFWhHA0.js";
56
+ import { CanonicalizationMethod, Cert, CertDigest, DigestMethod, IssuerDigitalSignature, IssuerSerial, KeyInfo, QualifyingProperties, Reference, SignatureMethod, SignedInfo, SignedProperties, SignedSignatureProperties, SigningCertificate, Transform, X509Data } from "../signatures-C-nCPDqt.js";
57
57
  import { Notification, NotificationDeliveryAttempt, NotificationMetadata, NotificationResponse, NotificationSearchParams, NotificationStatus, NotificationStatusEnum, NotificationType, NotificationTypeEnum } from "../notifications-B4l_qRj7.js";
58
- import { TaxpayerQRCodeResponse, TinSearchParams, TinSearchResponse } from "../taxpayer-fpGIHNXp.js";
58
+ import { TaxpayerQRCodeResponse, TinSearchParams, TinSearchResponse } from "../taxpayer-CxAVm7lJ.js";
59
59
  import { Fetch } from "../utils-B3mo51Zp.js";
60
60
  import { ClientCredentials, TokenResponse } from "../index-FTgB2nM6.js";
61
61
  export { Address, Buyer, CanonicalizationMethod, Cert, CertDigest, Classification, ClassificationCode, ClassificationCodeEnum, ClientCredentials, CompleteInvoice, Country, CountryCode, CountryCodeEnum, CountryNameEnum, Currency, CurrencyCode, CurrencyCodeEnum, DigestMethod, DocumentStatus, DocumentSummary, DocumentTypeResponse, DocumentTypeVersion, DocumentTypeVersionResponse, DocumentTypesResponse, DocumentValidationResult, DocumentValidationStepResult, EInvoiceType, EInvoiceTypeCode, EInvoiceTypeCodeEnum, Fetch, FinalDocumentData, GetSubmissionResponse, InvoiceLineItem, InvoiceSubmission, InvoiceV1_1, IssuerDigitalSignature, IssuerSerial, KeyInfo, LegalMonetaryTotal, MSICCode, Notification, NotificationDeliveryAttempt, NotificationMetadata, NotificationResponse, NotificationSearchParams, NotificationStatus, NotificationStatusEnum, NotificationType, NotificationTypeEnum, PaymentMode, PaymentModeCode, PaymentModeCodeEnum, QualifyingProperties, Reference, RegistrationType, ResponseDocument, SignatureMethod, SignedInfo, SignedInfoObject, SignedInvoiceSubmission, SignedProperties, SignedPropertiesData, SignedPropertiesObject, SignedSignatureProperties, SigningCertificate, SigningCredentials, StandardError, State, StateCode, StateCodeEnum, SubmissionResponse, SubmissionStatus, Supplier, TaxCategory, TaxSubtotal, TaxTotal, TaxType, TaxTypeCode, TaxTypeCodeEnum, TaxpayerQRCodeResponse, TinSearchParams, TinSearchResponse, TokenResponse, Transform, UBLDocument, UnitType, UnitTypeCode, WorkflowParameter, X509Data };
@@ -1,2 +1,2 @@
1
- import { CanonicalizationMethod, Cert, CertDigest, DigestMethod, IssuerDigitalSignature, IssuerSerial, KeyInfo, QualifyingProperties, Reference, SignatureMethod, SignedInfo, SignedProperties, SignedSignatureProperties, SigningCertificate, Transform, X509Data } from "../signatures-DOKNMiZI.js";
1
+ import { CanonicalizationMethod, Cert, CertDigest, DigestMethod, IssuerDigitalSignature, IssuerSerial, KeyInfo, QualifyingProperties, Reference, SignatureMethod, SignedInfo, SignedProperties, SignedSignatureProperties, SigningCertificate, Transform, X509Data } from "../signatures-C-nCPDqt.js";
2
2
  export { CanonicalizationMethod, Cert, CertDigest, DigestMethod, IssuerDigitalSignature, IssuerSerial, KeyInfo, QualifyingProperties, Reference, SignatureMethod, SignedInfo, SignedProperties, SignedSignatureProperties, SigningCertificate, Transform, X509Data };
@@ -1,2 +1,2 @@
1
- import { State, StateCode, StateCodeEnum } from "../state-codes-VOFWhHA0.js";
1
+ import { State, StateCode, StateCodeEnum } from "../state-codes-BaGjZcA8.js";
2
2
  export { State, StateCode, StateCodeEnum };
@@ -1,2 +1,2 @@
1
- import { TaxType, TaxTypeCode, TaxTypeCodeEnum } from "../tax-types-ieqw5Ze7.js";
1
+ import { TaxType, TaxTypeCode, TaxTypeCodeEnum } from "../tax-types-BskcyNBv.js";
2
2
  export { TaxType, TaxTypeCode, TaxTypeCodeEnum };
@@ -1,4 +1,5 @@
1
1
  import "../classification-codes-B1D5xbq5.js";
2
+ import "../country-code-D42kAyNH.js";
2
3
  import "../currencies-CDveO_yz.js";
3
4
  import "../e-invoice-BxNC6V_j.js";
4
5
  import "../0X-DZnB0al0.js";
@@ -12,8 +13,8 @@ import "../7X-Ckv9bbzG.js";
12
13
  import "../8X-C37BJTl6.js";
13
14
  import "../9X-_XRgT2-_.js";
14
15
  import "../msic-codes-CiPeemFK.js";
15
- import "../signatures-DOKNMiZI.js";
16
- import "../tax-types-ieqw5Ze7.js";
17
- import "../documents-BgXt86Qp.js";
18
- import { TaxpayerQRCodeResponse, TinSearchParams, TinSearchResponse } from "../taxpayer-fpGIHNXp.js";
16
+ import "../tax-types-BskcyNBv.js";
17
+ import "../state-codes-BaGjZcA8.js";
18
+ import "../documents-zzL50wnG.js";
19
+ import { TaxpayerQRCodeResponse, TinSearchParams, TinSearchResponse } from "../taxpayer-CxAVm7lJ.js";
19
20
  export { TaxpayerQRCodeResponse, TinSearchParams, TinSearchResponse };
@@ -13,9 +13,9 @@ import "../7X-Ckv9bbzG.js";
13
13
  import "../8X-C37BJTl6.js";
14
14
  import "../9X-_XRgT2-_.js";
15
15
  import "../msic-codes-CiPeemFK.js";
16
- import "../signatures-DOKNMiZI.js";
17
- import "../tax-types-ieqw5Ze7.js";
18
- import { CompleteInvoice, InvoiceSubmission, InvoiceV1_1, SignedInfoObject, SignedPropertiesObject, SigningCredentials, UBLDocument } from "../documents-BgXt86Qp.js";
16
+ import "../tax-types-BskcyNBv.js";
17
+ import "../state-codes-BaGjZcA8.js";
18
+ import { CompleteInvoice, InvoiceSubmission, InvoiceV1_1, SignedInfoObject, SignedPropertiesObject, SigningCredentials, UBLDocument } from "../documents-zzL50wnG.js";
19
19
  import "../payment-modes-NpE3OcCV.js";
20
20
  import "../1X-C72Wa4pk.js";
21
21
  import "../2X-CH89y3Af.js";
@@ -53,9 +53,9 @@ import "../YX-F34sJ7Ik.js";
53
53
  import "../ZX-CDQOfsHh.js";
54
54
  import "../XX-DOA-10JW.js";
55
55
  import "../unit-types-VgYXIwTT.js";
56
- import "../state-codes-VOFWhHA0.js";
56
+ import "../signatures-C-nCPDqt.js";
57
57
  import "../notifications-B4l_qRj7.js";
58
- import "../taxpayer-fpGIHNXp.js";
58
+ import "../taxpayer-CxAVm7lJ.js";
59
59
  import "../utils-B3mo51Zp.js";
60
60
  import "../index-FTgB2nM6.js";
61
61
 
@@ -13,9 +13,9 @@ import "../7X-Ckv9bbzG.js";
13
13
  import "../8X-C37BJTl6.js";
14
14
  import "../9X-_XRgT2-_.js";
15
15
  import "../msic-codes-CiPeemFK.js";
16
- import "../signatures-DOKNMiZI.js";
17
- import "../tax-types-ieqw5Ze7.js";
18
- import { InvoiceV1_1 } from "../documents-BgXt86Qp.js";
16
+ import "../tax-types-BskcyNBv.js";
17
+ import "../state-codes-BaGjZcA8.js";
18
+ import { InvoiceV1_1 } from "../documents-zzL50wnG.js";
19
19
  import "../payment-modes-NpE3OcCV.js";
20
20
  import "../1X-C72Wa4pk.js";
21
21
  import "../2X-CH89y3Af.js";
@@ -53,9 +53,9 @@ import "../YX-F34sJ7Ik.js";
53
53
  import "../ZX-CDQOfsHh.js";
54
54
  import "../XX-DOA-10JW.js";
55
55
  import "../unit-types-VgYXIwTT.js";
56
- import "../state-codes-VOFWhHA0.js";
56
+ import "../signatures-C-nCPDqt.js";
57
57
  import "../notifications-B4l_qRj7.js";
58
- import "../taxpayer-fpGIHNXp.js";
58
+ import "../taxpayer-CxAVm7lJ.js";
59
59
  import "../utils-B3mo51Zp.js";
60
60
  import "../index-FTgB2nM6.js";
61
61
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ripwords/myinvois-client",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "MyInvois client",
5
5
  "scripts": {
6
6
  "build": "tsdown",
@@ -1 +0,0 @@
1
- {"version":3,"file":"taxpayerValidation-DdeXCvPT.cjs","names":["context: TaxpayerContext","params: TinSearchParams","errorData","tin: string","idType: RegistrationType","idValue: string","qrCodeText: string"],"sources":["../src/api/taxpayerValidation.ts"],"sourcesContent":["import type {\n Fetch,\n RegistrationType,\n StandardError,\n TaxpayerQRCodeResponse,\n TinSearchParams,\n TinSearchResponse,\n} from '../types'\n\ninterface TaxpayerContext {\n fetch: Fetch\n debug: boolean\n}\n\nexport async function tinSearch(\n context: TaxpayerContext,\n params: TinSearchParams,\n): Promise<TinSearchResponse | StandardError> {\n const { fetch, debug } = context\n const { taxpayerName, idType, idValue } = params\n\n // Validate input parameters according to API requirements\n if (!taxpayerName && (!idType || !idValue)) {\n throw new Error(\n 'Either taxpayerName must be provided, or both idType and idValue must be provided',\n )\n }\n\n if ((idType && !idValue) || (!idType && idValue)) {\n throw new Error('idType and idValue must be provided together')\n }\n\n // Build query parameters\n const queryParams = new URLSearchParams()\n\n if (taxpayerName) {\n queryParams.append('taxpayerName', taxpayerName)\n }\n\n if (idType && idValue) {\n queryParams.append('idType', idType)\n queryParams.append('idValue', idValue)\n }\n\n const queryString = queryParams.toString()\n\n try {\n const response = await fetch(\n `/api/v1.0/taxpayer/search/tin?${queryString}`,\n {\n method: 'GET',\n },\n )\n\n if (response.status === 200) {\n return (await response.json()) as TinSearchResponse\n }\n\n // Handle specific error cases mentioned in the API documentation\n if (response.status === 400) {\n const errorData = (await response.json()) as StandardError\n if (debug) {\n console.error(\n 'TIN search failed - search criteria not conclusive or invalid parameters:',\n errorData,\n )\n }\n return errorData\n }\n\n if (response.status === 404) {\n const errorData = (await response.json()) as StandardError\n if (debug) {\n console.error(\n 'TIN search failed - no TIN found for given search criteria:',\n errorData,\n )\n }\n return errorData\n }\n\n // Handle other error status codes\n const errorData = (await response.json()) as StandardError\n if (debug) {\n console.error(\n 'TIN search failed with status:',\n response.status,\n errorData,\n )\n }\n return errorData\n } catch (error) {\n if (debug) {\n console.error('TIN search error:', error)\n }\n throw error\n }\n}\n\nexport async function verifyTin(\n context: TaxpayerContext,\n tin: string,\n idType: RegistrationType,\n idValue: string,\n): Promise<boolean> {\n const { fetch, debug } = context\n\n try {\n const response = await fetch(\n `/api/v1.0/taxpayer/validate/${tin}?idType=${idType}&idValue=${idValue}`,\n {\n method: 'GET',\n },\n )\n\n if (response.status === 200) {\n return true\n }\n\n return false\n } catch (error) {\n if (debug) {\n console.error(error)\n }\n return false\n }\n}\n\nexport async function taxpayerQRCode(\n context: TaxpayerContext,\n qrCodeText: string,\n): Promise<TaxpayerQRCodeResponse | StandardError> {\n const { fetch } = context\n\n const base64EncodedQRCodeText = Buffer.from(qrCodeText).toString('base64')\n\n const response = await fetch(\n `/api/v1.0/taxpayer/qrcodeinfo/${base64EncodedQRCodeText}`,\n )\n\n return response.json()\n}\n"],"mappings":";;AAcA,eAAsB,UACpBA,SACAC,QAC4C;CAC5C,MAAM,EAAE,OAAO,OAAO,GAAG;CACzB,MAAM,EAAE,cAAc,QAAQ,SAAS,GAAG;AAG1C,MAAK,kBAAkB,WAAW,SAChC,OAAM,IAAI,MACR;AAIJ,KAAK,WAAW,YAAc,UAAU,QACtC,OAAM,IAAI,MAAM;CAIlB,MAAM,cAAc,IAAI;AAExB,KAAI,aACF,aAAY,OAAO,gBAAgB,aAAa;AAGlD,KAAI,UAAU,SAAS;AACrB,cAAY,OAAO,UAAU,OAAO;AACpC,cAAY,OAAO,WAAW,QAAQ;CACvC;CAED,MAAM,cAAc,YAAY,UAAU;AAE1C,KAAI;EACF,MAAM,WAAW,MAAM,OACpB,gCAAgC,YAAY,GAC7C,EACE,QAAQ,MACT,EACF;AAED,MAAI,SAAS,WAAW,IACtB,QAAQ,MAAM,SAAS,MAAM;AAI/B,MAAI,SAAS,WAAW,KAAK;GAC3B,MAAMC,cAAa,MAAM,SAAS,MAAM;AACxC,OAAI,MACF,SAAQ,MACN,6EACAA,YACD;AAEH,UAAOA;EACR;AAED,MAAI,SAAS,WAAW,KAAK;GAC3B,MAAMA,cAAa,MAAM,SAAS,MAAM;AACxC,OAAI,MACF,SAAQ,MACN,+DACAA,YACD;AAEH,UAAOA;EACR;EAGD,MAAM,YAAa,MAAM,SAAS,MAAM;AACxC,MAAI,MACF,SAAQ,MACN,kCACA,SAAS,QACT,UACD;AAEH,SAAO;CACR,SAAQ,OAAO;AACd,MAAI,MACF,SAAQ,MAAM,qBAAqB,MAAM;AAE3C,QAAM;CACP;AACF;AAED,eAAsB,UACpBF,SACAG,KACAC,QACAC,SACkB;CAClB,MAAM,EAAE,OAAO,OAAO,GAAG;AAEzB,KAAI;EACF,MAAM,WAAW,MAAM,OACpB,8BAA8B,IAAI,UAAU,OAAO,WAAW,QAAQ,GACvE,EACE,QAAQ,MACT,EACF;AAED,MAAI,SAAS,WAAW,IACtB,QAAO;AAGT,SAAO;CACR,SAAQ,OAAO;AACd,MAAI,MACF,SAAQ,MAAM,MAAM;AAEtB,SAAO;CACR;AACF;AAED,eAAsB,eACpBL,SACAM,YACiD;CACjD,MAAM,EAAE,OAAO,GAAG;CAElB,MAAM,0BAA0B,OAAO,KAAK,WAAW,CAAC,SAAS,SAAS;CAE1E,MAAM,WAAW,MAAM,OACpB,gCAAgC,wBAAwB,EAC1D;AAED,QAAO,SAAS,MAAM;AACvB"}