@vulog/aima-document 1.1.88 → 1.1.91

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1 +1,218 @@
1
1
  # @vulog/aima-document
2
+
3
+ Document management module for the AIMA platform. This module provides functionality to manage user documents, including creation, updates, and status management.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @vulog/aima-client @vulog/aima-core @vulog/aima-document
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ### Initialize Client
14
+
15
+ ```javascript
16
+ import { getClient } from '@vulog/aima-client';
17
+ import { createOrUpdateDocument, getUserDocuments, updateDocumentStatus } from '@vulog/aima-document';
18
+
19
+ const client = getClient({
20
+ apiKey: 'your-api-key',
21
+ baseUrl: 'https://your-api-base-url',
22
+ clientId: 'your-client-id',
23
+ clientSecret: 'your-client-secret',
24
+ fleetId: 'your-fleet-id',
25
+ });
26
+ ```
27
+
28
+ ## API Reference
29
+
30
+ ### createOrUpdateDocument
31
+
32
+ Create a new document or update an existing one for a user.
33
+
34
+ ```javascript
35
+ const document = await createOrUpdateDocument(client, {
36
+ entityId: 'user-uuid-here',
37
+ documentType: 'DRIVER_LICENSE',
38
+ fileData: 'base64-encoded-file-data',
39
+ fileName: 'license.pdf',
40
+ mimeType: 'application/pdf'
41
+ });
42
+ ```
43
+
44
+ **Parameters:**
45
+ - `client`: AIMA client instance
46
+ - `payload`: Document configuration object
47
+ - `entityId`: User UUID
48
+ - `documentType`: Type of document (e.g., 'DRIVER_LICENSE', 'ID_CARD', 'PASSPORT')
49
+ - `fileData`: Base64 encoded file data
50
+ - `fileName`: Name of the file
51
+ - `mimeType`: MIME type of the file
52
+
53
+ ### getUserDocuments
54
+
55
+ Retrieve all documents for a specific user.
56
+
57
+ ```javascript
58
+ const documents = await getUserDocuments(client, 'user-uuid-here');
59
+ ```
60
+
61
+ **Parameters:**
62
+ - `client`: AIMA client instance
63
+ - `entityId`: User UUID
64
+
65
+ **Returns:** Array of user documents
66
+
67
+ ### updateDocumentStatus
68
+
69
+ Update the status of a document.
70
+
71
+ ```javascript
72
+ const updatedDocument = await updateDocumentStatus(client, {
73
+ documentId: 'document-id-here',
74
+ status: 'APPROVED',
75
+ notes: 'Document verified successfully'
76
+ });
77
+ ```
78
+
79
+ **Parameters:**
80
+ - `client`: AIMA client instance
81
+ - `payload`: Status update configuration
82
+ - `documentId`: Document identifier
83
+ - `status`: New status ('PENDING', 'APPROVED', 'REJECTED')
84
+ - `notes`: Optional notes about the status change
85
+
86
+ ## Types
87
+
88
+ ### Document
89
+
90
+ ```typescript
91
+ interface Document {
92
+ id: string;
93
+ entityId: string;
94
+ documentType: string;
95
+ fileName: string;
96
+ mimeType: string;
97
+ fileSize: number;
98
+ status: 'PENDING' | 'APPROVED' | 'REJECTED';
99
+ uploadDate: string;
100
+ lastModified: string;
101
+ notes?: string;
102
+ }
103
+ ```
104
+
105
+ ### DocumentType
106
+
107
+ Common document types include:
108
+ - `DRIVER_LICENSE`: Driver's license
109
+ - `ID_CARD`: National ID card
110
+ - `PASSPORT`: Passport
111
+ - `INSURANCE`: Insurance document
112
+ - `REGISTRATION`: Vehicle registration
113
+
114
+ ## Error Handling
115
+
116
+ All functions include validation and will throw appropriate errors if:
117
+ - Required parameters are missing
118
+ - Invalid document types are provided
119
+ - File data is invalid
120
+ - User or document not found
121
+
122
+ ## Examples
123
+
124
+ ### Complete Document Management Workflow
125
+
126
+ ```javascript
127
+ import { getClient } from '@vulog/aima-client';
128
+ import { createOrUpdateDocument, getUserDocuments, updateDocumentStatus } from '@vulog/aima-document';
129
+ import fs from 'fs';
130
+
131
+ const client = getClient({
132
+ apiKey: 'your-api-key',
133
+ baseUrl: 'https://your-api-base-url',
134
+ clientId: 'your-client-id',
135
+ clientSecret: 'your-client-secret',
136
+ fleetId: 'your-fleet-id',
137
+ });
138
+
139
+ async function documentWorkflow() {
140
+ try {
141
+ // Read and encode a file
142
+ const fileBuffer = fs.readFileSync('path/to/license.pdf');
143
+ const base64Data = fileBuffer.toString('base64');
144
+
145
+ // Create a new document
146
+ const document = await createOrUpdateDocument(client, {
147
+ entityId: 'user-uuid-here',
148
+ documentType: 'DRIVER_LICENSE',
149
+ fileData: base64Data,
150
+ fileName: 'license.pdf',
151
+ mimeType: 'application/pdf'
152
+ });
153
+
154
+ console.log('Document created:', document);
155
+
156
+ // Get all user documents
157
+ const documents = await getUserDocuments(client, 'user-uuid-here');
158
+ console.log('User documents:', documents);
159
+
160
+ // Update document status
161
+ const updatedDocument = await updateDocumentStatus(client, {
162
+ documentId: document.id,
163
+ status: 'APPROVED',
164
+ notes: 'License verified and approved'
165
+ });
166
+
167
+ console.log('Document status updated:', updatedDocument);
168
+
169
+ } catch (error) {
170
+ console.error('Document management error:', error);
171
+ }
172
+ }
173
+ ```
174
+
175
+ ### File Upload Helper
176
+
177
+ ```javascript
178
+ import { createOrUpdateDocument } from '@vulog/aima-document';
179
+ import fs from 'fs';
180
+
181
+ async function uploadDocument(client, filePath, documentType, entityId) {
182
+ try {
183
+ // Read file
184
+ const fileBuffer = fs.readFileSync(filePath);
185
+ const base64Data = fileBuffer.toString('base64');
186
+
187
+ // Get file info
188
+ const stats = fs.statSync(filePath);
189
+ const fileName = filePath.split('/').pop();
190
+ const mimeType = getMimeType(fileName);
191
+
192
+ // Upload document
193
+ return await createOrUpdateDocument(client, {
194
+ entityId,
195
+ documentType,
196
+ fileData: base64Data,
197
+ fileName,
198
+ mimeType
199
+ });
200
+ } catch (error) {
201
+ console.error('File upload error:', error);
202
+ throw error;
203
+ }
204
+ }
205
+
206
+ function getMimeType(fileName) {
207
+ const ext = fileName.split('.').pop().toLowerCase();
208
+ const mimeTypes = {
209
+ 'pdf': 'application/pdf',
210
+ 'jpg': 'image/jpeg',
211
+ 'jpeg': 'image/jpeg',
212
+ 'png': 'image/png',
213
+ 'doc': 'application/msword',
214
+ 'docx': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
215
+ };
216
+ return mimeTypes[ext] || 'application/octet-stream';
217
+ }
218
+ ```
package/dist/index.d.mts CHANGED
@@ -33,9 +33,10 @@ type DocumentFull = {
33
33
  status: DocumentStatus;
34
34
  reviewer?: string;
35
35
  issuingCountry?: 'AD' | 'AE' | 'AF' | 'AG' | 'AI' | 'AL' | 'AM' | 'AN' | 'AO' | 'AQ' | 'AR' | 'AS' | 'AT' | 'AU' | 'AW' | 'AX' | 'AZ' | 'BA' | 'BB' | 'BD' | 'BE' | 'BF' | 'BG' | 'BH' | 'BI' | 'BJ' | 'BL' | 'BM' | 'BN' | 'BO' | 'BQ' | 'BR' | 'BS' | 'BT' | 'BV' | 'BW' | 'BY' | 'BZ' | 'CA' | 'CC' | 'CD' | 'CF' | 'CG' | 'CH' | 'CI' | 'CK' | 'CL' | 'CM' | 'CN' | 'CO' | 'CR' | 'CU' | 'CV' | 'CW' | 'CX' | 'CY' | 'CZ' | 'DE' | 'DJ' | 'DK' | 'DM' | 'DO' | 'DZ' | 'EC' | 'EE' | 'EG' | 'EH' | 'ER' | 'ES' | 'ET' | 'FI' | 'FJ' | 'FK' | 'FM' | 'FO' | 'FR' | 'GA' | 'GB' | 'GD' | 'GE' | 'GF' | 'GG' | 'GH' | 'GI' | 'GL' | 'GM' | 'GN' | 'GP' | 'GQ' | 'GR' | 'GS' | 'GT' | 'GU' | 'GW' | 'GY' | 'HK' | 'HM' | 'HN' | 'HR' | 'HT' | 'HU' | 'ID' | 'IE' | 'IL' | 'IM' | 'IN' | 'IO' | 'IQ' | 'IR' | 'IS' | 'IT' | 'JE' | 'JM' | 'JO' | 'JP' | 'KE' | 'KG' | 'KH' | 'KI' | 'KM' | 'KN' | 'KP' | 'KR' | 'KW' | 'KY' | 'KZ' | 'LA' | 'LB' | 'LC' | 'LI' | 'LK' | 'LR' | 'LS' | 'LT' | 'LU' | 'LV' | 'LY' | 'MA' | 'MC' | 'MD' | 'ME' | 'MF' | 'MG' | 'MH' | 'MK' | 'ML' | 'MM' | 'MN' | 'MO' | 'MP' | 'MQ' | 'MR' | 'MS' | 'MT' | 'MU' | 'MV' | 'MW' | 'MX' | 'MY' | 'MZ' | 'NA' | 'NC' | 'NE' | 'NF' | 'NG' | 'NI' | 'NL' | 'NO' | 'NP' | 'NR' | 'NU' | 'NZ' | 'OM' | 'PA' | 'PE' | 'PF' | 'PG' | 'PH' | 'PK' | 'PL' | 'PM' | 'PN' | 'PR' | 'PS' | 'PT' | 'PW' | 'PY' | 'QA' | 'RE' | 'RO' | 'RS' | 'RU' | 'RW' | 'SA' | 'SB' | 'SC' | 'SD' | 'SE' | 'SG' | 'SH' | 'SI' | 'SJ' | 'SK' | 'SL' | 'SM' | 'SN' | 'SO' | 'SR' | 'SS' | 'ST' | 'SV' | 'SX' | 'SY' | 'SZ' | 'TC' | 'TD' | 'TF' | 'TG' | 'TH' | 'TJ' | 'TK' | 'TL' | 'TM' | 'TN' | 'TO' | 'TR' | 'TT' | 'TV' | 'TW' | 'TZ' | 'UA' | 'UG' | 'UM' | 'US' | 'UY' | 'UZ' | 'VA' | 'VC' | 'VE' | 'VG' | 'VI' | 'VN' | 'VU' | 'WF' | 'WS' | 'YE' | 'YT' | 'ZA' | 'ZM' | 'ZW';
36
- issuingOffice: string;
37
- issuingDate: string;
38
- dlClass: string;
36
+ issuingOffice?: string;
37
+ issuingDate?: string;
38
+ dlClass?: string;
39
+ issuingSubdivision?: string;
39
40
  };
40
41
  type DocumentBody = Partial<Omit<DocumentFull, 'id' | 'fleetId' | 'documentType' | 'files' | 'uploadUrls'> | 'status' | 'reviewer'> & {
41
42
  documentType: string;
package/dist/index.d.ts CHANGED
@@ -33,9 +33,10 @@ type DocumentFull = {
33
33
  status: DocumentStatus;
34
34
  reviewer?: string;
35
35
  issuingCountry?: 'AD' | 'AE' | 'AF' | 'AG' | 'AI' | 'AL' | 'AM' | 'AN' | 'AO' | 'AQ' | 'AR' | 'AS' | 'AT' | 'AU' | 'AW' | 'AX' | 'AZ' | 'BA' | 'BB' | 'BD' | 'BE' | 'BF' | 'BG' | 'BH' | 'BI' | 'BJ' | 'BL' | 'BM' | 'BN' | 'BO' | 'BQ' | 'BR' | 'BS' | 'BT' | 'BV' | 'BW' | 'BY' | 'BZ' | 'CA' | 'CC' | 'CD' | 'CF' | 'CG' | 'CH' | 'CI' | 'CK' | 'CL' | 'CM' | 'CN' | 'CO' | 'CR' | 'CU' | 'CV' | 'CW' | 'CX' | 'CY' | 'CZ' | 'DE' | 'DJ' | 'DK' | 'DM' | 'DO' | 'DZ' | 'EC' | 'EE' | 'EG' | 'EH' | 'ER' | 'ES' | 'ET' | 'FI' | 'FJ' | 'FK' | 'FM' | 'FO' | 'FR' | 'GA' | 'GB' | 'GD' | 'GE' | 'GF' | 'GG' | 'GH' | 'GI' | 'GL' | 'GM' | 'GN' | 'GP' | 'GQ' | 'GR' | 'GS' | 'GT' | 'GU' | 'GW' | 'GY' | 'HK' | 'HM' | 'HN' | 'HR' | 'HT' | 'HU' | 'ID' | 'IE' | 'IL' | 'IM' | 'IN' | 'IO' | 'IQ' | 'IR' | 'IS' | 'IT' | 'JE' | 'JM' | 'JO' | 'JP' | 'KE' | 'KG' | 'KH' | 'KI' | 'KM' | 'KN' | 'KP' | 'KR' | 'KW' | 'KY' | 'KZ' | 'LA' | 'LB' | 'LC' | 'LI' | 'LK' | 'LR' | 'LS' | 'LT' | 'LU' | 'LV' | 'LY' | 'MA' | 'MC' | 'MD' | 'ME' | 'MF' | 'MG' | 'MH' | 'MK' | 'ML' | 'MM' | 'MN' | 'MO' | 'MP' | 'MQ' | 'MR' | 'MS' | 'MT' | 'MU' | 'MV' | 'MW' | 'MX' | 'MY' | 'MZ' | 'NA' | 'NC' | 'NE' | 'NF' | 'NG' | 'NI' | 'NL' | 'NO' | 'NP' | 'NR' | 'NU' | 'NZ' | 'OM' | 'PA' | 'PE' | 'PF' | 'PG' | 'PH' | 'PK' | 'PL' | 'PM' | 'PN' | 'PR' | 'PS' | 'PT' | 'PW' | 'PY' | 'QA' | 'RE' | 'RO' | 'RS' | 'RU' | 'RW' | 'SA' | 'SB' | 'SC' | 'SD' | 'SE' | 'SG' | 'SH' | 'SI' | 'SJ' | 'SK' | 'SL' | 'SM' | 'SN' | 'SO' | 'SR' | 'SS' | 'ST' | 'SV' | 'SX' | 'SY' | 'SZ' | 'TC' | 'TD' | 'TF' | 'TG' | 'TH' | 'TJ' | 'TK' | 'TL' | 'TM' | 'TN' | 'TO' | 'TR' | 'TT' | 'TV' | 'TW' | 'TZ' | 'UA' | 'UG' | 'UM' | 'US' | 'UY' | 'UZ' | 'VA' | 'VC' | 'VE' | 'VG' | 'VI' | 'VN' | 'VU' | 'WF' | 'WS' | 'YE' | 'YT' | 'ZA' | 'ZM' | 'ZW';
36
- issuingOffice: string;
37
- issuingDate: string;
38
- dlClass: string;
36
+ issuingOffice?: string;
37
+ issuingDate?: string;
38
+ dlClass?: string;
39
+ issuingSubdivision?: string;
39
40
  };
40
41
  type DocumentBody = Partial<Omit<DocumentFull, 'id' | 'fleetId' | 'documentType' | 'files' | 'uploadUrls'> | 'status' | 'reviewer'> & {
41
42
  documentType: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vulog/aima-document",
3
- "version": "1.1.88",
3
+ "version": "1.1.91",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
@@ -19,8 +19,8 @@
19
19
  "author": "Vulog",
20
20
  "license": "MIT",
21
21
  "dependencies": {
22
- "@vulog/aima-client": "1.1.88",
23
- "@vulog/aima-core": "1.1.88"
22
+ "@vulog/aima-client": "1.1.91",
23
+ "@vulog/aima-core": "1.1.91"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "zod": "^3.25.76"
@@ -30,17 +30,35 @@ describe('getUserDocument', () => {
30
30
  hasNumber: true,
31
31
  hasExpirationDate: false,
32
32
  numberUploadUrl: 2,
33
- hasIssuingCountry: false,
33
+ hasIssuingCountry: true,
34
34
  hasIssuingOffice: true,
35
35
  hasIssuingDate: true,
36
- hasDlClass: false
36
+ hasDlClass: true,
37
+ hasIssuingSubdivision: true,
37
38
  }
39
+ const docTypeSelfie = {
40
+ id: 460,
41
+ fleetId: FLEET_ID,
42
+ type: 'SELFIE',
43
+ name: 'Selfie',
44
+ mandatory: false,
45
+ hasNumber: false,
46
+ hasExpirationDate: false,
47
+ numberUploadUrl: 1,
48
+ hasIssuingCountry: false,
49
+ hasIssuingOffice: false,
50
+ hasIssuingDate: false,
51
+ hasDlClass: false,
52
+ hasIssuingSubdivision: false
53
+ };
38
54
  const idDocId = 10892065;
39
55
  const dlDocId = 10892077;
56
+ const selfieDocId = 10931811;
40
57
  const documents = {
41
58
  documentTypes: [
42
59
  { ...docTypeId },
43
- { ...docTypeDl}
60
+ { ...docTypeDl },
61
+ { ...docTypeSelfie },
44
62
  ],
45
63
  documents: [
46
64
  {
@@ -49,6 +67,7 @@ describe('getUserDocument', () => {
49
67
  userId: USER_ID,
50
68
  documentType: { ...docTypeId },
51
69
  expirationDate: '1970-01-01',
70
+ approvalDate: null,
52
71
  files: [
53
72
  {
54
73
  id: null,
@@ -69,6 +88,7 @@ describe('getUserDocument', () => {
69
88
  issuingOffice: 'Nice, 06',
70
89
  issuingDate: '2023-01-16',
71
90
  dlClass: null,
91
+ issuingSubdivision: null,
72
92
  documentNumber: null
73
93
  },
74
94
  {
@@ -77,6 +97,7 @@ describe('getUserDocument', () => {
77
97
  userId: USER_ID,
78
98
  documentType: { ...docTypeDl },
79
99
  expirationDate: '1970-01-01',
100
+ approvalDate: null,
80
101
  files: [
81
102
  {
82
103
  id: null,
@@ -103,12 +124,43 @@ describe('getUserDocument', () => {
103
124
  ],
104
125
  status: 'VALID',
105
126
  reviewer: '493a4d98-7437-42db-8d4e-bd722ac62caf',
106
- issuingCountry: null,
127
+ issuingCountry: 'FR',
107
128
  issuingOffice: 'Nice',
108
129
  issuingDate: '1994-02-18',
130
+ dlClass: 'B',
131
+ issuingSubdivision: '06',
132
+ documentNumber: '123456'
133
+ },
134
+ {
135
+ id: selfieDocId,
136
+ fleetId: FLEET_ID,
137
+ userId: USER_ID,
138
+ documentType: { ...docTypeSelfie },
139
+ expirationDate: null,
140
+ approvalDate: null,
141
+ files: [
142
+ {
143
+ id: null,
144
+ url: 'https://java-eu01.vulog.com/upload/fleets/${FLEET_ID}/file?tk=sbSfJzSpv8xJ4FN7ETn5Zq5ykKoAmYKIpFjvVPzVpsCcAGmrMWNJ3h4NunQu***',
145
+ name: `${docTypeSelfie.type}_0`,
146
+ }
147
+ ],
148
+ uploadUrls: [
149
+ {
150
+ id: null,
151
+ url: 'https://java-eu01.vulog.com/upload/fleets/${FLEET_ID}/documents/10931800/SELFIE_0?tk=sbSfJzSpv8xJ4FN7ETn5Zn1MGPxqzzDIvE1WJ***',
152
+ name: `${docTypeSelfie.type}_0`,
153
+ }
154
+ ],
155
+ status: 'VALID',
156
+ reviewer: 'Registration',
157
+ issuingCountry: null,
158
+ issuingOffice: null,
159
+ issuingDate: null,
109
160
  dlClass: null,
161
+ issuingSubdivision: null,
110
162
  documentNumber: null
111
- }
163
+ },
112
164
  ],
113
165
  documentByService: [
114
166
  {
@@ -179,6 +231,19 @@ describe('getUserDocument', () => {
179
231
  config: {}
180
232
  });
181
233
  }
234
+ else if (url.startsWith(`/boapi/proxy/user/fleets/${FLEET_ID}/users/${USER_ID}/documents/${selfieDocId}/pi`)) {
235
+ return Promise.resolve({
236
+ data: {
237
+ fleetId: FLEET_ID,
238
+ userId: USER_ID,
239
+ documentId: selfieDocId
240
+ },
241
+ status: 200,
242
+ statusText: 'OK',
243
+ headers: {},
244
+ config: {}
245
+ });
246
+ }
182
247
  // Pour les autres URLs, rejetez la promesse
183
248
  return Promise.reject(new Error('404 Not Found'));
184
249
  });
@@ -197,17 +262,64 @@ describe('getUserDocument', () => {
197
262
  expect(docs).toBeTruthy();
198
263
  expect(docs.documents).toBeTruthy();
199
264
  expect(docs.documents.length).toEqual(documents.documents.length);
200
- expect(docs.documents.length).toEqual(2);
265
+ expect(docs.documents.length).toEqual(3);
201
266
  expect(docs.documents[0].id).toEqual(documents.documents[0].id);
202
267
  expect(docs.documents[0].documentNumber).toBeNull();
203
268
  expect(docs.documents[1].id).toEqual(documents.documents[1].id);
204
- expect(docs.documents[1].documentNumber).toBeNull();
269
+ expect(docs.documents[1].documentNumber).toEqual(documents.documents[1].documentNumber);
270
+ expect(docs.documents[2].id).toEqual(documents.documents[2].id);
271
+ expect(docs.documents[2].documentNumber).toBeNull();
272
+
273
+ expect(docs.documents[0].fleetId).toEqual(documents.documents[0].fleetId);
274
+ expect(docs.documents[0].userId).toEqual(documents.documents[0].userId);
275
+ expect(docs.documents[0].documentType).not.toBeNull();
276
+ expect(docs.documents[0].documentNumber).toEqual(documents.documents[0].documentNumber);
277
+ expect(docs.documents[0].expirationDate).toEqual(documents.documents[0].expirationDate);
278
+ expect(docs.documents[0].files).toEqual(documents.documents[0].files);
279
+ expect(docs.documents[0].uploadUrls).toEqual(documents.documents[0].uploadUrls);
280
+ expect(docs.documents[0].status).toEqual(documents.documents[0].status);
281
+ expect(docs.documents[0].reviewer).toEqual(documents.documents[0].reviewer);
282
+ expect(docs.documents[0].issuingCountry).toEqual(documents.documents[0].issuingCountry);
283
+ expect(docs.documents[0].issuingOffice).toEqual(documents.documents[0].issuingOffice);
284
+ expect(docs.documents[0].issuingDate).toEqual(documents.documents[0].issuingDate);
285
+ expect(docs.documents[0].dlClass).toEqual(documents.documents[0].dlClass);
286
+ expect(docs.documents[0].issuingSubdivision).toEqual(documents.documents[0].issuingSubdivision);
287
+
288
+ expect(docs.documents[1].fleetId).toEqual(documents.documents[1].fleetId);
289
+ expect(docs.documents[1].userId).toEqual(documents.documents[1].userId);
290
+ expect(docs.documents[1].documentType).not.toBeNull();
291
+ expect(docs.documents[1].documentNumber).toEqual(documents.documents[1].documentNumber);
292
+ expect(docs.documents[1].expirationDate).toEqual(documents.documents[1].expirationDate);
293
+ expect(docs.documents[1].files).toEqual(documents.documents[1].files);
294
+ expect(docs.documents[1].uploadUrls).toEqual(documents.documents[1].uploadUrls);
295
+ expect(docs.documents[1].status).toEqual(documents.documents[1].status);
296
+ expect(docs.documents[1].reviewer).toEqual(documents.documents[1].reviewer);
297
+ expect(docs.documents[1].issuingCountry).toEqual(documents.documents[1].issuingCountry);
298
+ expect(docs.documents[1].issuingOffice).toEqual(documents.documents[1].issuingOffice);
299
+ expect(docs.documents[1].issuingDate).toEqual(documents.documents[1].issuingDate);
300
+ expect(docs.documents[1].dlClass).toEqual(documents.documents[1].dlClass);
301
+ expect(docs.documents[1].issuingSubdivision).toEqual(documents.documents[1].issuingSubdivision);
302
+
303
+ expect(docs.documents[2].fleetId).toEqual(documents.documents[2].fleetId);
304
+ expect(docs.documents[2].userId).toEqual(documents.documents[2].userId);
305
+ expect(docs.documents[2].documentType).not.toBeNull();
306
+ expect(docs.documents[2].documentNumber).toEqual(documents.documents[2].documentNumber);
307
+ expect(docs.documents[2].expirationDate).toEqual(documents.documents[2].expirationDate);
308
+ expect(docs.documents[2].files).toEqual(documents.documents[2].files);
309
+ expect(docs.documents[2].uploadUrls).toEqual(documents.documents[2].uploadUrls);
310
+ expect(docs.documents[2].status).toEqual(documents.documents[2].status);
311
+ expect(docs.documents[2].reviewer).toEqual(documents.documents[2].reviewer);
312
+ expect(docs.documents[2].issuingCountry).toEqual(documents.documents[2].issuingCountry);
313
+ expect(docs.documents[2].issuingOffice).toEqual(documents.documents[2].issuingOffice);
314
+ expect(docs.documents[2].issuingDate).toEqual(documents.documents[2].issuingDate);
315
+ expect(docs.documents[2].dlClass).toEqual(documents.documents[2].dlClass);
316
+ expect(docs.documents[2].issuingSubdivision).toEqual(documents.documents[2].issuingSubdivision);
205
317
  });
206
318
 
207
319
  test('call with PI', async () => {
208
320
 
209
321
  const docs = await getUserDocuments(client, USER_ID, ['DOCUMENT_NUMBER_1']);
210
- expect(getMock).toHaveBeenCalledTimes(3);
322
+ expect(getMock).toHaveBeenCalledTimes(4);
211
323
  expect(getMock).toBeCalledWith(`/boapi/proxy/user/fleets/${FLEET_ID}/users/${USER_ID}/documents`);
212
324
  expect(getMock).toBeCalledWith(`/boapi/proxy/user/fleets/${FLEET_ID}/users/${USER_ID}/documents/${idDocId}/pi?types=DOCUMENT_NUMBER_1`);
213
325
  expect(getMock).toBeCalledWith(`/boapi/proxy/user/fleets/${FLEET_ID}/users/${USER_ID}/documents/${dlDocId}/pi?types=DOCUMENT_NUMBER_1`);
@@ -215,11 +327,14 @@ describe('getUserDocument', () => {
215
327
  expect(docs).toBeTruthy();
216
328
  expect(docs.documents).toBeTruthy();
217
329
  expect(docs.documents.length).toEqual(documents.documents.length);
218
- expect(docs.documents.length).toEqual(2);
330
+ expect(docs.documents.length).toEqual(3);
219
331
  expect(docs.documents[0].id).toEqual(documents.documents[0].id);
220
332
  expect(docs.documents[0].documentNumber).toBeTruthy();
221
333
  expect(docs.documents[1].id).toEqual(documents.documents[1].id);
222
334
  expect(docs.documents[1].documentNumber).toBeTruthy();
335
+ expect(docs.documents[2].id).toEqual(documents.documents[2].id);
336
+ expect(docs.documents[2].documentNumber).toBeFalsy();
337
+
223
338
  if(docs.documents[0].id === idDocId) {
224
339
  expect(docs.documents[0].documentNumber).toEqual(piId.documentNumber1);
225
340
  expect(docs.documents[1].documentNumber).toEqual(piDl.documentNumber1);
package/src/types.ts CHANGED
@@ -285,9 +285,10 @@ export type DocumentFull = {
285
285
  | 'ZA'
286
286
  | 'ZM'
287
287
  | 'ZW';
288
- issuingOffice: string;
289
- issuingDate: string;
290
- dlClass: string;
288
+ issuingOffice?: string;
289
+ issuingDate?: string;
290
+ dlClass?: string;
291
+ issuingSubdivision?: string;
291
292
  };
292
293
 
293
294
  export type DocumentBody = Partial<