@ripwords/myinvois-client 0.2.0 → 0.2.2

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 (50) hide show
  1. package/dist/api/documentManagement.d.ts +1 -1
  2. package/dist/api/documentSubmission.d.ts +1 -1
  3. package/dist/api/documentTypeManagement.d.ts +1 -1
  4. package/dist/api/notificationManagement.d.ts +1 -1
  5. package/dist/api/platformLogin.d.ts +1 -1
  6. package/dist/api/taxpayerValidation.d.ts +1 -9
  7. package/dist/index.cjs +109 -0
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.d.ts +103 -2
  10. package/dist/index.js +111 -2
  11. package/dist/index10.cjs +16 -187
  12. package/dist/index10.cjs.map +1 -1
  13. package/dist/index12.cjs +25 -16
  14. package/dist/index12.cjs.map +1 -1
  15. package/dist/index13.cjs +24 -0
  16. package/dist/{index19.cjs.map → index13.cjs.map} +1 -1
  17. package/dist/index15.cjs +0 -29
  18. package/dist/index16.cjs +0 -25
  19. package/dist/index17.cjs +5 -0
  20. package/dist/index18.cjs +5 -33
  21. package/dist/index19.cjs +4 -23
  22. package/dist/index2.cjs +61 -4
  23. package/dist/{index8.cjs.map → index2.cjs.map} +1 -1
  24. package/dist/index20.cjs +3 -0
  25. package/dist/index21.cjs +3 -0
  26. package/dist/index22.cjs +5 -0
  27. package/dist/index3.cjs +531 -5
  28. package/dist/index3.cjs.map +1 -0
  29. package/dist/index4.cjs +195 -4
  30. package/dist/index4.cjs.map +1 -0
  31. package/dist/index5.cjs +0 -3
  32. package/dist/index6.cjs +24 -2
  33. package/dist/index6.cjs.map +1 -0
  34. package/dist/index66.cts.map +1 -1
  35. package/dist/index67.cts.map +1 -1
  36. package/dist/index7.cjs +0 -5
  37. package/dist/index8.cjs +0 -62
  38. package/dist/index9.cjs +23 -526
  39. package/dist/index9.cjs.map +1 -1
  40. package/dist/{taxpayer-D67d2zAC.d.ts → taxpayer-fpGIHNXp.d.ts} +9 -1
  41. package/dist/{taxpayer-sGkviG8J.d.cts → taxpayer-q6fVtwaA.d.cts} +10 -2
  42. package/dist/taxpayerValidation-DdeXCvPT.cjs.map +1 -1
  43. package/dist/types/index.d.ts +2 -2
  44. package/dist/types/taxpayer.d.ts +2 -2
  45. package/dist/utils/document.d.ts +1 -1
  46. package/dist/utils/signature-diagnostics.d.ts +1 -1
  47. package/package.json +1 -1
  48. package/dist/index15.cjs.map +0 -1
  49. package/dist/index16.cjs.map +0 -1
  50. package/dist/index18.cjs.map +0 -1
@@ -55,7 +55,7 @@ import "../XX-DOA-10JW.js";
55
55
  import "../unit-types-VgYXIwTT.js";
56
56
  import "../state-codes-VOFWhHA0.js";
57
57
  import "../notifications-B4l_qRj7.js";
58
- import "../taxpayer-D67d2zAC.js";
58
+ import "../taxpayer-fpGIHNXp.js";
59
59
  import { Fetch } from "../utils-B3mo51Zp.js";
60
60
  import "../index-FTgB2nM6.js";
61
61
 
@@ -55,7 +55,7 @@ import "../XX-DOA-10JW.js";
55
55
  import "../unit-types-VgYXIwTT.js";
56
56
  import "../state-codes-VOFWhHA0.js";
57
57
  import "../notifications-B4l_qRj7.js";
58
- import "../taxpayer-D67d2zAC.js";
58
+ import "../taxpayer-fpGIHNXp.js";
59
59
  import { Fetch } from "../utils-B3mo51Zp.js";
60
60
  import "../index-FTgB2nM6.js";
61
61
 
@@ -55,7 +55,7 @@ import "../XX-DOA-10JW.js";
55
55
  import "../unit-types-VgYXIwTT.js";
56
56
  import "../state-codes-VOFWhHA0.js";
57
57
  import "../notifications-B4l_qRj7.js";
58
- import "../taxpayer-D67d2zAC.js";
58
+ import "../taxpayer-fpGIHNXp.js";
59
59
  import { Fetch } from "../utils-B3mo51Zp.js";
60
60
  import "../index-FTgB2nM6.js";
61
61
 
@@ -55,7 +55,7 @@ import "../XX-DOA-10JW.js";
55
55
  import "../unit-types-VgYXIwTT.js";
56
56
  import "../state-codes-VOFWhHA0.js";
57
57
  import { NotificationResponse, NotificationSearchParams } from "../notifications-B4l_qRj7.js";
58
- import "../taxpayer-D67d2zAC.js";
58
+ import "../taxpayer-fpGIHNXp.js";
59
59
  import { Fetch } from "../utils-B3mo51Zp.js";
60
60
  import "../index-FTgB2nM6.js";
61
61
 
@@ -55,7 +55,7 @@ import "../XX-DOA-10JW.js";
55
55
  import "../unit-types-VgYXIwTT.js";
56
56
  import "../state-codes-VOFWhHA0.js";
57
57
  import "../notifications-B4l_qRj7.js";
58
- import "../taxpayer-D67d2zAC.js";
58
+ import "../taxpayer-fpGIHNXp.js";
59
59
  import "../utils-B3mo51Zp.js";
60
60
  import { ClientCredentials } from "../index-FTgB2nM6.js";
61
61
 
@@ -55,7 +55,7 @@ import "../XX-DOA-10JW.js";
55
55
  import "../unit-types-VgYXIwTT.js";
56
56
  import "../state-codes-VOFWhHA0.js";
57
57
  import "../notifications-B4l_qRj7.js";
58
- import { TaxpayerQRCodeResponse } from "../taxpayer-D67d2zAC.js";
58
+ import { TaxpayerQRCodeResponse, TinSearchParams, TinSearchResponse } from "../taxpayer-fpGIHNXp.js";
59
59
  import { Fetch } from "../utils-B3mo51Zp.js";
60
60
  import "../index-FTgB2nM6.js";
61
61
 
@@ -64,14 +64,6 @@ interface TaxpayerContext {
64
64
  fetch: Fetch;
65
65
  debug: boolean;
66
66
  }
67
- interface TinSearchParams {
68
- taxpayerName?: string;
69
- idType?: RegistrationType;
70
- idValue?: string;
71
- }
72
- interface TinSearchResponse {
73
- tin: string;
74
- }
75
67
  declare function tinSearch(context: TaxpayerContext, params: TinSearchParams): Promise<TinSearchResponse | StandardError>;
76
68
  declare function verifyTin(context: TaxpayerContext, tin: string, idType: RegistrationType, idValue: string): Promise<boolean>;
77
69
  declare function taxpayerQRCode(context: TaxpayerContext, qrCodeText: string): Promise<TaxpayerQRCodeResponse | StandardError>;
package/dist/index.cjs CHANGED
@@ -100,6 +100,115 @@ var MyInvoisClient = class {
100
100
  }, tin, idType, idValue);
101
101
  }
102
102
  /**
103
+ * Searches for a Tax Identification Number (TIN) using taxpayer information.
104
+ *
105
+ * This method allows searching for a TIN using either a taxpayer name or a combination
106
+ * of identification type and value. The search is flexible and supports multiple
107
+ * identification types including NRIC, ARMY, PASSPORT, and BRN.
108
+ *
109
+ * @param params - Search parameters object
110
+ * @param params.taxpayerName - Optional name of the taxpayer to search for
111
+ * @param params.idType - Optional type of ID to search with (NRIC, ARMY, PASSPORT, BRN)
112
+ * @param params.idValue - Optional value of the ID to search with
113
+ * @returns Promise resolving to TIN search response or standard error
114
+ *
115
+ * @example
116
+ * ```typescript
117
+ * // Search by taxpayer name
118
+ * const result = await client.searchTin({ taxpayerName: 'John Doe' });
119
+ * if ('tin' in result) {
120
+ * console.log('Found TIN:', result.tin);
121
+ * }
122
+ *
123
+ * // Search by ID type and value
124
+ * const result = await client.searchTin({
125
+ * idType: 'NRIC',
126
+ * idValue: '123456789012'
127
+ * });
128
+ * ```
129
+ *
130
+ * @remarks
131
+ * - Either taxpayerName or both idType and idValue must be provided
132
+ * - Returns StandardError object if search criteria are invalid or inconclusive
133
+ * - Debug mode provides detailed error logging for troubleshooting
134
+ * - Search results are not guaranteed to be unique
135
+ */
136
+ async searchTin(params) {
137
+ return require_taxpayerValidation.tinSearch({
138
+ fetch: this.fetch.bind(this),
139
+ debug: this.debug
140
+ }, params);
141
+ }
142
+ /**
143
+ * Retrieves taxpayer information from a QR code.
144
+ *
145
+ * This method decodes a QR code containing taxpayer information and returns
146
+ * detailed taxpayer data including TIN, name, contact details, and business information.
147
+ *
148
+ * @param qrCodeText - The QR code text to decode
149
+ * @returns Promise resolving to taxpayer QR code response or standard error
150
+ *
151
+ * @example
152
+ * ```typescript
153
+ * // Get taxpayer info from QR code
154
+ * const taxpayerInfo = await client.getTaxpayerQRCode('QR_CODE_TEXT');
155
+ * if ('tin' in taxpayerInfo) {
156
+ * console.log('Taxpayer TIN:', taxpayerInfo.tin);
157
+ * console.log('Business Name:', taxpayerInfo.name);
158
+ * console.log('Address:', taxpayerInfo.addressLine1);
159
+ * }
160
+ * ```
161
+ *
162
+ * @remarks
163
+ * - QR code must be in the correct format specified by MyInvois
164
+ * - Returns StandardError if QR code is invalid or cannot be decoded
165
+ * - Debug mode provides detailed error logging
166
+ */
167
+ async getTaxpayerQRCode(qrCodeText) {
168
+ return require_taxpayerValidation.taxpayerQRCode({
169
+ fetch: this.fetch.bind(this),
170
+ debug: this.debug
171
+ }, qrCodeText);
172
+ }
173
+ /**
174
+ * Performs an action on a document such as rejection or cancellation.
175
+ *
176
+ * This method allows updating the status of a document to either rejected or cancelled,
177
+ * along with providing a reason for the action. Useful for managing document workflow
178
+ * and maintaining audit trails.
179
+ *
180
+ * @param documentUid - The unique identifier of the document
181
+ * @param status - The new status to set ('rejected' or 'cancelled')
182
+ * @param reason - The reason for the status change
183
+ * @returns Promise resolving to document action response containing UUID, status, and any errors
184
+ *
185
+ * @example
186
+ * ```typescript
187
+ * // Reject a document with reason
188
+ * const result = await client.performDocumentAction(
189
+ * 'doc-123',
190
+ * 'rejected',
191
+ * 'Invalid tax calculation'
192
+ * );
193
+ *
194
+ * // Cancel a document
195
+ * const result = await client.performDocumentAction(
196
+ * 'doc-456',
197
+ * 'cancelled',
198
+ * 'Duplicate submission'
199
+ * );
200
+ * ```
201
+ *
202
+ * @remarks
203
+ * - Only valid for documents in appropriate states
204
+ * - Reason is required and should be descriptive
205
+ * - Action is irreversible once completed
206
+ * - Returns error if document cannot be found or action is invalid
207
+ */
208
+ async performDocumentAction(documentUid, status, reason) {
209
+ return require_documentSubmission.performDocumentAction(documentUid, status, reason);
210
+ }
211
+ /**
103
212
  * Submits one or more e-invoice documents to the MyInvois platform for processing.
104
213
  *
105
214
  * This method digitally signs each document using the provided certificate and private key,
@@ -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","documents: InvoiceV1_1[]","submissionUid: string","pollInterval: number","maxRetries: number","documentUid: string","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} 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 * 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":"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"}
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":"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"}
package/dist/index.d.ts CHANGED
@@ -55,7 +55,7 @@ import "./XX-DOA-10JW.js";
55
55
  import { UnitType, UnitTypeCode } from "./unit-types-VgYXIwTT.js";
56
56
  import { State, StateCode, StateCodeEnum } from "./state-codes-VOFWhHA0.js";
57
57
  import { Notification, NotificationDeliveryAttempt, NotificationMetadata, NotificationResponse, NotificationSearchParams, NotificationStatus, NotificationStatusEnum, NotificationType, NotificationTypeEnum } from "./notifications-B4l_qRj7.js";
58
- import { TaxpayerQRCodeResponse } from "./taxpayer-D67d2zAC.js";
58
+ import { TaxpayerQRCodeResponse, TinSearchParams, TinSearchResponse } from "./taxpayer-fpGIHNXp.js";
59
59
  import { Fetch } from "./utils-B3mo51Zp.js";
60
60
  import { ClientCredentials, TokenResponse } from "./index-FTgB2nM6.js";
61
61
 
@@ -103,6 +103,107 @@ declare class MyInvoisClient {
103
103
  */
104
104
  verifyTin(tin: string, idType: RegistrationType, idValue: string): Promise<boolean>;
105
105
  /**
106
+ * Searches for a Tax Identification Number (TIN) using taxpayer information.
107
+ *
108
+ * This method allows searching for a TIN using either a taxpayer name or a combination
109
+ * of identification type and value. The search is flexible and supports multiple
110
+ * identification types including NRIC, ARMY, PASSPORT, and BRN.
111
+ *
112
+ * @param params - Search parameters object
113
+ * @param params.taxpayerName - Optional name of the taxpayer to search for
114
+ * @param params.idType - Optional type of ID to search with (NRIC, ARMY, PASSPORT, BRN)
115
+ * @param params.idValue - Optional value of the ID to search with
116
+ * @returns Promise resolving to TIN search response or standard error
117
+ *
118
+ * @example
119
+ * ```typescript
120
+ * // Search by taxpayer name
121
+ * const result = await client.searchTin({ taxpayerName: 'John Doe' });
122
+ * if ('tin' in result) {
123
+ * console.log('Found TIN:', result.tin);
124
+ * }
125
+ *
126
+ * // Search by ID type and value
127
+ * const result = await client.searchTin({
128
+ * idType: 'NRIC',
129
+ * idValue: '123456789012'
130
+ * });
131
+ * ```
132
+ *
133
+ * @remarks
134
+ * - Either taxpayerName or both idType and idValue must be provided
135
+ * - Returns StandardError object if search criteria are invalid or inconclusive
136
+ * - Debug mode provides detailed error logging for troubleshooting
137
+ * - Search results are not guaranteed to be unique
138
+ */
139
+ searchTin(params: TinSearchParams): Promise<TinSearchResponse | StandardError>;
140
+ /**
141
+ * Retrieves taxpayer information from a QR code.
142
+ *
143
+ * This method decodes a QR code containing taxpayer information and returns
144
+ * detailed taxpayer data including TIN, name, contact details, and business information.
145
+ *
146
+ * @param qrCodeText - The QR code text to decode
147
+ * @returns Promise resolving to taxpayer QR code response or standard error
148
+ *
149
+ * @example
150
+ * ```typescript
151
+ * // Get taxpayer info from QR code
152
+ * const taxpayerInfo = await client.getTaxpayerQRCode('QR_CODE_TEXT');
153
+ * if ('tin' in taxpayerInfo) {
154
+ * console.log('Taxpayer TIN:', taxpayerInfo.tin);
155
+ * console.log('Business Name:', taxpayerInfo.name);
156
+ * console.log('Address:', taxpayerInfo.addressLine1);
157
+ * }
158
+ * ```
159
+ *
160
+ * @remarks
161
+ * - QR code must be in the correct format specified by MyInvois
162
+ * - Returns StandardError if QR code is invalid or cannot be decoded
163
+ * - Debug mode provides detailed error logging
164
+ */
165
+ getTaxpayerQRCode(qrCodeText: string): Promise<TaxpayerQRCodeResponse | StandardError>;
166
+ /**
167
+ * Performs an action on a document such as rejection or cancellation.
168
+ *
169
+ * This method allows updating the status of a document to either rejected or cancelled,
170
+ * along with providing a reason for the action. Useful for managing document workflow
171
+ * and maintaining audit trails.
172
+ *
173
+ * @param documentUid - The unique identifier of the document
174
+ * @param status - The new status to set ('rejected' or 'cancelled')
175
+ * @param reason - The reason for the status change
176
+ * @returns Promise resolving to document action response containing UUID, status, and any errors
177
+ *
178
+ * @example
179
+ * ```typescript
180
+ * // Reject a document with reason
181
+ * const result = await client.performDocumentAction(
182
+ * 'doc-123',
183
+ * 'rejected',
184
+ * 'Invalid tax calculation'
185
+ * );
186
+ *
187
+ * // Cancel a document
188
+ * const result = await client.performDocumentAction(
189
+ * 'doc-456',
190
+ * 'cancelled',
191
+ * 'Duplicate submission'
192
+ * );
193
+ * ```
194
+ *
195
+ * @remarks
196
+ * - Only valid for documents in appropriate states
197
+ * - Reason is required and should be descriptive
198
+ * - Action is irreversible once completed
199
+ * - Returns error if document cannot be found or action is invalid
200
+ */
201
+ performDocumentAction(documentUid: string, status: "rejected" | "cancelled", reason: string): Promise<{
202
+ uuid: string;
203
+ status: string;
204
+ error: StandardError;
205
+ }>;
206
+ /**
106
207
  * Submits one or more e-invoice documents to the MyInvois platform for processing.
107
208
  *
108
209
  * This method digitally signs each document using the provided certificate and private key,
@@ -420,4 +521,4 @@ declare class MyInvoisClient {
420
521
  getDocumentTypeVersion(id: number, versionId: number): Promise<DocumentTypeVersionResponse | StandardError>;
421
522
  }
422
523
  //#endregion
423
- 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, TokenResponse, Transform, UBLDocument, UnitType, UnitTypeCode, WorkflowParameter, X509Data };
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
@@ -1,10 +1,10 @@
1
1
  import { getDocument, getDocumentDetails, searchDocuments } from "./documentManagement-CIQPkmyb.js";
2
2
  import "./document-BSuYbfXR.js";
3
- import { getSubmissionStatus, submitDocument } from "./documentSubmission-BdJxIB_I.js";
3
+ import { getSubmissionStatus, performDocumentAction, submitDocument } from "./documentSubmission-BdJxIB_I.js";
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 { verifyTin } from "./taxpayerValidation-DI4B6kWx.js";
7
+ import { taxpayerQRCode, tinSearch, verifyTin } from "./taxpayerValidation-DI4B6kWx.js";
8
8
  import { extractCertificateInfo, validateKeyPair } from "./certificate-BDECQL9C.js";
9
9
  import { getBaseUrl } from "./getBaseUrl-BYkBwhQP.js";
10
10
 
@@ -100,6 +100,115 @@ var MyInvoisClient = class {
100
100
  }, tin, idType, idValue);
101
101
  }
102
102
  /**
103
+ * Searches for a Tax Identification Number (TIN) using taxpayer information.
104
+ *
105
+ * This method allows searching for a TIN using either a taxpayer name or a combination
106
+ * of identification type and value. The search is flexible and supports multiple
107
+ * identification types including NRIC, ARMY, PASSPORT, and BRN.
108
+ *
109
+ * @param params - Search parameters object
110
+ * @param params.taxpayerName - Optional name of the taxpayer to search for
111
+ * @param params.idType - Optional type of ID to search with (NRIC, ARMY, PASSPORT, BRN)
112
+ * @param params.idValue - Optional value of the ID to search with
113
+ * @returns Promise resolving to TIN search response or standard error
114
+ *
115
+ * @example
116
+ * ```typescript
117
+ * // Search by taxpayer name
118
+ * const result = await client.searchTin({ taxpayerName: 'John Doe' });
119
+ * if ('tin' in result) {
120
+ * console.log('Found TIN:', result.tin);
121
+ * }
122
+ *
123
+ * // Search by ID type and value
124
+ * const result = await client.searchTin({
125
+ * idType: 'NRIC',
126
+ * idValue: '123456789012'
127
+ * });
128
+ * ```
129
+ *
130
+ * @remarks
131
+ * - Either taxpayerName or both idType and idValue must be provided
132
+ * - Returns StandardError object if search criteria are invalid or inconclusive
133
+ * - Debug mode provides detailed error logging for troubleshooting
134
+ * - Search results are not guaranteed to be unique
135
+ */
136
+ async searchTin(params) {
137
+ return tinSearch({
138
+ fetch: this.fetch.bind(this),
139
+ debug: this.debug
140
+ }, params);
141
+ }
142
+ /**
143
+ * Retrieves taxpayer information from a QR code.
144
+ *
145
+ * This method decodes a QR code containing taxpayer information and returns
146
+ * detailed taxpayer data including TIN, name, contact details, and business information.
147
+ *
148
+ * @param qrCodeText - The QR code text to decode
149
+ * @returns Promise resolving to taxpayer QR code response or standard error
150
+ *
151
+ * @example
152
+ * ```typescript
153
+ * // Get taxpayer info from QR code
154
+ * const taxpayerInfo = await client.getTaxpayerQRCode('QR_CODE_TEXT');
155
+ * if ('tin' in taxpayerInfo) {
156
+ * console.log('Taxpayer TIN:', taxpayerInfo.tin);
157
+ * console.log('Business Name:', taxpayerInfo.name);
158
+ * console.log('Address:', taxpayerInfo.addressLine1);
159
+ * }
160
+ * ```
161
+ *
162
+ * @remarks
163
+ * - QR code must be in the correct format specified by MyInvois
164
+ * - Returns StandardError if QR code is invalid or cannot be decoded
165
+ * - Debug mode provides detailed error logging
166
+ */
167
+ async getTaxpayerQRCode(qrCodeText) {
168
+ return taxpayerQRCode({
169
+ fetch: this.fetch.bind(this),
170
+ debug: this.debug
171
+ }, qrCodeText);
172
+ }
173
+ /**
174
+ * Performs an action on a document such as rejection or cancellation.
175
+ *
176
+ * This method allows updating the status of a document to either rejected or cancelled,
177
+ * along with providing a reason for the action. Useful for managing document workflow
178
+ * and maintaining audit trails.
179
+ *
180
+ * @param documentUid - The unique identifier of the document
181
+ * @param status - The new status to set ('rejected' or 'cancelled')
182
+ * @param reason - The reason for the status change
183
+ * @returns Promise resolving to document action response containing UUID, status, and any errors
184
+ *
185
+ * @example
186
+ * ```typescript
187
+ * // Reject a document with reason
188
+ * const result = await client.performDocumentAction(
189
+ * 'doc-123',
190
+ * 'rejected',
191
+ * 'Invalid tax calculation'
192
+ * );
193
+ *
194
+ * // Cancel a document
195
+ * const result = await client.performDocumentAction(
196
+ * 'doc-456',
197
+ * 'cancelled',
198
+ * 'Duplicate submission'
199
+ * );
200
+ * ```
201
+ *
202
+ * @remarks
203
+ * - Only valid for documents in appropriate states
204
+ * - Reason is required and should be descriptive
205
+ * - Action is irreversible once completed
206
+ * - Returns error if document cannot be found or action is invalid
207
+ */
208
+ async performDocumentAction(documentUid, status, reason) {
209
+ return performDocumentAction(documentUid, status, reason);
210
+ }
211
+ /**
103
212
  * Submits one or more e-invoice documents to the MyInvois platform for processing.
104
213
  *
105
214
  * This method digitally signs each document using the provided certificate and private key,