didox 1.0.2 → 1.0.3

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/CHANGELOG.md ADDED
@@ -0,0 +1,128 @@
1
+ # Changelog
2
+
3
+ All notable changes to the Didox SDK will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [1.0.3] - 2026-01-16
9
+
10
+ ### Added
11
+ - **Product Classes (ИКПУ) Management**
12
+ - `getProductClassCodes()` - Get attached product class codes for current profile
13
+ - `searchProductClasses()` - Search available product classes with pagination
14
+ - `addProductClass()` - Add product class code to profile
15
+ - `removeProductClass()` - Remove product class code from profile
16
+ - `checkProductClassCode()` - Check product class code packages by TIN
17
+ - **VAT & Taxpayer Information**
18
+ - `getVatRegStatus()` - Get VAT registration status by TIN or PINFL
19
+ - `getTaxpayerType()` - Get taxpayer type information
20
+ - Support for historical data queries with date parameters
21
+ - **Warehouses Management**
22
+ - `getWarehouses()` - Get warehouses by TIN or PINFL
23
+ - **Company Users & Permissions**
24
+ - `updateCompanyUsersPermissions()` - Update company users permissions with signed tokens
25
+ - Support for GNK (tax committee) and Didox internal roles
26
+ - **Enhanced Profile Module**
27
+ - Modular architecture with sub-APIs for better organization
28
+ - Convenience methods for direct access to extended features
29
+ - **Comprehensive Type Definitions**
30
+ - Full TypeScript support for all new APIs
31
+ - Enums for VAT status codes and role codes
32
+ - Detailed interface definitions for all request/response objects
33
+
34
+ ### Technical Improvements
35
+ - Extended validation for TIN/PINFL formats
36
+ - Enhanced error handling for new endpoint types
37
+ - Maintained backward compatibility with existing APIs
38
+
39
+ ## [1.0.2] - 2026-01-16
40
+
41
+ ### Added
42
+
43
+ - **Profile module** - Complete company profile management API
44
+ - **Get current profile** - Retrieve detailed company information (`didox.profile.getProfile()`)
45
+ - **Update profile** - Update company profile with comprehensive validation (`didox.profile.updateProfile()`)
46
+ - **Profile operators** - Get operators associated with the profile (`didox.profile.getOperators()`)
47
+ - **Utilities module** - Helper functions for company data operations
48
+ - **Get branches by TIN** - Retrieve company branches by Tax ID (`didox.utilities.getBranchesByTin()`)
49
+
50
+ ### Technical Features
51
+
52
+ - **Enhanced validation** - Support for TIN (9 digits), PINFL (14 digits), VAT rates, regions
53
+ - **Comprehensive typing** - Full TypeScript support for all profile fields
54
+ - **Operator management** - Access to integrated platform operators (Didox, Faktura, etc.)
55
+ - **Branch queries** - Geographic and organizational branch information
56
+ - **Field filtering** - Only expose documented API fields in public types
57
+
58
+ ### Validation Rules
59
+
60
+ - **TIN validation** - Exactly 9 digits for company/director identification
61
+ - **PINFL validation** - Exactly 14 digits for personal identification
62
+ - **Notifications** - Only 0 (disabled) or 1 (enabled)
63
+ - **Region ID** - Numeric regional identifiers
64
+ - **VAT settings** - Number validation for VAT rates and excise flags
65
+
66
+ ### API Methods
67
+
68
+ - `didox.profile.getProfile()` - Get comprehensive company profile
69
+ - `didox.profile.updateProfile()` - Update company information
70
+ - `didox.profile.getOperators()` - List profile operators
71
+ - `didox.utilities.getBranchesByTin()` - Query branches by company TIN
72
+
73
+ ## [1.0.1] - 2026-01-16
74
+
75
+ ### Added
76
+
77
+ - **Account module** - Complete account/profile management API
78
+ - **Get current profile** - Retrieve authenticated user profile information (`didox.account.getProfile()`)
79
+ - **Update profile** - Update user profile with validation (`didox.account.updateProfile()`)
80
+ - **Input validation for profile update** - Strict validation for mobile, email, password, notifications
81
+ - **Enhanced authorization headers** - Automatic Partner-Authorization header management
82
+ - **TypeScript support for Account** - Full type definitions for profile operations
83
+
84
+ ### Technical Features
85
+
86
+ - **Mobile validation** - Format 998XXXXXXXXX (12 digits)
87
+ - **Email validation** - Standard email format validation
88
+ - **Password validation** - Optional field, minimum 8 characters when provided
89
+ - **Notifications validation** - Accepts only 0 (disabled) or 1 (enabled)
90
+ - **Dual authentication** - Supports both user-key and Partner-Authorization headers
91
+
92
+ ### API Methods
93
+
94
+ - `didox.account.getProfile()` - Get current user profile
95
+ - `didox.account.updateProfile()` - Update user profile information
96
+
97
+ ## [1.0.0] - 2026-01-16
98
+
99
+ ### Added
100
+
101
+ - **DidoxClient initialization** - Main SDK client with configuration management
102
+ - **Auth module** - Complete authentication API implementation
103
+ - **Legal entity login** - Authenticate legal entities with Tax ID and password
104
+ - **Individual to company login** - Switch context to company using individual token
105
+ - **Input validation** - Strict validation for all API parameters before requests
106
+ - **Typed errors** - Custom error classes for different failure scenarios:
107
+ - `DidoxValidationError` - Input validation failures
108
+ - `DidoxAuthError` - Authentication failures (422 status)
109
+ - `DidoxApiError` - API error responses (4xx, 5xx)
110
+ - `DidoxNetworkError` - Network and timeout errors
111
+ - **TypeScript support** - Full TypeScript definitions with strict typing
112
+ - **Environment configuration** - Support for development and production environments
113
+ - **Partner token authentication** - Secure API authorization using partner tokens
114
+ - **Token management** - Automatic token handling for authenticated requests
115
+ - **JSDoc documentation** - Complete IDE hints for all public methods
116
+ - **ESM + CJS builds** - Universal module support for modern and legacy Node.js
117
+
118
+ ### Technical Features
119
+
120
+ - **Node.js ≥ 18 support** - Modern Node.js runtime requirement
121
+ - **Zero external dependencies** - Uses native fetch API for HTTP requests
122
+ - **Modular architecture** - Clean separation of concerns across modules
123
+ - **Production-ready code** - Enterprise-grade error handling and validation
124
+
125
+ ### API Methods
126
+
127
+ - `didox.auth.loginLegalEntity()` - Legal entity authentication
128
+ - `didox.auth.loginCompanyAsIndividual()` - Company context switching
package/README.md CHANGED
@@ -292,6 +292,174 @@ try {
292
292
  }
293
293
  ```
294
294
 
295
+ ## Product Classes (ИКПУ)
296
+
297
+ Manage product classification codes for your company profile.
298
+
299
+ ### Get Attached Product Classes
300
+
301
+ Retrieve product classes currently attached to your profile:
302
+
303
+ ```typescript
304
+ try {
305
+ const result = await didox.profile.getProductClassCodes();
306
+
307
+ console.log('Total attached classes:', result.data.length);
308
+
309
+ result.data.forEach(productClass => {
310
+ console.log(`Code: ${productClass.classCode}`);
311
+ console.log(`Name: ${productClass.className}`);
312
+ console.log(`Packages: ${productClass.packages.length} available`);
313
+ console.log('---');
314
+ });
315
+ } catch (error) {
316
+ console.error('Failed to get product classes:', error.message);
317
+ }
318
+ ```
319
+
320
+ ### Search Available Product Classes
321
+
322
+ Search for product classes you can attach to your profile:
323
+
324
+ ```typescript
325
+ try {
326
+ const result = await didox.profile.searchProductClasses({
327
+ search: 'фото',
328
+ lang: 'ru',
329
+ page: 1
330
+ });
331
+
332
+ console.log(`Found ${result.total} classes (page ${result.current_page})`);
333
+
334
+ result.data.forEach(productClass => {
335
+ console.log(`Code: ${productClass.classCode}`);
336
+ console.log(`Name: ${productClass.className_ru}`);
337
+ console.log(`Origin: ${productClass.origin.name}`);
338
+ });
339
+ } catch (error) {
340
+ console.error('Failed to search product classes:', error.message);
341
+ }
342
+ ```
343
+
344
+ ### Add/Remove Product Classes
345
+
346
+ ```typescript
347
+ try {
348
+ // Add a product class
349
+ await didox.profile.addProductClass('08418001001013043');
350
+ console.log('Product class added successfully');
351
+
352
+ // Remove a product class
353
+ await didox.profile.removeProductClass('08418001001013043');
354
+ console.log('Product class removed successfully');
355
+ } catch (error) {
356
+ console.error('Failed to manage product class:', error.message);
357
+ }
358
+ ```
359
+
360
+ ## VAT & Taxpayer Information
361
+
362
+ Get VAT registration and taxpayer type information.
363
+
364
+ ### VAT Registration Status
365
+
366
+ Check VAT registration status by TIN or PINFL:
367
+
368
+ ```typescript
369
+ try {
370
+ const vatStatus = await didox.profile.getVatRegStatus('123456789');
371
+
372
+ console.log(`VAT Registration Code: ${vatStatus.vatRegCode}`);
373
+ console.log(`VAT Status: ${vatStatus.vatRegStatus}`);
374
+
375
+ // Status codes:
376
+ // 10 - Плательщик НДС
377
+ // 20 - Плательщик НДС+ (сертификат активный)
378
+ // 21 - Плательщик НДС+ (сертификат неактивный)
379
+ // 30 - Плательщик налога с оборота
380
+ // 50 - Индивидуальный предприниматель
381
+ // 60 - Физическое лицо
382
+ } catch (error) {
383
+ console.error('Failed to get VAT status:', error.message);
384
+ }
385
+ ```
386
+
387
+ ### Taxpayer Type
388
+
389
+ Get taxpayer type information:
390
+
391
+ ```typescript
392
+ try {
393
+ const taxpayerType = await didox.profile.getTaxpayerType(
394
+ '123456789', // TIN
395
+ 'ru', // Language
396
+ '17.01.2022' // Optional date
397
+ );
398
+
399
+ console.log(`Code: ${taxpayerType.code}`);
400
+ console.log(`Name: ${taxpayerType.name}`);
401
+ } catch (error) {
402
+ console.error('Failed to get taxpayer type:', error.message);
403
+ }
404
+ ```
405
+
406
+ ## Warehouses
407
+
408
+ Get warehouse information by TIN or PINFL.
409
+
410
+ ```typescript
411
+ try {
412
+ const warehouses = await didox.profile.getWarehouses('123456789');
413
+
414
+ console.log(`Found ${warehouses.length} warehouses`);
415
+
416
+ warehouses.forEach(warehouse => {
417
+ console.log(`Warehouse #${warehouse.warehouseNumber}`);
418
+ console.log(`Name: ${warehouse.warehouseName}`);
419
+ console.log(`Address: ${warehouse.warehouseAddress}`);
420
+ console.log('---');
421
+ });
422
+ } catch (error) {
423
+ console.error('Failed to get warehouses:', error.message);
424
+ }
425
+ ```
426
+
427
+ ## Company Users & Permissions
428
+
429
+ Manage company user permissions with signed tokens.
430
+
431
+ ```typescript
432
+ try {
433
+ await didox.profile.updateCompanyUsersPermissions({
434
+ gnkpermissions: 'base64-signed-gnk-roles-token',
435
+ internalpermissions: 'base64-signed-didox-roles-token',
436
+ is_director: 1
437
+ });
438
+
439
+ console.log('User permissions updated successfully');
440
+ } catch (error) {
441
+ console.error('Failed to update permissions:', error.message);
442
+ }
443
+ ```
444
+
445
+ **Note**: This API requires externally signed tokens. The SDK does not generate signatures - you must prepare and sign the role JSONs externally before calling this method.
446
+
447
+ ### Role Codes Reference
448
+
449
+ **GNK (Tax Committee) Roles:**
450
+ - 11 - Отправка / отмена ЭСФ
451
+ - 12 - Подтверждение / отклонение ЭСФ
452
+ - 21 - Отправка / отмена доверенностей
453
+ - 22 - Подтверждение / отклонение доверенностей
454
+ - And more...
455
+
456
+ **Didox Internal Roles:**
457
+ - 191 - Отправка / отмена заказов
458
+ - 192 - Подтверждение / отклонение заказов
459
+ - 59 - Создание договоров
460
+ - 199 - Создание заказов
461
+ - And more...
462
+
295
463
  ## Error Handling
296
464
 
297
465
  The SDK provides specific error classes for different failure scenarios: