hvp-shared 6.3.0 → 6.5.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/catalog-item/requests.d.ts +6 -2
- package/dist/contracts/catalog-item/responses.d.ts +6 -2
- 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);
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Request DTOs for catalog item endpoints.
|
|
5
5
|
*/
|
|
6
|
-
import { UsageType, SyncStatus } from '../../constants/catalog-item.constants';
|
|
6
|
+
import { UsageType, SyncStatus, StockPolicy } from '../../constants/catalog-item.constants';
|
|
7
7
|
import { MarketCompetition } from '../../constants/market-competition.constants';
|
|
8
8
|
import { PricingRuleCode } from '../../constants/pricing-rule.constants';
|
|
9
9
|
/**
|
|
@@ -104,7 +104,11 @@ export interface UpdateCatalogItemHvpDataRequest {
|
|
|
104
104
|
pricingRuleCode?: PricingRuleCode;
|
|
105
105
|
/** Recommended price (calculated from pricing rule) */
|
|
106
106
|
recommendedPrice?: number;
|
|
107
|
-
/**
|
|
107
|
+
/** How stock levels are managed */
|
|
108
|
+
stockPolicy?: StockPolicy;
|
|
109
|
+
/** Observations generated by analysis script */
|
|
110
|
+
stockObservations?: string;
|
|
111
|
+
/** @deprecated Use stockPolicy: 'manual' instead */
|
|
108
112
|
requiresManualReview?: boolean;
|
|
109
113
|
}
|
|
110
114
|
/**
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Response DTOs for catalog item endpoints.
|
|
5
5
|
*/
|
|
6
6
|
import { SyncField } from '../../types/sync-field.types';
|
|
7
|
-
import { UsageType, SyncStatus } from '../../constants/catalog-item.constants';
|
|
7
|
+
import { UsageType, SyncStatus, StockPolicy } from '../../constants/catalog-item.constants';
|
|
8
8
|
import { MarketCompetition } from '../../constants/market-competition.constants';
|
|
9
9
|
import { PricingRuleCode } from '../../constants/pricing-rule.constants';
|
|
10
10
|
import { Warehouse } from '../../types/qvet.types';
|
|
@@ -136,7 +136,11 @@ export interface CatalogItemDetailResponse {
|
|
|
136
136
|
* Calculated from: cost * (1 + targetMargin/100) * (1 + VAT/100)
|
|
137
137
|
*/
|
|
138
138
|
recommendedPrice?: number;
|
|
139
|
-
/**
|
|
139
|
+
/** How stock levels are managed */
|
|
140
|
+
stockPolicy?: StockPolicy;
|
|
141
|
+
/** Observations generated by analysis script */
|
|
142
|
+
stockObservations?: string;
|
|
143
|
+
/** @deprecated Use stockPolicy: 'manual' instead */
|
|
140
144
|
requiresManualReview?: boolean;
|
|
141
145
|
};
|
|
142
146
|
hasPendingChanges: boolean;
|
|
@@ -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);
|