hvp-shared 6.8.0 → 6.10.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.
@@ -15,8 +15,51 @@ export declare enum JobType {
15
15
  SYNC_MOVEMENTS = "SYNC_MOVEMENTS",
16
16
  SYNC_STOCK_CONFIG = "SYNC_STOCK_CONFIG",
17
17
  SYNC_CATALOG = "SYNC_CATALOG",
18
+ SYNC_CLIENTS = "SYNC_CLIENTS",
19
+ SYNC_INVENTORY_SNAPSHOT = "SYNC_INVENTORY_SNAPSHOT",
20
+ SYNC_BATCH = "SYNC_BATCH",
18
21
  SYNC_ALL = "SYNC_ALL"
19
22
  }
23
+ /**
24
+ * Report types for batch sync operations.
25
+ * Each report type has specific parameter requirements.
26
+ */
27
+ export declare enum ReportType {
28
+ /** Sales report - uses date range params */
29
+ SALES = "SALES",
30
+ /** Purchases report - uses date range params */
31
+ PURCHASES = "PURCHASES",
32
+ /** Inventory movements report - uses date range params */
33
+ MOVEMENTS = "MOVEMENTS",
34
+ /** Transfers report - uses date range params */
35
+ TRANSFERS = "TRANSFERS",
36
+ /** Inventory snapshot - uses snapshot date param */
37
+ INVENTORY_SNAPSHOT = "INVENTORY_SNAPSHOT",
38
+ /** Clients list - no date params required */
39
+ CLIENTS = "CLIENTS",
40
+ /** Product catalog - no date params required */
41
+ CATALOG = "CATALOG",
42
+ /** Stock configuration - no date params required */
43
+ STOCK_CONFIG = "STOCK_CONFIG"
44
+ }
45
+ /**
46
+ * Sub-task status within a batch job
47
+ */
48
+ export declare enum SubTaskStatus {
49
+ PENDING = "pending",
50
+ IN_PROGRESS = "in_progress",
51
+ COMPLETED = "completed",
52
+ FAILED = "failed",
53
+ SKIPPED = "skipped"
54
+ }
55
+ /**
56
+ * Parameter type for each report type
57
+ */
58
+ export type ReportParamType = 'date_range' | 'snapshot' | 'no_params';
59
+ /**
60
+ * Mapping of report types to their parameter type
61
+ */
62
+ export declare const REPORT_PARAM_TYPES: Record<ReportType, ReportParamType>;
20
63
  /**
21
64
  * Job execution status
22
65
  */
@@ -40,6 +83,14 @@ export declare enum JobStep {
40
83
  * Human-readable labels for job types (Spanish for UI)
41
84
  */
42
85
  export declare const JOB_TYPE_LABELS: Record<JobType, string>;
86
+ /**
87
+ * Human-readable labels for report types (Spanish for UI)
88
+ */
89
+ export declare const REPORT_TYPE_LABELS: Record<ReportType, string>;
90
+ /**
91
+ * Human-readable labels for sub-task status (Spanish for UI)
92
+ */
93
+ export declare const SUB_TASK_STATUS_LABELS: Record<SubTaskStatus, string>;
43
94
  /**
44
95
  * Human-readable labels for job steps (Spanish for UI)
45
96
  */
@@ -6,7 +6,7 @@
6
6
  * Used by frontend (polling) and backend (job execution).
7
7
  */
8
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;
9
+ exports.JOB_STATUS_LABELS = exports.JOB_STEP_LABELS = exports.SUB_TASK_STATUS_LABELS = exports.REPORT_TYPE_LABELS = exports.JOB_TYPE_LABELS = exports.JobStep = exports.JobStatus = exports.REPORT_PARAM_TYPES = exports.SubTaskStatus = exports.ReportType = exports.JobType = void 0;
10
10
  /**
11
11
  * Job types for QVET sync operations
12
12
  */
@@ -19,8 +19,58 @@ var JobType;
19
19
  JobType["SYNC_MOVEMENTS"] = "SYNC_MOVEMENTS";
20
20
  JobType["SYNC_STOCK_CONFIG"] = "SYNC_STOCK_CONFIG";
21
21
  JobType["SYNC_CATALOG"] = "SYNC_CATALOG";
22
+ JobType["SYNC_CLIENTS"] = "SYNC_CLIENTS";
23
+ JobType["SYNC_INVENTORY_SNAPSHOT"] = "SYNC_INVENTORY_SNAPSHOT";
24
+ JobType["SYNC_BATCH"] = "SYNC_BATCH";
22
25
  JobType["SYNC_ALL"] = "SYNC_ALL";
23
26
  })(JobType || (exports.JobType = JobType = {}));
27
+ /**
28
+ * Report types for batch sync operations.
29
+ * Each report type has specific parameter requirements.
30
+ */
31
+ var ReportType;
32
+ (function (ReportType) {
33
+ /** Sales report - uses date range params */
34
+ ReportType["SALES"] = "SALES";
35
+ /** Purchases report - uses date range params */
36
+ ReportType["PURCHASES"] = "PURCHASES";
37
+ /** Inventory movements report - uses date range params */
38
+ ReportType["MOVEMENTS"] = "MOVEMENTS";
39
+ /** Transfers report - uses date range params */
40
+ ReportType["TRANSFERS"] = "TRANSFERS";
41
+ /** Inventory snapshot - uses snapshot date param */
42
+ ReportType["INVENTORY_SNAPSHOT"] = "INVENTORY_SNAPSHOT";
43
+ /** Clients list - no date params required */
44
+ ReportType["CLIENTS"] = "CLIENTS";
45
+ /** Product catalog - no date params required */
46
+ ReportType["CATALOG"] = "CATALOG";
47
+ /** Stock configuration - no date params required */
48
+ ReportType["STOCK_CONFIG"] = "STOCK_CONFIG";
49
+ })(ReportType || (exports.ReportType = ReportType = {}));
50
+ /**
51
+ * Sub-task status within a batch job
52
+ */
53
+ var SubTaskStatus;
54
+ (function (SubTaskStatus) {
55
+ SubTaskStatus["PENDING"] = "pending";
56
+ SubTaskStatus["IN_PROGRESS"] = "in_progress";
57
+ SubTaskStatus["COMPLETED"] = "completed";
58
+ SubTaskStatus["FAILED"] = "failed";
59
+ SubTaskStatus["SKIPPED"] = "skipped";
60
+ })(SubTaskStatus || (exports.SubTaskStatus = SubTaskStatus = {}));
61
+ /**
62
+ * Mapping of report types to their parameter type
63
+ */
64
+ exports.REPORT_PARAM_TYPES = {
65
+ [ReportType.SALES]: 'date_range',
66
+ [ReportType.PURCHASES]: 'date_range',
67
+ [ReportType.MOVEMENTS]: 'date_range',
68
+ [ReportType.TRANSFERS]: 'date_range',
69
+ [ReportType.INVENTORY_SNAPSHOT]: 'snapshot',
70
+ [ReportType.CLIENTS]: 'no_params',
71
+ [ReportType.CATALOG]: 'no_params',
72
+ [ReportType.STOCK_CONFIG]: 'no_params',
73
+ };
24
74
  /**
25
75
  * Job execution status
26
76
  */
@@ -53,8 +103,34 @@ exports.JOB_TYPE_LABELS = {
53
103
  [JobType.SYNC_MOVEMENTS]: 'Sincronizar Movimientos',
54
104
  [JobType.SYNC_STOCK_CONFIG]: 'Sincronizar Config. Stock',
55
105
  [JobType.SYNC_CATALOG]: 'Sincronizar Catálogo',
106
+ [JobType.SYNC_CLIENTS]: 'Sincronizar Clientes',
107
+ [JobType.SYNC_INVENTORY_SNAPSHOT]: 'Sincronizar Snapshot Inventario',
108
+ [JobType.SYNC_BATCH]: 'Sincronización por Lotes',
56
109
  [JobType.SYNC_ALL]: 'Sincronizar Todo',
57
110
  };
111
+ /**
112
+ * Human-readable labels for report types (Spanish for UI)
113
+ */
114
+ exports.REPORT_TYPE_LABELS = {
115
+ [ReportType.SALES]: 'Ventas',
116
+ [ReportType.PURCHASES]: 'Compras',
117
+ [ReportType.MOVEMENTS]: 'Movimientos',
118
+ [ReportType.TRANSFERS]: 'Traspasos',
119
+ [ReportType.INVENTORY_SNAPSHOT]: 'Snapshot Inventario',
120
+ [ReportType.CLIENTS]: 'Clientes',
121
+ [ReportType.CATALOG]: 'Catálogo',
122
+ [ReportType.STOCK_CONFIG]: 'Config. Stock',
123
+ };
124
+ /**
125
+ * Human-readable labels for sub-task status (Spanish for UI)
126
+ */
127
+ exports.SUB_TASK_STATUS_LABELS = {
128
+ [SubTaskStatus.PENDING]: 'Pendiente',
129
+ [SubTaskStatus.IN_PROGRESS]: 'En proceso',
130
+ [SubTaskStatus.COMPLETED]: 'Completado',
131
+ [SubTaskStatus.FAILED]: 'Fallido',
132
+ [SubTaskStatus.SKIPPED]: 'Omitido',
133
+ };
58
134
  /**
59
135
  * Human-readable labels for job steps (Spanish for UI)
60
136
  */
@@ -268,3 +268,71 @@ export interface QvetMovementsQueryParams {
268
268
  skip?: number;
269
269
  sort?: string;
270
270
  }
271
+ /**
272
+ * Single transfer record from QVET
273
+ * Represents an inter-warehouse transfer
274
+ */
275
+ export interface QvetTransferResponse {
276
+ id: string;
277
+ transferId: number;
278
+ date: string;
279
+ productName: string;
280
+ sourceWarehouse: string;
281
+ targetWarehouse: string;
282
+ quantity: number;
283
+ conversionFactor: number;
284
+ initialStockSource: number;
285
+ initialStockTarget: number;
286
+ unitCost: number;
287
+ averageCost: number;
288
+ lot: string;
289
+ lotExpiryDate: string | null;
290
+ userName: string;
291
+ responsibleSource: string;
292
+ responsibleTarget: string;
293
+ notes: string;
294
+ syncedAt: string;
295
+ }
296
+ /**
297
+ * Paginated list of transfers
298
+ */
299
+ export interface QvetTransfersListResponse {
300
+ ok: boolean;
301
+ data: QvetTransferResponse[];
302
+ pagination: {
303
+ total: number;
304
+ limit: number;
305
+ skip: number;
306
+ hasMore: boolean;
307
+ };
308
+ }
309
+ /**
310
+ * Transfers summary statistics for a period
311
+ */
312
+ export interface QvetTransfersSummaryResponse {
313
+ ok: boolean;
314
+ data: {
315
+ totalRecords: number;
316
+ totalQuantity: number;
317
+ totalValue: number;
318
+ uniqueProducts: number;
319
+ sourceWarehouses: number;
320
+ targetWarehouses: number;
321
+ };
322
+ }
323
+ /**
324
+ * Query parameters for transfers endpoint
325
+ */
326
+ export interface QvetTransfersQueryParams {
327
+ startDate?: string;
328
+ endDate?: string;
329
+ year?: number;
330
+ month?: number;
331
+ halfMonth?: 1 | 2;
332
+ sourceWarehouse?: string;
333
+ targetWarehouse?: string;
334
+ productName?: string;
335
+ limit?: number;
336
+ skip?: number;
337
+ sort?: string;
338
+ }
@@ -4,7 +4,7 @@
4
4
  * Interfaces for background job system.
5
5
  * Used by frontend (polling) and backend (job execution).
6
6
  */
7
- import { JobStatus, JobStep, JobType } from '../constants/background-job.constants';
7
+ import { JobStatus, JobStep, JobType, ReportType, SubTaskStatus } from '../constants/background-job.constants';
8
8
  /**
9
9
  * Job progress information
10
10
  */
@@ -40,6 +40,85 @@ export interface JobError {
40
40
  /** Stack trace (only in development) */
41
41
  stack?: string;
42
42
  }
43
+ /**
44
+ * Parameters for date-range based reports (Sales, Purchases, Movements, Transfers)
45
+ */
46
+ export interface DateRangeParams {
47
+ /** Year to sync */
48
+ year: number;
49
+ /** Month to sync (1-12). If omitted, syncs full year */
50
+ month?: number;
51
+ /** Half month (1 = days 1-15, 2 = days 16-end). Optional */
52
+ halfMonth?: 1 | 2;
53
+ }
54
+ /**
55
+ * Parameters for snapshot-based reports (Inventory Snapshot)
56
+ */
57
+ export interface SnapshotParams {
58
+ /** The specific date to get inventory snapshot for (ISO string) */
59
+ snapshotDate: string;
60
+ /** Optional: filter by warehouse */
61
+ warehouse?: string;
62
+ }
63
+ /**
64
+ * Union type for all possible sync parameters
65
+ */
66
+ export type SyncParams = DateRangeParams | SnapshotParams | Record<string, never>;
67
+ /**
68
+ * Result for a single sub-task
69
+ */
70
+ export interface SubTaskResult {
71
+ /** Total records processed */
72
+ recordsProcessed: number;
73
+ /** New records created */
74
+ recordsCreated: number;
75
+ /** Existing records updated */
76
+ recordsUpdated: number;
77
+ /** Non-fatal errors encountered */
78
+ errors: string[];
79
+ }
80
+ /**
81
+ * A sub-task within a batch job
82
+ */
83
+ export interface BatchSubTask {
84
+ /** Unique identifier for this sub-task */
85
+ id: string;
86
+ /** Report type to sync */
87
+ reportType: ReportType;
88
+ /** Current status */
89
+ status: SubTaskStatus;
90
+ /** Parameters specific to this report type */
91
+ params: SyncParams;
92
+ /** Progress percentage (0-100) */
93
+ progress: number;
94
+ /** Human-readable progress message */
95
+ progressMessage: string;
96
+ /** When the sub-task started */
97
+ startedAt?: string;
98
+ /** When the sub-task completed */
99
+ completedAt?: string;
100
+ /** Duration in milliseconds */
101
+ durationMs?: number;
102
+ /** Result when completed */
103
+ result?: SubTaskResult;
104
+ /** Error message when failed */
105
+ error?: string;
106
+ }
107
+ /**
108
+ * Summary of batch job sub-tasks
109
+ */
110
+ export interface BatchSubTasksSummary {
111
+ /** Total number of sub-tasks */
112
+ total: number;
113
+ /** Number completed successfully */
114
+ completed: number;
115
+ /** Number failed */
116
+ failed: number;
117
+ /** Number skipped */
118
+ skipped: number;
119
+ /** Number still pending */
120
+ pending: number;
121
+ }
43
122
  /**
44
123
  * Background job response (for API)
45
124
  */
@@ -68,6 +147,12 @@ export interface BackgroundJobResponse {
68
147
  result?: JobResult;
69
148
  /** Error (when failed) */
70
149
  error?: JobError;
150
+ /** Index of current sub-task being processed (for batch jobs) */
151
+ currentSubTaskIndex?: number;
152
+ /** Sub-tasks in this batch job */
153
+ subTasks?: BatchSubTask[];
154
+ /** Summary of sub-task statuses (for batch jobs) */
155
+ subTasksSummary?: BatchSubTasksSummary;
71
156
  }
72
157
  /**
73
158
  * Request to create a new sync job
@@ -78,6 +163,18 @@ export interface CreateSyncJobRequest {
78
163
  /** Optional parameters for the sync */
79
164
  params?: Record<string, unknown>;
80
165
  }
166
+ /**
167
+ * Request to create a batch sync job
168
+ */
169
+ export interface CreateBatchSyncJobRequest {
170
+ /** Sub-tasks to execute in this batch */
171
+ subTasks: Array<{
172
+ /** Report type to sync */
173
+ reportType: ReportType;
174
+ /** Parameters specific to this report type */
175
+ params: SyncParams;
176
+ }>;
177
+ }
81
178
  /**
82
179
  * Sync status for a report type
83
180
  */
@@ -105,3 +202,25 @@ export interface SyncStatusResponse {
105
202
  startedAt: string;
106
203
  }>;
107
204
  }
205
+ /**
206
+ * A sync suggestion for missing data
207
+ */
208
+ export interface SyncSuggestion {
209
+ /** Report type */
210
+ reportType: ReportType;
211
+ /** Suggested parameters */
212
+ params: SyncParams;
213
+ /** Human-readable description */
214
+ description: string;
215
+ /** Priority (lower = more important) */
216
+ priority: number;
217
+ }
218
+ /**
219
+ * Sync suggestions response
220
+ */
221
+ export interface SyncSuggestionsResponse {
222
+ /** List of suggested syncs */
223
+ suggestions: SyncSuggestion[];
224
+ /** When suggestions were generated */
225
+ generatedAt: string;
226
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hvp-shared",
3
- "version": "6.8.0",
3
+ "version": "6.10.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",