@ripwords/myinvois-client 0.2.21 → 0.2.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index10.cjs +16 -187
- package/dist/index10.cjs.map +1 -1
- package/dist/index12.cjs +25 -16
- package/dist/index12.cjs.map +1 -1
- package/dist/index13.cjs +24 -0
- package/dist/{index19.cjs.map → index13.cjs.map} +1 -1
- package/dist/index15.cjs +0 -29
- package/dist/index16.cjs +0 -25
- package/dist/index17.cjs +5 -0
- package/dist/index18.cjs +6 -33
- package/dist/index19.cjs +4 -23
- package/dist/index2.cjs +61 -4
- package/dist/{index8.cjs.map → index2.cjs.map} +1 -1
- package/dist/index20.cjs +3 -0
- package/dist/index21.cjs +3 -0
- package/dist/index22.cjs +6 -0
- package/dist/index3.cjs +531 -6
- package/dist/index3.cjs.map +1 -0
- package/dist/index4.cjs +195 -4
- package/dist/index4.cjs.map +1 -0
- package/dist/index5.cjs +0 -3
- package/dist/index6.cjs +24 -2
- package/dist/index6.cjs.map +1 -0
- package/dist/index67.cts.map +1 -1
- package/dist/index7.cjs +0 -6
- package/dist/index8.cjs +0 -62
- package/dist/index9.cjs +23 -526
- package/dist/index9.cjs.map +1 -1
- package/package.json +1 -1
- package/dist/index15.cjs.map +0 -1
- package/dist/index16.cjs.map +0 -1
- package/dist/index18.cjs.map +0 -1
package/dist/index.cjs
CHANGED
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["clientId: string","clientSecret: string","environment: 'sandbox' | 'production'","certificatePem: string","privateKeyPem: string","onBehalfOf?: string","debug?: boolean","onBehalfOf: string","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: AllDocumentsV1_1[]","submissionUid: string","pollInterval: number","maxRetries: number","id: number","versionId: number","p12Input: Buffer | string","passphrase: string"],"sources":["../src/index.ts"],"sourcesContent":["import {\n DocumentStatus,\n DocumentSummary,\n DocumentTypeResponse,\n DocumentTypesResponse,\n DocumentTypeVersionResponse,\n DocumentValidationResult,\n DocumentValidationStepResult,\n EInvoiceTypeCode,\n NotificationResponse,\n NotificationSearchParams,\n RegistrationType,\n SigningCredentials,\n StandardError,\n SubmissionResponse,\n SubmissionStatus,\n TaxpayerQRCodeResponse,\n TinSearchParams,\n TinSearchResponse,\n AllDocumentsV1_1,\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 {\n extractCertificateInfo,\n validateKeyPair,\n getPemFromP12,\n} from './utils/certificate'\nimport { getBaseUrl } from './utils/getBaseUrl'\nimport { queueRequest, categorizeRequest } from './utils/apiQueue'\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 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 async updateBeneficiary(onBehalfOf: string): Promise<void> {\n this.onBehalfOf = onBehalfOf\n await this.refreshToken()\n return\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 // Dynamically categorise the request and enqueue it so we never exceed the\n // vendor-specified rate-limits. If the path isn't recognised it will fall\n // back to the `default` category which has a very high allowance.\n\n const category = categorizeRequest(\n path,\n options?.method as string | undefined,\n )\n\n return queueRequest(\n category,\n () =>\n fetch(`${this.baseUrl}${path}`, {\n ...options,\n headers: { ...options.headers, Authorization: `Bearer ${token}` },\n }),\n this.debug,\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: AllDocumentsV1_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 // Static helper: create a client directly from a PKCS#12 (.p12) bundle\n static fromP12(\n clientId: string,\n clientSecret: string,\n environment: 'sandbox' | 'production',\n p12Input: Buffer | string,\n passphrase: string,\n onBehalfOf?: string,\n debug?: boolean,\n ): MyInvoisClient {\n const { certificatePem, privateKeyPem } = getPemFromP12(\n p12Input,\n passphrase,\n )\n\n return new MyInvoisClient(\n clientId,\n clientSecret,\n environment,\n certificatePem,\n privateKeyPem,\n onBehalfOf,\n debug,\n )\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAqCA,IAAa,iBAAb,MAAa,eAAe;CAC1B,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAQ;CACR,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,MAAM,kBAAkBC,YAAmC;AACzD,OAAK,aAAa;AAClB,QAAM,KAAK,cAAc;AACzB;CACD;CAED,MAAc,eAAe;EAC3B,MAAM,gBAAgB,MAAM,oCAAc;GACxC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AAO,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;CAGD,OAAO,QACLvB,UACAC,cACAC,aACAsB,UACAC,YACApB,YACAC,OACgB;EAChB,MAAM,EAAE,gBAAgB,eAAe,GAAG,kCACxC,UACA,WACD;AAED,SAAO,IAAI,eACT,UACA,cACA,aACA,gBACA,eACA,YACA;CAEH;AACF"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["clientId: string","clientSecret: string","environment: 'sandbox' | 'production'","certificatePem: string","privateKeyPem: string","onBehalfOf?: string","debug?: boolean","onBehalfOf: string","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: AllDocumentsV1_1[]","submissionUid: string","pollInterval: number","maxRetries: number","id: number","versionId: number","p12Input: Buffer | string","passphrase: string"],"sources":["../src/index.ts"],"sourcesContent":["import {\n DocumentStatus,\n DocumentSummary,\n DocumentTypeResponse,\n DocumentTypesResponse,\n DocumentTypeVersionResponse,\n DocumentValidationResult,\n DocumentValidationStepResult,\n EInvoiceTypeCode,\n NotificationResponse,\n NotificationSearchParams,\n RegistrationType,\n SigningCredentials,\n StandardError,\n SubmissionResponse,\n SubmissionStatus,\n TaxpayerQRCodeResponse,\n TinSearchParams,\n TinSearchResponse,\n AllDocumentsV1_1,\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 {\n extractCertificateInfo,\n validateKeyPair,\n getPemFromP12,\n} from './utils/certificate'\nimport { getBaseUrl } from './utils/getBaseUrl'\nimport { queueRequest, categorizeRequest } from './utils/apiQueue'\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 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 async updateOnBehalfOf(onBehalfOf: string): Promise<void> {\n this.onBehalfOf = onBehalfOf\n await this.refreshToken()\n return\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 // Dynamically categorise the request and enqueue it so we never exceed the\n // vendor-specified rate-limits. If the path isn't recognised it will fall\n // back to the `default` category which has a very high allowance.\n\n const category = categorizeRequest(\n path,\n options?.method as string | undefined,\n )\n\n return queueRequest(\n category,\n () =>\n fetch(`${this.baseUrl}${path}`, {\n ...options,\n headers: { ...options.headers, Authorization: `Bearer ${token}` },\n }),\n this.debug,\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: AllDocumentsV1_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 // Static helper: create a client directly from a PKCS#12 (.p12) bundle\n static fromP12(\n clientId: string,\n clientSecret: string,\n environment: 'sandbox' | 'production',\n p12Input: Buffer | string,\n passphrase: string,\n onBehalfOf?: string,\n debug?: boolean,\n ): MyInvoisClient {\n const { certificatePem, privateKeyPem } = getPemFromP12(\n p12Input,\n passphrase,\n )\n\n return new MyInvoisClient(\n clientId,\n clientSecret,\n environment,\n certificatePem,\n privateKeyPem,\n onBehalfOf,\n debug,\n )\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAqCA,IAAa,iBAAb,MAAa,eAAe;CAC1B,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAQ;CACR,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,MAAM,iBAAiBC,YAAmC;AACxD,OAAK,aAAa;AAClB,QAAM,KAAK,cAAc;AACzB;CACD;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;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EAChB,MAAM,EAAE,gBAAgB,eAAe,GAAG,kCACxC,UACA,WACD;AAED,SAAO,IAAI,eACT,UACA,cACA,aACA,gBACA,eACA,YACA;CAEH;AACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -70,7 +70,7 @@ declare class MyInvoisClient {
|
|
|
70
70
|
private token;
|
|
71
71
|
private tokenExpiration;
|
|
72
72
|
constructor(clientId: string, clientSecret: string, environment: "sandbox" | "production", certificatePem: string, privateKeyPem: string, onBehalfOf?: string, debug?: boolean);
|
|
73
|
-
|
|
73
|
+
updateOnBehalfOf(onBehalfOf: string): Promise<void>;
|
|
74
74
|
private refreshToken;
|
|
75
75
|
private getToken;
|
|
76
76
|
private fetch;
|
package/dist/index.js
CHANGED
package/dist/index10.cjs
CHANGED
|
@@ -1,196 +1,25 @@
|
|
|
1
1
|
|
|
2
|
-
//#region src/types/
|
|
2
|
+
//#region src/types/payment-modes.d.ts
|
|
3
3
|
/**
|
|
4
|
-
* Enum representing the allowed
|
|
5
|
-
* Provides a more readable way to reference
|
|
4
|
+
* Enum representing the allowed payment mode codes with descriptive names.
|
|
5
|
+
* Provides a more readable way to reference payment modes.
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
|
-
* const
|
|
9
|
-
* console.log(
|
|
8
|
+
* const mode = PaymentModeCodeEnum.Cash;
|
|
9
|
+
* console.log(mode); // Output: "01"
|
|
10
10
|
*/
|
|
11
|
-
let
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
CurrencyCodeEnum$1["AZN"] = "AZN";
|
|
22
|
-
CurrencyCodeEnum$1["BAM"] = "BAM";
|
|
23
|
-
CurrencyCodeEnum$1["BBD"] = "BBD";
|
|
24
|
-
CurrencyCodeEnum$1["BDT"] = "BDT";
|
|
25
|
-
CurrencyCodeEnum$1["BGN"] = "BGN";
|
|
26
|
-
CurrencyCodeEnum$1["BHD"] = "BHD";
|
|
27
|
-
CurrencyCodeEnum$1["BIF"] = "BIF";
|
|
28
|
-
CurrencyCodeEnum$1["BMD"] = "BMD";
|
|
29
|
-
CurrencyCodeEnum$1["BND"] = "BND";
|
|
30
|
-
CurrencyCodeEnum$1["BOB"] = "BOB";
|
|
31
|
-
CurrencyCodeEnum$1["BOV"] = "BOV";
|
|
32
|
-
CurrencyCodeEnum$1["BRL"] = "BRL";
|
|
33
|
-
CurrencyCodeEnum$1["BSD"] = "BSD";
|
|
34
|
-
CurrencyCodeEnum$1["BTN"] = "BTN";
|
|
35
|
-
CurrencyCodeEnum$1["BWP"] = "BWP";
|
|
36
|
-
CurrencyCodeEnum$1["BYN"] = "BYN";
|
|
37
|
-
CurrencyCodeEnum$1["BZD"] = "BZD";
|
|
38
|
-
CurrencyCodeEnum$1["CAD"] = "CAD";
|
|
39
|
-
CurrencyCodeEnum$1["CDF"] = "CDF";
|
|
40
|
-
CurrencyCodeEnum$1["CHE"] = "CHE";
|
|
41
|
-
CurrencyCodeEnum$1["CHF"] = "CHF";
|
|
42
|
-
CurrencyCodeEnum$1["CHW"] = "CHW";
|
|
43
|
-
CurrencyCodeEnum$1["CLF"] = "CLF";
|
|
44
|
-
CurrencyCodeEnum$1["CLP"] = "CLP";
|
|
45
|
-
CurrencyCodeEnum$1["CNY"] = "CNY";
|
|
46
|
-
CurrencyCodeEnum$1["COP"] = "COP";
|
|
47
|
-
CurrencyCodeEnum$1["COU"] = "COU";
|
|
48
|
-
CurrencyCodeEnum$1["CRC"] = "CRC";
|
|
49
|
-
CurrencyCodeEnum$1["CUC"] = "CUC";
|
|
50
|
-
CurrencyCodeEnum$1["CUP"] = "CUP";
|
|
51
|
-
CurrencyCodeEnum$1["CVE"] = "CVE";
|
|
52
|
-
CurrencyCodeEnum$1["CZK"] = "CZK";
|
|
53
|
-
CurrencyCodeEnum$1["DJF"] = "DJF";
|
|
54
|
-
CurrencyCodeEnum$1["DKK"] = "DKK";
|
|
55
|
-
CurrencyCodeEnum$1["DOP"] = "DOP";
|
|
56
|
-
CurrencyCodeEnum$1["DZD"] = "DZD";
|
|
57
|
-
CurrencyCodeEnum$1["EGP"] = "EGP";
|
|
58
|
-
CurrencyCodeEnum$1["ERN"] = "ERN";
|
|
59
|
-
CurrencyCodeEnum$1["ETB"] = "ETB";
|
|
60
|
-
CurrencyCodeEnum$1["EUR"] = "EUR";
|
|
61
|
-
CurrencyCodeEnum$1["FJD"] = "FJD";
|
|
62
|
-
CurrencyCodeEnum$1["FKP"] = "FKP";
|
|
63
|
-
CurrencyCodeEnum$1["GBP"] = "GBP";
|
|
64
|
-
CurrencyCodeEnum$1["GEL"] = "GEL";
|
|
65
|
-
CurrencyCodeEnum$1["GHS"] = "GHS";
|
|
66
|
-
CurrencyCodeEnum$1["GIP"] = "GIP";
|
|
67
|
-
CurrencyCodeEnum$1["GMD"] = "GMD";
|
|
68
|
-
CurrencyCodeEnum$1["GNF"] = "GNF";
|
|
69
|
-
CurrencyCodeEnum$1["GTQ"] = "GTQ";
|
|
70
|
-
CurrencyCodeEnum$1["GYD"] = "GYD";
|
|
71
|
-
CurrencyCodeEnum$1["HKD"] = "HKD";
|
|
72
|
-
CurrencyCodeEnum$1["HNL"] = "HNL";
|
|
73
|
-
CurrencyCodeEnum$1["HRK"] = "HRK";
|
|
74
|
-
CurrencyCodeEnum$1["HTG"] = "HTG";
|
|
75
|
-
CurrencyCodeEnum$1["HUF"] = "HUF";
|
|
76
|
-
CurrencyCodeEnum$1["IDR"] = "IDR";
|
|
77
|
-
CurrencyCodeEnum$1["ILS"] = "ILS";
|
|
78
|
-
CurrencyCodeEnum$1["INR"] = "INR";
|
|
79
|
-
CurrencyCodeEnum$1["IQD"] = "IQD";
|
|
80
|
-
CurrencyCodeEnum$1["IRR"] = "IRR";
|
|
81
|
-
CurrencyCodeEnum$1["ISK"] = "ISK";
|
|
82
|
-
CurrencyCodeEnum$1["JMD"] = "JMD";
|
|
83
|
-
CurrencyCodeEnum$1["JOD"] = "JOD";
|
|
84
|
-
CurrencyCodeEnum$1["JPY"] = "JPY";
|
|
85
|
-
CurrencyCodeEnum$1["KES"] = "KES";
|
|
86
|
-
CurrencyCodeEnum$1["KGS"] = "KGS";
|
|
87
|
-
CurrencyCodeEnum$1["KHR"] = "KHR";
|
|
88
|
-
CurrencyCodeEnum$1["KMF"] = "KMF";
|
|
89
|
-
CurrencyCodeEnum$1["KPW"] = "KPW";
|
|
90
|
-
CurrencyCodeEnum$1["KRW"] = "KRW";
|
|
91
|
-
CurrencyCodeEnum$1["KWD"] = "KWD";
|
|
92
|
-
CurrencyCodeEnum$1["KYD"] = "KYD";
|
|
93
|
-
CurrencyCodeEnum$1["KZT"] = "KZT";
|
|
94
|
-
CurrencyCodeEnum$1["LAK"] = "LAK";
|
|
95
|
-
CurrencyCodeEnum$1["LBP"] = "LBP";
|
|
96
|
-
CurrencyCodeEnum$1["LKR"] = "LKR";
|
|
97
|
-
CurrencyCodeEnum$1["LRD"] = "LRD";
|
|
98
|
-
CurrencyCodeEnum$1["LSL"] = "LSL";
|
|
99
|
-
CurrencyCodeEnum$1["LYD"] = "LYD";
|
|
100
|
-
CurrencyCodeEnum$1["MAD"] = "MAD";
|
|
101
|
-
CurrencyCodeEnum$1["MDL"] = "MDL";
|
|
102
|
-
CurrencyCodeEnum$1["MGA"] = "MGA";
|
|
103
|
-
CurrencyCodeEnum$1["MKD"] = "MKD";
|
|
104
|
-
CurrencyCodeEnum$1["MMK"] = "MMK";
|
|
105
|
-
CurrencyCodeEnum$1["MNT"] = "MNT";
|
|
106
|
-
CurrencyCodeEnum$1["MOP"] = "MOP";
|
|
107
|
-
CurrencyCodeEnum$1["MRU"] = "MRU";
|
|
108
|
-
CurrencyCodeEnum$1["MUR"] = "MUR";
|
|
109
|
-
CurrencyCodeEnum$1["MVR"] = "MVR";
|
|
110
|
-
CurrencyCodeEnum$1["MWK"] = "MWK";
|
|
111
|
-
CurrencyCodeEnum$1["MXN"] = "MXN";
|
|
112
|
-
CurrencyCodeEnum$1["MXV"] = "MXV";
|
|
113
|
-
CurrencyCodeEnum$1["MYR"] = "MYR";
|
|
114
|
-
CurrencyCodeEnum$1["MZN"] = "MZN";
|
|
115
|
-
CurrencyCodeEnum$1["NAD"] = "NAD";
|
|
116
|
-
CurrencyCodeEnum$1["NGN"] = "NGN";
|
|
117
|
-
CurrencyCodeEnum$1["NIO"] = "NIO";
|
|
118
|
-
CurrencyCodeEnum$1["NOK"] = "NOK";
|
|
119
|
-
CurrencyCodeEnum$1["NPR"] = "NPR";
|
|
120
|
-
CurrencyCodeEnum$1["NZD"] = "NZD";
|
|
121
|
-
CurrencyCodeEnum$1["OMR"] = "OMR";
|
|
122
|
-
CurrencyCodeEnum$1["PAB"] = "PAB";
|
|
123
|
-
CurrencyCodeEnum$1["PEN"] = "PEN";
|
|
124
|
-
CurrencyCodeEnum$1["PGK"] = "PGK";
|
|
125
|
-
CurrencyCodeEnum$1["PHP"] = "PHP";
|
|
126
|
-
CurrencyCodeEnum$1["PKR"] = "PKR";
|
|
127
|
-
CurrencyCodeEnum$1["PLN"] = "PLN";
|
|
128
|
-
CurrencyCodeEnum$1["PYG"] = "PYG";
|
|
129
|
-
CurrencyCodeEnum$1["QAR"] = "QAR";
|
|
130
|
-
CurrencyCodeEnum$1["RON"] = "RON";
|
|
131
|
-
CurrencyCodeEnum$1["RSD"] = "RSD";
|
|
132
|
-
CurrencyCodeEnum$1["RUB"] = "RUB";
|
|
133
|
-
CurrencyCodeEnum$1["RWF"] = "RWF";
|
|
134
|
-
CurrencyCodeEnum$1["SAR"] = "SAR";
|
|
135
|
-
CurrencyCodeEnum$1["SBD"] = "SBD";
|
|
136
|
-
CurrencyCodeEnum$1["SCR"] = "SCR";
|
|
137
|
-
CurrencyCodeEnum$1["SDG"] = "SDG";
|
|
138
|
-
CurrencyCodeEnum$1["SEK"] = "SEK";
|
|
139
|
-
CurrencyCodeEnum$1["SGD"] = "SGD";
|
|
140
|
-
CurrencyCodeEnum$1["SHP"] = "SHP";
|
|
141
|
-
CurrencyCodeEnum$1["SLL"] = "SLL";
|
|
142
|
-
CurrencyCodeEnum$1["SOS"] = "SOS";
|
|
143
|
-
CurrencyCodeEnum$1["SRD"] = "SRD";
|
|
144
|
-
CurrencyCodeEnum$1["SSP"] = "SSP";
|
|
145
|
-
CurrencyCodeEnum$1["STN"] = "STN";
|
|
146
|
-
CurrencyCodeEnum$1["SVC"] = "SVC";
|
|
147
|
-
CurrencyCodeEnum$1["SYP"] = "SYP";
|
|
148
|
-
CurrencyCodeEnum$1["SZL"] = "SZL";
|
|
149
|
-
CurrencyCodeEnum$1["THB"] = "THB";
|
|
150
|
-
CurrencyCodeEnum$1["TJS"] = "TJS";
|
|
151
|
-
CurrencyCodeEnum$1["TMT"] = "TMT";
|
|
152
|
-
CurrencyCodeEnum$1["TND"] = "TND";
|
|
153
|
-
CurrencyCodeEnum$1["TOP"] = "TOP";
|
|
154
|
-
CurrencyCodeEnum$1["TRY"] = "TRY";
|
|
155
|
-
CurrencyCodeEnum$1["TTD"] = "TTD";
|
|
156
|
-
CurrencyCodeEnum$1["TWD"] = "TWD";
|
|
157
|
-
CurrencyCodeEnum$1["TZS"] = "TZS";
|
|
158
|
-
CurrencyCodeEnum$1["UAH"] = "UAH";
|
|
159
|
-
CurrencyCodeEnum$1["UGX"] = "UGX";
|
|
160
|
-
CurrencyCodeEnum$1["USD"] = "USD";
|
|
161
|
-
CurrencyCodeEnum$1["USN"] = "USN";
|
|
162
|
-
CurrencyCodeEnum$1["UYI"] = "UYI";
|
|
163
|
-
CurrencyCodeEnum$1["UYU"] = "UYU";
|
|
164
|
-
CurrencyCodeEnum$1["UYW"] = "UYW";
|
|
165
|
-
CurrencyCodeEnum$1["UZS"] = "UZS";
|
|
166
|
-
CurrencyCodeEnum$1["VED"] = "VED";
|
|
167
|
-
CurrencyCodeEnum$1["VES"] = "VES";
|
|
168
|
-
CurrencyCodeEnum$1["VND"] = "VND";
|
|
169
|
-
CurrencyCodeEnum$1["VUV"] = "VUV";
|
|
170
|
-
CurrencyCodeEnum$1["WST"] = "WST";
|
|
171
|
-
CurrencyCodeEnum$1["XAF"] = "XAF";
|
|
172
|
-
CurrencyCodeEnum$1["XAG"] = "XAG";
|
|
173
|
-
CurrencyCodeEnum$1["XAU"] = "XAU";
|
|
174
|
-
CurrencyCodeEnum$1["XBA"] = "XBA";
|
|
175
|
-
CurrencyCodeEnum$1["XBB"] = "XBB";
|
|
176
|
-
CurrencyCodeEnum$1["XBC"] = "XBC";
|
|
177
|
-
CurrencyCodeEnum$1["XBD"] = "XBD";
|
|
178
|
-
CurrencyCodeEnum$1["XCD"] = "XCD";
|
|
179
|
-
CurrencyCodeEnum$1["XDR"] = "XDR";
|
|
180
|
-
CurrencyCodeEnum$1["XOF"] = "XOF";
|
|
181
|
-
CurrencyCodeEnum$1["XPD"] = "XPD";
|
|
182
|
-
CurrencyCodeEnum$1["XPF"] = "XPF";
|
|
183
|
-
CurrencyCodeEnum$1["XPT"] = "XPT";
|
|
184
|
-
CurrencyCodeEnum$1["XSU"] = "XSU";
|
|
185
|
-
CurrencyCodeEnum$1["XUA"] = "XUA";
|
|
186
|
-
CurrencyCodeEnum$1["XXX"] = "XXX";
|
|
187
|
-
CurrencyCodeEnum$1["YER"] = "YER";
|
|
188
|
-
CurrencyCodeEnum$1["ZAR"] = "ZAR";
|
|
189
|
-
CurrencyCodeEnum$1["ZMW"] = "ZMW";
|
|
190
|
-
CurrencyCodeEnum$1["ZWL"] = "ZWL";
|
|
191
|
-
return CurrencyCodeEnum$1;
|
|
11
|
+
let PaymentModeCodeEnum = /* @__PURE__ */ function(PaymentModeCodeEnum$1) {
|
|
12
|
+
PaymentModeCodeEnum$1["Cash"] = "01";
|
|
13
|
+
PaymentModeCodeEnum$1["Cheque"] = "02";
|
|
14
|
+
PaymentModeCodeEnum$1["BankTransfer"] = "03";
|
|
15
|
+
PaymentModeCodeEnum$1["CreditCard"] = "04";
|
|
16
|
+
PaymentModeCodeEnum$1["DebitCard"] = "05";
|
|
17
|
+
PaymentModeCodeEnum$1["EWalletDigitalWallet"] = "06";
|
|
18
|
+
PaymentModeCodeEnum$1["DigitalBank"] = "07";
|
|
19
|
+
PaymentModeCodeEnum$1["Others"] = "08";
|
|
20
|
+
return PaymentModeCodeEnum$1;
|
|
192
21
|
}({});
|
|
193
22
|
|
|
194
23
|
//#endregion
|
|
195
|
-
exports.
|
|
24
|
+
exports.PaymentModeCodeEnum = PaymentModeCodeEnum;
|
|
196
25
|
//# sourceMappingURL=index10.cjs.map
|
package/dist/index10.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index10.cjs","names":[],"sources":["../src/types/
|
|
1
|
+
{"version":3,"file":"index10.cjs","names":[],"sources":["../src/types/payment-modes.d.ts"],"sourcesContent":["/**\n * Represents the allowed codes for payment modes.\n * Based on the documentation: https://sdk.myinvois.hasil.gov.my/codes/payment-methods/\n */\nexport type PaymentModeCode =\n | '01' // Cash\n | '02' // Cheque\n | '03' // Bank Transfer\n | '04' // Credit Card\n | '05' // Debit Card\n | '06' // e-Wallet / Digital Wallet\n | '07' // Digital Bank\n | '08' // Others\n\n/**\n * Enum representing the allowed payment mode codes with descriptive names.\n * Provides a more readable way to reference payment modes.\n *\n * @example\n * const mode = PaymentModeCodeEnum.Cash;\n * console.log(mode); // Output: \"01\"\n */\nexport enum PaymentModeCodeEnum {\n Cash = '01',\n Cheque = '02',\n BankTransfer = '03',\n CreditCard = '04',\n DebitCard = '05',\n EWalletDigitalWallet = '06',\n DigitalBank = '07',\n Others = '08',\n}\n\n/**\n * Interface representing a payment mode entry.\n * Contains the code and its corresponding description.\n */\nexport interface PaymentMode {\n code: PaymentModeCode\n description: string\n}\n"],"mappings":";;;;;;;;;;AAsBA,IAAY,sEAAL;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACD"}
|
package/dist/index12.cjs
CHANGED
|
@@ -1,25 +1,34 @@
|
|
|
1
1
|
|
|
2
|
-
//#region src/types/
|
|
2
|
+
//#region src/types/state-codes.d.ts
|
|
3
3
|
/**
|
|
4
|
-
* Enum representing the allowed codes
|
|
5
|
-
* Provides a more readable way to reference
|
|
4
|
+
* Enum representing the allowed state codes with descriptive names.
|
|
5
|
+
* Provides a more readable way to reference states.
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
|
-
* const
|
|
9
|
-
* console.log(
|
|
8
|
+
* const code = StateCodeEnum.Selangor;
|
|
9
|
+
* console.log(code); // Output: "10"
|
|
10
10
|
*/
|
|
11
|
-
let
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
let StateCodeEnum = /* @__PURE__ */ function(StateCodeEnum$1) {
|
|
12
|
+
StateCodeEnum$1["Johor"] = "01";
|
|
13
|
+
StateCodeEnum$1["Kedah"] = "02";
|
|
14
|
+
StateCodeEnum$1["Kelantan"] = "03";
|
|
15
|
+
StateCodeEnum$1["Melaka"] = "04";
|
|
16
|
+
StateCodeEnum$1["NegeriSembilan"] = "05";
|
|
17
|
+
StateCodeEnum$1["Pahang"] = "06";
|
|
18
|
+
StateCodeEnum$1["PulauPinang"] = "07";
|
|
19
|
+
StateCodeEnum$1["Perak"] = "08";
|
|
20
|
+
StateCodeEnum$1["Perlis"] = "09";
|
|
21
|
+
StateCodeEnum$1["Selangor"] = "10";
|
|
22
|
+
StateCodeEnum$1["Terengganu"] = "11";
|
|
23
|
+
StateCodeEnum$1["Sabah"] = "12";
|
|
24
|
+
StateCodeEnum$1["Sarawak"] = "13";
|
|
25
|
+
StateCodeEnum$1["WPKualaLumpur"] = "14";
|
|
26
|
+
StateCodeEnum$1["WPLabuan"] = "15";
|
|
27
|
+
StateCodeEnum$1["WPPutrajaya"] = "16";
|
|
28
|
+
StateCodeEnum$1["NotApplicable"] = "17";
|
|
29
|
+
return StateCodeEnum$1;
|
|
21
30
|
}({});
|
|
22
31
|
|
|
23
32
|
//#endregion
|
|
24
|
-
exports.
|
|
33
|
+
exports.StateCodeEnum = StateCodeEnum;
|
|
25
34
|
//# sourceMappingURL=index12.cjs.map
|
package/dist/index12.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index12.cjs","names":[],"sources":["../src/types/
|
|
1
|
+
{"version":3,"file":"index12.cjs","names":[],"sources":["../src/types/state-codes.d.ts"],"sourcesContent":["/**\n * Represents the allowed codes for Malaysian states and federal territories.\n * Based on the documentation: https://sdk.myinvois.hasil.gov.my/codes/state-codes/\n */\nexport type StateCode =\n | '01' // Johor\n | '02' // Kedah\n | '03' // Kelantan\n | '04' // Melaka\n | '05' // Negeri Sembilan\n | '06' // Pahang\n | '07' // Pulau Pinang\n | '08' // Perak\n | '09' // Perlis\n | '10' // Selangor\n | '11' // Terengganu\n | '12' // Sabah\n | '13' // Sarawak\n | '14' // Wilayah Persekutuan Kuala Lumpur\n | '15' // Wilayah Persekutuan Labuan\n | '16' // Wilayah Persekutuan Putrajaya\n | '17' // Not Applicable\n\n/**\n * Enum representing the allowed state codes with descriptive names.\n * Provides a more readable way to reference states.\n *\n * @example\n * const code = StateCodeEnum.Selangor;\n * console.log(code); // Output: \"10\"\n */\nexport enum StateCodeEnum {\n Johor = '01',\n Kedah = '02',\n Kelantan = '03',\n Melaka = '04',\n NegeriSembilan = '05',\n Pahang = '06',\n PulauPinang = '07',\n Perak = '08',\n Perlis = '09',\n Selangor = '10',\n Terengganu = '11',\n Sabah = '12',\n Sarawak = '13',\n WPKualaLumpur = '14',\n WPLabuan = '15',\n WPPutrajaya = '16',\n NotApplicable = '17',\n}\n\n/**\n * Interface representing a state code entry.\n * Contains the code and its corresponding name.\n */\nexport interface State {\n code: StateCode\n name: string\n}\n"],"mappings":";;;;;;;;;;AA+BA,IAAY,0DAAL;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACD"}
|
package/dist/index13.cjs
CHANGED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/types/tax-types.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Enum representing the allowed tax type codes with descriptive names.
|
|
5
|
+
* Provides a more readable way to reference tax types.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* const code = TaxTypeCodeEnum.SalesTax;
|
|
9
|
+
* console.log(code); // Output: "01"
|
|
10
|
+
*/
|
|
11
|
+
let TaxTypeCodeEnum = /* @__PURE__ */ function(TaxTypeCodeEnum$1) {
|
|
12
|
+
TaxTypeCodeEnum$1["SalesTax"] = "01";
|
|
13
|
+
TaxTypeCodeEnum$1["ServiceTax"] = "02";
|
|
14
|
+
TaxTypeCodeEnum$1["TourismTax"] = "03";
|
|
15
|
+
TaxTypeCodeEnum$1["HighValueGoodsTax"] = "04";
|
|
16
|
+
TaxTypeCodeEnum$1["SalesTaxLowValueGoods"] = "05";
|
|
17
|
+
TaxTypeCodeEnum$1["NotApplicable"] = "06";
|
|
18
|
+
TaxTypeCodeEnum$1["TaxExemption"] = "E";
|
|
19
|
+
return TaxTypeCodeEnum$1;
|
|
20
|
+
}({});
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
exports.TaxTypeCodeEnum = TaxTypeCodeEnum;
|
|
24
|
+
//# sourceMappingURL=index13.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"
|
|
1
|
+
{"version":3,"file":"index13.cjs","names":[],"sources":["../src/types/tax-types.d.ts"],"sourcesContent":["/**\n * Represents the allowed codes for tax types.\n * Based on the documentation: https://sdk.myinvois.hasil.gov.my/codes/tax-types/\n */\nexport type TaxTypeCode =\n | '01' // Sales Tax\n | '02' // Service Tax\n | '03' // Tourism Tax\n | '04' // High-Value Goods Tax\n | '05' // Sales Tax on Low Value Goods\n | '06' // Not Applicable\n | 'E' // Tax exemption (where applicable)\n\n/**\n * Enum representing the allowed tax type codes with descriptive names.\n * Provides a more readable way to reference tax types.\n *\n * @example\n * const code = TaxTypeCodeEnum.SalesTax;\n * console.log(code); // Output: \"01\"\n */\nexport enum TaxTypeCodeEnum {\n SalesTax = '01',\n ServiceTax = '02',\n TourismTax = '03',\n HighValueGoodsTax = '04',\n SalesTaxLowValueGoods = '05',\n NotApplicable = '06',\n TaxExemption = 'E',\n}\n\n/**\n * Interface representing a tax type entry.\n * Contains the code and its corresponding description.\n */\nexport interface TaxType {\n code: TaxTypeCode\n description: string\n}\n"],"mappings":";;;;;;;;;;AAqBA,IAAY,8DAAL;AACL;AACA;AACA;AACA;AACA;AACA;AACA;;AACD"}
|
package/dist/index15.cjs
CHANGED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//#region src/types/notifications.d.ts
|
|
3
|
-
let NotificationTypeEnum = /* @__PURE__ */ function(NotificationTypeEnum$1) {
|
|
4
|
-
NotificationTypeEnum$1[NotificationTypeEnum$1["Profile data validation"] = 3] = "Profile data validation";
|
|
5
|
-
NotificationTypeEnum$1[NotificationTypeEnum$1["Document received"] = 6] = "Document received";
|
|
6
|
-
NotificationTypeEnum$1[NotificationTypeEnum$1["Document validated"] = 7] = "Document validated";
|
|
7
|
-
NotificationTypeEnum$1[NotificationTypeEnum$1["Document cancelled"] = 8] = "Document cancelled";
|
|
8
|
-
NotificationTypeEnum$1[NotificationTypeEnum$1["User profile changed"] = 10] = "User profile changed";
|
|
9
|
-
NotificationTypeEnum$1[NotificationTypeEnum$1["Taxpayer profile changed"] = 11] = "Taxpayer profile changed";
|
|
10
|
-
NotificationTypeEnum$1[NotificationTypeEnum$1["Document rejection initiated"] = 15] = "Document rejection initiated";
|
|
11
|
-
NotificationTypeEnum$1[NotificationTypeEnum$1["ERP data validation"] = 26] = "ERP data validation";
|
|
12
|
-
NotificationTypeEnum$1[NotificationTypeEnum$1["Documents processing summary"] = 33] = "Documents processing summary";
|
|
13
|
-
NotificationTypeEnum$1[NotificationTypeEnum$1["Document Template Published"] = 34] = "Document Template Published";
|
|
14
|
-
NotificationTypeEnum$1[NotificationTypeEnum$1["Document Template Deletion"] = 35] = "Document Template Deletion";
|
|
15
|
-
return NotificationTypeEnum$1;
|
|
16
|
-
}({});
|
|
17
|
-
let NotificationStatusEnum = /* @__PURE__ */ function(NotificationStatusEnum$1) {
|
|
18
|
-
NotificationStatusEnum$1[NotificationStatusEnum$1["New"] = 1] = "New";
|
|
19
|
-
NotificationStatusEnum$1[NotificationStatusEnum$1["Pending"] = 2] = "Pending";
|
|
20
|
-
NotificationStatusEnum$1[NotificationStatusEnum$1["Batched"] = 3] = "Batched";
|
|
21
|
-
NotificationStatusEnum$1[NotificationStatusEnum$1["Delivered"] = 4] = "Delivered";
|
|
22
|
-
NotificationStatusEnum$1[NotificationStatusEnum$1["Error"] = 5] = "Error";
|
|
23
|
-
return NotificationStatusEnum$1;
|
|
24
|
-
}({});
|
|
25
|
-
|
|
26
|
-
//#endregion
|
|
27
|
-
exports.NotificationStatusEnum = NotificationStatusEnum;
|
|
28
|
-
exports.NotificationTypeEnum = NotificationTypeEnum;
|
|
29
|
-
//# sourceMappingURL=index15.cjs.map
|
package/dist/index16.cjs
CHANGED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//#region src/types/payment-modes.d.ts
|
|
3
|
-
/**
|
|
4
|
-
* Enum representing the allowed payment mode codes with descriptive names.
|
|
5
|
-
* Provides a more readable way to reference payment modes.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* const mode = PaymentModeCodeEnum.Cash;
|
|
9
|
-
* console.log(mode); // Output: "01"
|
|
10
|
-
*/
|
|
11
|
-
let PaymentModeCodeEnum = /* @__PURE__ */ function(PaymentModeCodeEnum$1) {
|
|
12
|
-
PaymentModeCodeEnum$1["Cash"] = "01";
|
|
13
|
-
PaymentModeCodeEnum$1["Cheque"] = "02";
|
|
14
|
-
PaymentModeCodeEnum$1["BankTransfer"] = "03";
|
|
15
|
-
PaymentModeCodeEnum$1["CreditCard"] = "04";
|
|
16
|
-
PaymentModeCodeEnum$1["DebitCard"] = "05";
|
|
17
|
-
PaymentModeCodeEnum$1["EWalletDigitalWallet"] = "06";
|
|
18
|
-
PaymentModeCodeEnum$1["DigitalBank"] = "07";
|
|
19
|
-
PaymentModeCodeEnum$1["Others"] = "08";
|
|
20
|
-
return PaymentModeCodeEnum$1;
|
|
21
|
-
}({});
|
|
22
|
-
|
|
23
|
-
//#endregion
|
|
24
|
-
exports.PaymentModeCodeEnum = PaymentModeCodeEnum;
|
|
25
|
-
//# sourceMappingURL=index16.cjs.map
|
package/dist/index17.cjs
CHANGED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
const require_documentManagement = require('./documentManagement-DQ7JEcBq.cjs');
|
|
2
|
+
|
|
3
|
+
exports.getDocument = require_documentManagement.getDocument;
|
|
4
|
+
exports.getDocumentDetails = require_documentManagement.getDocumentDetails;
|
|
5
|
+
exports.searchDocuments = require_documentManagement.searchDocuments;
|