hvp-shared 6.4.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.
@@ -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
+ };
@@ -10,3 +10,4 @@ export * from './pricing-rule.constants';
10
10
  export * from './qvet-catalog';
11
11
  export * from './qvet-warehouses';
12
12
  export * from './qvet-inventory';
13
+ export * from './background-job.constants';
@@ -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);
@@ -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
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ /**
3
+ * Background Job Types
4
+ *
5
+ * Interfaces for background job system.
6
+ * Used by frontend (polling) and backend (job execution).
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -9,3 +9,4 @@ export * from './error-codes.types';
9
9
  export * from './sync-field.types';
10
10
  export * from './catalog-item.types';
11
11
  export * from './qvet.types';
12
+ export * from './background-job.types';
@@ -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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hvp-shared",
3
- "version": "6.4.0",
3
+ "version": "6.5.0",
4
4
  "description": "Shared types and utilities for HVP backend and frontend",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",