hvp-shared 6.4.0 → 6.6.0
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/constants/background-job.constants.d.ts +50 -0
- package/dist/constants/background-job.constants.js +76 -0
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/index.js +1 -0
- package/dist/contracts/index.d.ts +1 -0
- package/dist/contracts/index.js +1 -0
- package/dist/contracts/qvet/index.d.ts +4 -0
- package/dist/contracts/qvet/index.js +20 -0
- package/dist/contracts/qvet/responses.d.ts +101 -0
- package/dist/contracts/qvet/responses.js +8 -0
- package/dist/types/background-job.types.d.ts +107 -0
- package/dist/types/background-job.types.js +8 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Background Job Constants
|
|
3
|
+
*
|
|
4
|
+
* Enums and constants for background job system.
|
|
5
|
+
* Used by frontend (polling) and backend (job execution).
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Job types for QVET sync operations
|
|
9
|
+
*/
|
|
10
|
+
export declare enum JobType {
|
|
11
|
+
SYNC_SALES = "SYNC_SALES",
|
|
12
|
+
SYNC_PURCHASES = "SYNC_PURCHASES",
|
|
13
|
+
SYNC_INVENTORY = "SYNC_INVENTORY",
|
|
14
|
+
SYNC_TRANSFERS = "SYNC_TRANSFERS",
|
|
15
|
+
SYNC_MOVEMENTS = "SYNC_MOVEMENTS",
|
|
16
|
+
SYNC_STOCK_CONFIG = "SYNC_STOCK_CONFIG",
|
|
17
|
+
SYNC_CATALOG = "SYNC_CATALOG",
|
|
18
|
+
SYNC_ALL = "SYNC_ALL"
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Job execution status
|
|
22
|
+
*/
|
|
23
|
+
export declare enum JobStatus {
|
|
24
|
+
PENDING = "pending",
|
|
25
|
+
PROCESSING = "processing",
|
|
26
|
+
COMPLETED = "completed",
|
|
27
|
+
FAILED = "failed",
|
|
28
|
+
CANCELLED = "cancelled"
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Current step within a sync job
|
|
32
|
+
*/
|
|
33
|
+
export declare enum JobStep {
|
|
34
|
+
DOWNLOAD = "download",
|
|
35
|
+
PARSE = "parse",
|
|
36
|
+
TRANSFORM = "transform",
|
|
37
|
+
SYNC = "sync"
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Human-readable labels for job types (Spanish for UI)
|
|
41
|
+
*/
|
|
42
|
+
export declare const JOB_TYPE_LABELS: Record<JobType, string>;
|
|
43
|
+
/**
|
|
44
|
+
* Human-readable labels for job steps (Spanish for UI)
|
|
45
|
+
*/
|
|
46
|
+
export declare const JOB_STEP_LABELS: Record<JobStep, string>;
|
|
47
|
+
/**
|
|
48
|
+
* Human-readable labels for job status (Spanish for UI)
|
|
49
|
+
*/
|
|
50
|
+
export declare const JOB_STATUS_LABELS: Record<JobStatus, string>;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Background Job Constants
|
|
4
|
+
*
|
|
5
|
+
* Enums and constants for background job system.
|
|
6
|
+
* Used by frontend (polling) and backend (job execution).
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.JOB_STATUS_LABELS = exports.JOB_STEP_LABELS = exports.JOB_TYPE_LABELS = exports.JobStep = exports.JobStatus = exports.JobType = void 0;
|
|
10
|
+
/**
|
|
11
|
+
* Job types for QVET sync operations
|
|
12
|
+
*/
|
|
13
|
+
var JobType;
|
|
14
|
+
(function (JobType) {
|
|
15
|
+
JobType["SYNC_SALES"] = "SYNC_SALES";
|
|
16
|
+
JobType["SYNC_PURCHASES"] = "SYNC_PURCHASES";
|
|
17
|
+
JobType["SYNC_INVENTORY"] = "SYNC_INVENTORY";
|
|
18
|
+
JobType["SYNC_TRANSFERS"] = "SYNC_TRANSFERS";
|
|
19
|
+
JobType["SYNC_MOVEMENTS"] = "SYNC_MOVEMENTS";
|
|
20
|
+
JobType["SYNC_STOCK_CONFIG"] = "SYNC_STOCK_CONFIG";
|
|
21
|
+
JobType["SYNC_CATALOG"] = "SYNC_CATALOG";
|
|
22
|
+
JobType["SYNC_ALL"] = "SYNC_ALL";
|
|
23
|
+
})(JobType || (exports.JobType = JobType = {}));
|
|
24
|
+
/**
|
|
25
|
+
* Job execution status
|
|
26
|
+
*/
|
|
27
|
+
var JobStatus;
|
|
28
|
+
(function (JobStatus) {
|
|
29
|
+
JobStatus["PENDING"] = "pending";
|
|
30
|
+
JobStatus["PROCESSING"] = "processing";
|
|
31
|
+
JobStatus["COMPLETED"] = "completed";
|
|
32
|
+
JobStatus["FAILED"] = "failed";
|
|
33
|
+
JobStatus["CANCELLED"] = "cancelled";
|
|
34
|
+
})(JobStatus || (exports.JobStatus = JobStatus = {}));
|
|
35
|
+
/**
|
|
36
|
+
* Current step within a sync job
|
|
37
|
+
*/
|
|
38
|
+
var JobStep;
|
|
39
|
+
(function (JobStep) {
|
|
40
|
+
JobStep["DOWNLOAD"] = "download";
|
|
41
|
+
JobStep["PARSE"] = "parse";
|
|
42
|
+
JobStep["TRANSFORM"] = "transform";
|
|
43
|
+
JobStep["SYNC"] = "sync";
|
|
44
|
+
})(JobStep || (exports.JobStep = JobStep = {}));
|
|
45
|
+
/**
|
|
46
|
+
* Human-readable labels for job types (Spanish for UI)
|
|
47
|
+
*/
|
|
48
|
+
exports.JOB_TYPE_LABELS = {
|
|
49
|
+
[JobType.SYNC_SALES]: 'Sincronizar Ventas',
|
|
50
|
+
[JobType.SYNC_PURCHASES]: 'Sincronizar Compras',
|
|
51
|
+
[JobType.SYNC_INVENTORY]: 'Sincronizar Inventario',
|
|
52
|
+
[JobType.SYNC_TRANSFERS]: 'Sincronizar Traspasos',
|
|
53
|
+
[JobType.SYNC_MOVEMENTS]: 'Sincronizar Movimientos',
|
|
54
|
+
[JobType.SYNC_STOCK_CONFIG]: 'Sincronizar Config. Stock',
|
|
55
|
+
[JobType.SYNC_CATALOG]: 'Sincronizar Catálogo',
|
|
56
|
+
[JobType.SYNC_ALL]: 'Sincronizar Todo',
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Human-readable labels for job steps (Spanish for UI)
|
|
60
|
+
*/
|
|
61
|
+
exports.JOB_STEP_LABELS = {
|
|
62
|
+
[JobStep.DOWNLOAD]: 'Descargando',
|
|
63
|
+
[JobStep.PARSE]: 'Procesando archivo',
|
|
64
|
+
[JobStep.TRANSFORM]: 'Transformando datos',
|
|
65
|
+
[JobStep.SYNC]: 'Guardando en base de datos',
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Human-readable labels for job status (Spanish for UI)
|
|
69
|
+
*/
|
|
70
|
+
exports.JOB_STATUS_LABELS = {
|
|
71
|
+
[JobStatus.PENDING]: 'Pendiente',
|
|
72
|
+
[JobStatus.PROCESSING]: 'En proceso',
|
|
73
|
+
[JobStatus.COMPLETED]: 'Completado',
|
|
74
|
+
[JobStatus.FAILED]: 'Fallido',
|
|
75
|
+
[JobStatus.CANCELLED]: 'Cancelado',
|
|
76
|
+
};
|
package/dist/constants/index.js
CHANGED
|
@@ -26,3 +26,4 @@ __exportStar(require("./pricing-rule.constants"), exports);
|
|
|
26
26
|
__exportStar(require("./qvet-catalog"), exports);
|
|
27
27
|
__exportStar(require("./qvet-warehouses"), exports);
|
|
28
28
|
__exportStar(require("./qvet-inventory"), exports);
|
|
29
|
+
__exportStar(require("./background-job.constants"), exports);
|
package/dist/contracts/index.js
CHANGED
|
@@ -20,3 +20,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
21
|
__exportStar(require("./collaborator"), exports);
|
|
22
22
|
__exportStar(require("./catalog-item"), exports);
|
|
23
|
+
__exportStar(require("./qvet"), exports);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
/**
|
|
18
|
+
* QVET API Contracts
|
|
19
|
+
*/
|
|
20
|
+
__exportStar(require("./responses"), exports);
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QVET API Response Types
|
|
3
|
+
*
|
|
4
|
+
* Response interfaces for QVET data endpoints.
|
|
5
|
+
* Used by frontend to consume synced QVET data.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Single sale record from QVET
|
|
9
|
+
* Represents one line item in a sale transaction
|
|
10
|
+
*/
|
|
11
|
+
export interface QvetSaleResponse {
|
|
12
|
+
_id: string;
|
|
13
|
+
date: string;
|
|
14
|
+
warehouse: string;
|
|
15
|
+
subtotal: number;
|
|
16
|
+
paidAmount: number;
|
|
17
|
+
total: number;
|
|
18
|
+
quantity: number;
|
|
19
|
+
discount: number;
|
|
20
|
+
debt: number;
|
|
21
|
+
taxAmount: number;
|
|
22
|
+
taxRate: number;
|
|
23
|
+
paymentMethod: string;
|
|
24
|
+
priceList: string;
|
|
25
|
+
qvetCode: number;
|
|
26
|
+
productName: string;
|
|
27
|
+
section: string;
|
|
28
|
+
family: string;
|
|
29
|
+
subfamily: string;
|
|
30
|
+
isActive: boolean;
|
|
31
|
+
hasStockControl: boolean;
|
|
32
|
+
customerName: string;
|
|
33
|
+
qvetCustomerId?: number;
|
|
34
|
+
petName?: string;
|
|
35
|
+
qvetPetId?: number;
|
|
36
|
+
sellerName: string;
|
|
37
|
+
sellerInitials?: string;
|
|
38
|
+
branch: string;
|
|
39
|
+
syncedAt: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Paginated list of sales
|
|
43
|
+
*/
|
|
44
|
+
export interface QvetSalesListResponse {
|
|
45
|
+
ok: boolean;
|
|
46
|
+
data: QvetSaleResponse[];
|
|
47
|
+
pagination: {
|
|
48
|
+
total: number;
|
|
49
|
+
limit: number;
|
|
50
|
+
skip: number;
|
|
51
|
+
hasMore: boolean;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Sales summary statistics for a period
|
|
56
|
+
*/
|
|
57
|
+
export interface QvetSalesSummaryResponse {
|
|
58
|
+
ok: boolean;
|
|
59
|
+
data: {
|
|
60
|
+
totalRecords: number;
|
|
61
|
+
totalSales: number;
|
|
62
|
+
totalSubtotal: number;
|
|
63
|
+
totalTax: number;
|
|
64
|
+
totalDiscount: number;
|
|
65
|
+
totalQuantity: number;
|
|
66
|
+
avgTicket: number;
|
|
67
|
+
uniqueCustomers: number;
|
|
68
|
+
uniqueProducts: number;
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Sales by section aggregation
|
|
73
|
+
*/
|
|
74
|
+
export interface QvetSalesBySectionItem {
|
|
75
|
+
section: string;
|
|
76
|
+
totalSales: number;
|
|
77
|
+
totalQuantity: number;
|
|
78
|
+
recordCount: number;
|
|
79
|
+
}
|
|
80
|
+
export interface QvetSalesBySectionResponse {
|
|
81
|
+
ok: boolean;
|
|
82
|
+
data: QvetSalesBySectionItem[];
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Query parameters for sales endpoint
|
|
86
|
+
*/
|
|
87
|
+
export interface QvetSalesQueryParams {
|
|
88
|
+
startDate?: string;
|
|
89
|
+
endDate?: string;
|
|
90
|
+
year?: number;
|
|
91
|
+
month?: number;
|
|
92
|
+
halfMonth?: 1 | 2;
|
|
93
|
+
warehouse?: string;
|
|
94
|
+
section?: string;
|
|
95
|
+
family?: string;
|
|
96
|
+
qvetCode?: number;
|
|
97
|
+
customerName?: string;
|
|
98
|
+
limit?: number;
|
|
99
|
+
skip?: number;
|
|
100
|
+
sort?: string;
|
|
101
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Background Job Types
|
|
3
|
+
*
|
|
4
|
+
* Interfaces for background job system.
|
|
5
|
+
* Used by frontend (polling) and backend (job execution).
|
|
6
|
+
*/
|
|
7
|
+
import { JobStatus, JobStep, JobType } from '../constants/background-job.constants';
|
|
8
|
+
/**
|
|
9
|
+
* Job progress information
|
|
10
|
+
*/
|
|
11
|
+
export interface JobProgress {
|
|
12
|
+
/** Progress percentage (0-100) */
|
|
13
|
+
progress: number;
|
|
14
|
+
/** Human-readable progress message */
|
|
15
|
+
progressMessage: string;
|
|
16
|
+
/** Current execution step */
|
|
17
|
+
currentStep: JobStep;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Job execution result
|
|
21
|
+
*/
|
|
22
|
+
export interface JobResult {
|
|
23
|
+
/** Total records processed */
|
|
24
|
+
recordsProcessed: number;
|
|
25
|
+
/** New records created */
|
|
26
|
+
recordsCreated: number;
|
|
27
|
+
/** Existing records updated */
|
|
28
|
+
recordsUpdated: number;
|
|
29
|
+
/** Records deleted (if applicable) */
|
|
30
|
+
recordsDeleted: number;
|
|
31
|
+
/** Non-fatal errors encountered */
|
|
32
|
+
errors: string[];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Job error details
|
|
36
|
+
*/
|
|
37
|
+
export interface JobError {
|
|
38
|
+
/** Error message */
|
|
39
|
+
message: string;
|
|
40
|
+
/** Stack trace (only in development) */
|
|
41
|
+
stack?: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Background job response (for API)
|
|
45
|
+
*/
|
|
46
|
+
export interface BackgroundJobResponse {
|
|
47
|
+
/** Job ID */
|
|
48
|
+
id: string;
|
|
49
|
+
/** Job type */
|
|
50
|
+
type: JobType;
|
|
51
|
+
/** Current status */
|
|
52
|
+
status: JobStatus;
|
|
53
|
+
/** Progress (0-100) */
|
|
54
|
+
progress: number;
|
|
55
|
+
/** Progress message */
|
|
56
|
+
progressMessage?: string;
|
|
57
|
+
/** Current step */
|
|
58
|
+
currentStep?: JobStep;
|
|
59
|
+
/** Job creation timestamp */
|
|
60
|
+
createdAt: string;
|
|
61
|
+
/** Job start timestamp */
|
|
62
|
+
startedAt?: string;
|
|
63
|
+
/** Job completion timestamp */
|
|
64
|
+
completedAt?: string;
|
|
65
|
+
/** Execution duration in milliseconds */
|
|
66
|
+
durationMs?: number;
|
|
67
|
+
/** Result (when completed) */
|
|
68
|
+
result?: JobResult;
|
|
69
|
+
/** Error (when failed) */
|
|
70
|
+
error?: JobError;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Request to create a new sync job
|
|
74
|
+
*/
|
|
75
|
+
export interface CreateSyncJobRequest {
|
|
76
|
+
/** Type of sync to perform */
|
|
77
|
+
type: JobType;
|
|
78
|
+
/** Optional parameters for the sync */
|
|
79
|
+
params?: Record<string, unknown>;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Sync status for a report type
|
|
83
|
+
*/
|
|
84
|
+
export interface SyncReportStatus {
|
|
85
|
+
/** Last sync job ID */
|
|
86
|
+
lastJobId?: string;
|
|
87
|
+
/** Last sync status */
|
|
88
|
+
lastStatus?: JobStatus;
|
|
89
|
+
/** Last sync timestamp */
|
|
90
|
+
lastSyncAt?: string;
|
|
91
|
+
/** Whether a sync is currently running */
|
|
92
|
+
isRunning: boolean;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Overall sync status response
|
|
96
|
+
*/
|
|
97
|
+
export interface SyncStatusResponse {
|
|
98
|
+
/** Status per report type */
|
|
99
|
+
reports: Record<string, SyncReportStatus>;
|
|
100
|
+
/** Currently running jobs */
|
|
101
|
+
runningJobs: Array<{
|
|
102
|
+
id: string;
|
|
103
|
+
type: JobType;
|
|
104
|
+
progress: number;
|
|
105
|
+
startedAt: string;
|
|
106
|
+
}>;
|
|
107
|
+
}
|
package/dist/types/index.d.ts
CHANGED
package/dist/types/index.js
CHANGED
|
@@ -25,3 +25,4 @@ __exportStar(require("./error-codes.types"), exports);
|
|
|
25
25
|
__exportStar(require("./sync-field.types"), exports);
|
|
26
26
|
__exportStar(require("./catalog-item.types"), exports);
|
|
27
27
|
__exportStar(require("./qvet.types"), exports);
|
|
28
|
+
__exportStar(require("./background-job.types"), exports);
|