@machinemetrics/mm-erp-sdk 0.3.0-beta.0 → 0.3.0-beta.1
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/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/services/data-sync-service/configuration-manager.d.ts.map +1 -1
- package/dist/services/data-sync-service/configuration-manager.js +30 -30
- package/dist/services/data-sync-service/configuration-manager.js.map +1 -1
- package/dist/services/data-sync-service/data-sync-service.d.ts.map +1 -1
- package/dist/services/data-sync-service/data-sync-service.js +9 -0
- package/dist/services/data-sync-service/data-sync-service.js.map +1 -1
- package/dist/services/data-sync-service/jobs/clean-up-expired-cache.d.ts.map +1 -1
- package/dist/services/data-sync-service/jobs/clean-up-expired-cache.js +1 -2
- package/dist/services/data-sync-service/jobs/clean-up-expired-cache.js.map +1 -1
- package/dist/services/data-sync-service/jobs/from-erp.d.ts.map +1 -1
- package/dist/services/data-sync-service/jobs/from-erp.js +7 -13
- package/dist/services/data-sync-service/jobs/from-erp.js.map +1 -1
- package/dist/services/data-sync-service/jobs/retry-failed-labor-tickets.d.ts.map +1 -1
- package/dist/services/data-sync-service/jobs/retry-failed-labor-tickets.js +1 -2
- package/dist/services/data-sync-service/jobs/retry-failed-labor-tickets.js.map +1 -1
- package/dist/services/data-sync-service/jobs/run-migrations.d.ts.map +1 -1
- package/dist/services/data-sync-service/jobs/run-migrations.js +1 -2
- package/dist/services/data-sync-service/jobs/run-migrations.js.map +1 -1
- package/dist/services/data-sync-service/jobs/to-erp.d.ts.map +1 -1
- package/dist/services/data-sync-service/jobs/to-erp.js +12 -3
- package/dist/services/data-sync-service/jobs/to-erp.js.map +1 -1
- package/dist/services/data-sync-service/nats-labor-ticket-listener.d.ts +30 -0
- package/dist/services/data-sync-service/nats-labor-ticket-listener.d.ts.map +1 -0
- package/dist/services/data-sync-service/nats-labor-ticket-listener.js +290 -0
- package/dist/services/data-sync-service/nats-labor-ticket-listener.js.map +1 -0
- package/dist/services/mm-api-service/company-info.d.ts +13 -0
- package/dist/services/mm-api-service/company-info.d.ts.map +1 -0
- package/dist/services/mm-api-service/company-info.js +60 -0
- package/dist/services/mm-api-service/company-info.js.map +1 -0
- package/dist/services/mm-api-service/index.d.ts +7 -0
- package/dist/services/mm-api-service/index.d.ts.map +1 -1
- package/dist/services/mm-api-service/index.js +5 -0
- package/dist/services/mm-api-service/index.js.map +1 -1
- package/dist/services/mm-api-service/mm-api-service.d.ts +6 -0
- package/dist/services/mm-api-service/mm-api-service.d.ts.map +1 -1
- package/dist/services/mm-api-service/mm-api-service.js +15 -3
- package/dist/services/mm-api-service/mm-api-service.js.map +1 -1
- package/dist/services/mm-api-service/types/receive-types.d.ts +3 -0
- package/dist/services/mm-api-service/types/receive-types.d.ts.map +1 -1
- package/dist/services/mm-api-service/types/receive-types.js +1 -0
- package/dist/services/mm-api-service/types/receive-types.js.map +1 -1
- package/dist/services/nats-service/nats-service.d.ts +114 -0
- package/dist/services/nats-service/nats-service.d.ts.map +1 -0
- package/dist/services/nats-service/nats-service.js +244 -0
- package/dist/services/nats-service/nats-service.js.map +1 -0
- package/dist/services/nats-service/test-nats-subscriber.d.ts +6 -0
- package/dist/services/nats-service/test-nats-subscriber.d.ts.map +1 -0
- package/dist/services/nats-service/test-nats-subscriber.js +79 -0
- package/dist/services/nats-service/test-nats-subscriber.js.map +1 -0
- package/dist/services/reporting-service/logger.d.ts.map +1 -1
- package/dist/services/reporting-service/logger.js +31 -6
- package/dist/services/reporting-service/logger.js.map +1 -1
- package/dist/types/erp-connector.d.ts +1 -8
- package/dist/types/erp-connector.d.ts.map +1 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/error-formatter.d.ts +19 -0
- package/dist/utils/error-formatter.d.ts.map +1 -0
- package/dist/utils/error-formatter.js +184 -0
- package/dist/utils/error-formatter.js.map +1 -0
- package/dist/utils/http-client.js +2 -4
- package/dist/utils/http-client.js.map +1 -1
- package/dist/utils/index.d.ts +5 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +4 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/local-data-store/jobs-shared-data.d.ts +0 -2
- package/dist/utils/local-data-store/jobs-shared-data.d.ts.map +1 -1
- package/dist/utils/local-data-store/jobs-shared-data.js +0 -2
- package/dist/utils/local-data-store/jobs-shared-data.js.map +1 -1
- package/dist/utils/mm-labor-ticket-helpers.d.ts +4 -3
- package/dist/utils/mm-labor-ticket-helpers.d.ts.map +1 -1
- package/dist/utils/mm-labor-ticket-helpers.js +7 -12
- package/dist/utils/mm-labor-ticket-helpers.js.map +1 -1
- package/dist/utils/standard-process-drivers/labor-ticket-erp-synchronizer.d.ts +0 -15
- package/dist/utils/standard-process-drivers/labor-ticket-erp-synchronizer.d.ts.map +1 -1
- package/dist/utils/standard-process-drivers/labor-ticket-erp-synchronizer.js +46 -180
- package/dist/utils/standard-process-drivers/labor-ticket-erp-synchronizer.js.map +1 -1
- package/dist/utils/standard-process-drivers/mm-entity-processor.d.ts +1 -7
- package/dist/utils/standard-process-drivers/mm-entity-processor.d.ts.map +1 -1
- package/dist/utils/standard-process-drivers/mm-entity-processor.js +1 -7
- package/dist/utils/standard-process-drivers/mm-entity-processor.js.map +1 -1
- package/dist/utils/standard-process-drivers/standard-process-drivers.d.ts +2 -8
- package/dist/utils/standard-process-drivers/standard-process-drivers.d.ts.map +1 -1
- package/dist/utils/standard-process-drivers/standard-process-drivers.js +18 -27
- package/dist/utils/standard-process-drivers/standard-process-drivers.js.map +1 -1
- package/dist/utils/time-utils.d.ts.map +1 -1
- package/dist/utils/time-utils.js +0 -7
- package/dist/utils/time-utils.js.map +1 -1
- package/package.json +5 -4
- package/src/index.ts +3 -0
- package/src/services/data-sync-service/configuration-manager.ts +37 -50
- package/src/services/data-sync-service/data-sync-service.ts +10 -0
- package/src/services/data-sync-service/jobs/clean-up-expired-cache.ts +1 -2
- package/src/services/data-sync-service/jobs/from-erp.ts +7 -13
- package/src/services/data-sync-service/jobs/retry-failed-labor-tickets.ts +1 -2
- package/src/services/data-sync-service/jobs/run-migrations.ts +1 -2
- package/src/services/data-sync-service/jobs/to-erp.ts +12 -3
- package/src/services/data-sync-service/nats-labor-ticket-listener.ts +342 -0
- package/src/services/mm-api-service/company-info.ts +87 -0
- package/src/services/mm-api-service/index.ts +8 -0
- package/src/services/mm-api-service/mm-api-service.ts +20 -3
- package/src/services/mm-api-service/types/receive-types.ts +1 -0
- package/src/services/nats-service/nats-service.ts +351 -0
- package/src/services/nats-service/test-nats-subscriber.ts +96 -0
- package/src/services/reporting-service/logger.ts +39 -7
- package/src/types/erp-connector.ts +1 -8
- package/src/types/index.ts +0 -8
- package/src/utils/error-formatter.ts +205 -0
- package/src/utils/http-client.ts +3 -4
- package/src/utils/index.ts +6 -5
- package/src/utils/local-data-store/jobs-shared-data.ts +0 -2
- package/src/utils/mm-labor-ticket-helpers.ts +8 -11
- package/src/utils/standard-process-drivers/labor-ticket-erp-synchronizer.ts +64 -220
- package/src/utils/standard-process-drivers/mm-entity-processor.ts +1 -7
- package/src/utils/standard-process-drivers/standard-process-drivers.ts +19 -33
- package/src/utils/time-utils.ts +0 -11
- package/dist/types/flattened-work-order.d.ts +0 -99
- package/dist/types/flattened-work-order.d.ts.map +0 -1
- package/dist/types/flattened-work-order.js +0 -2
- package/dist/types/flattened-work-order.js.map +0 -1
- package/dist/utils/env.d.ts +0 -8
- package/dist/utils/env.d.ts.map +0 -1
- package/dist/utils/env.js +0 -58
- package/dist/utils/env.js.map +0 -1
- package/dist/utils/erp-timezone-utils.d.ts +0 -20
- package/dist/utils/erp-timezone-utils.d.ts.map +0 -1
- package/dist/utils/erp-timezone-utils.js +0 -75
- package/dist/utils/erp-timezone-utils.js.map +0 -1
- package/src/types/flattened-work-order.ts +0 -108
- package/src/utils/env.ts +0 -75
- package/src/utils/erp-timezone-utils.ts +0 -99
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ERPObjType } from "../../types/erp-types.js";
|
|
2
2
|
import { IERPLaborTicketHandler } from "../../types/erp-connector.js";
|
|
3
|
-
import type { FlattenedWorkOrderRow } from "../../types/flattened-work-order.js";
|
|
4
3
|
import { BatchCacheManager } from "../../services/caching-service/batch-cache-manager.js";
|
|
5
4
|
import {
|
|
6
5
|
IToRESTApiObject,
|
|
@@ -249,12 +248,7 @@ export class StandardProcessDrivers {
|
|
|
249
248
|
* parts, part operations, work orders, and work order operations, then process them in the correct order
|
|
250
249
|
* to maintain referential integrity.
|
|
251
250
|
*
|
|
252
|
-
*
|
|
253
|
-
* as ISO-8601 UTC strings (trailing `Z` or explicit offset). The SDK does not attempt to infer or
|
|
254
|
-
* convert local ERP timestamps on this path; it simply validates and forwards the values to MM.
|
|
255
|
-
* Connector implementations should convert ERP-local times to UTC before invoking this method.
|
|
256
|
-
*
|
|
257
|
-
* @param flattenedData Array of flattened rows containing both work order and operation data (see `FlattenedWorkOrderRow`)
|
|
251
|
+
* @param flattenedData Array of flattened rows containing both work order and operation data (camelCase fields)
|
|
258
252
|
* @param batchCacheManager The batch cache manager instance; pass in null if caching is not desired
|
|
259
253
|
*
|
|
260
254
|
* @returns Combined results from all entity processing with detailed logging information
|
|
@@ -262,7 +256,7 @@ export class StandardProcessDrivers {
|
|
|
262
256
|
* @throws Error on other underlying issues (network, authentication, etc.)
|
|
263
257
|
*/
|
|
264
258
|
static async syncWorkOrderBatchFromFlattened(
|
|
265
|
-
flattenedData:
|
|
259
|
+
flattenedData: any[],
|
|
266
260
|
batchCacheManager: BatchCacheManager | null
|
|
267
261
|
): Promise<{
|
|
268
262
|
parts: WriteEntitiesToMMResult;
|
|
@@ -274,11 +268,6 @@ export class StandardProcessDrivers {
|
|
|
274
268
|
throw new Error("No flattened work order data provided");
|
|
275
269
|
}
|
|
276
270
|
|
|
277
|
-
const toStringOrFallback = (
|
|
278
|
-
value: string | number | null | undefined,
|
|
279
|
-
fallback = ""
|
|
280
|
-
): string => (value === undefined || value === null ? fallback : String(value));
|
|
281
|
-
|
|
282
271
|
// Process the flattened data - each row contains both work order and operation info
|
|
283
272
|
const uniqueParts = new Map();
|
|
284
273
|
const uniquePartOperations = new Map();
|
|
@@ -308,8 +297,8 @@ export class StandardProcessDrivers {
|
|
|
308
297
|
resourceId: row.resourceId, // → resourceId
|
|
309
298
|
cycleTimeMs: row.cycleTimeMs, // → cycleTimeMs
|
|
310
299
|
setupTimeMs: row.setupTimeMs, // → setupTimeMs
|
|
311
|
-
|
|
312
|
-
quantityPerPart: row.quantityPerPart
|
|
300
|
+
description: row.operationDescription || "", // → description
|
|
301
|
+
quantityPerPart: row.quantityPerPart || 1, // → quantityPerPart
|
|
313
302
|
});
|
|
314
303
|
}
|
|
315
304
|
|
|
@@ -362,8 +351,8 @@ export class StandardProcessDrivers {
|
|
|
362
351
|
const parts = Array.from(uniqueParts.values()).map(
|
|
363
352
|
(item) =>
|
|
364
353
|
new MMSendPart(
|
|
365
|
-
|
|
366
|
-
|
|
354
|
+
item.partNumber || "", // partNumber
|
|
355
|
+
item.partRevision || "", // partRevision
|
|
367
356
|
item.method || "Standard" // method
|
|
368
357
|
)
|
|
369
358
|
);
|
|
@@ -371,14 +360,14 @@ export class StandardProcessDrivers {
|
|
|
371
360
|
const partOperations = Array.from(uniquePartOperations.values()).map(
|
|
372
361
|
(item) =>
|
|
373
362
|
new MMSendPartOperation(
|
|
374
|
-
|
|
375
|
-
|
|
363
|
+
item.partNumber || "", // partNumber
|
|
364
|
+
item.partRevision || "", // partRevision
|
|
376
365
|
item.method || "Standard", // method
|
|
377
366
|
item.sequenceNumber?.toString() || "", // sequenceNumber
|
|
378
367
|
item.resourceId?.toString() || "", // resourceId
|
|
379
368
|
item.cycleTimeMs || 0, // cycleTimeMs
|
|
380
369
|
item.setupTimeMs || 0, // setupTimeMs
|
|
381
|
-
item.
|
|
370
|
+
item.description || "", // description
|
|
382
371
|
item.quantityPerPart || 1 // quantityPerPart
|
|
383
372
|
)
|
|
384
373
|
);
|
|
@@ -387,12 +376,10 @@ export class StandardProcessDrivers {
|
|
|
387
376
|
(item) =>
|
|
388
377
|
new MMSendWorkOrder(
|
|
389
378
|
item.workOrderId?.toString() || "", // workOrderId
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
379
|
+
item.lot || "", // lot
|
|
380
|
+
item.split || "", // split
|
|
381
|
+
item.sub || "", // sub
|
|
393
382
|
item.status || "Open", // status
|
|
394
|
-
// Datetimes are assumed to already be UTC (or include an explicit offset).
|
|
395
|
-
// We reserialize via Date solely to validate the ISO format before sending to MM.
|
|
396
383
|
item.dueDate ? new Date(item.dueDate).toISOString() : null, // dueDate
|
|
397
384
|
item.description || "", // description
|
|
398
385
|
item.scheduledStartDate
|
|
@@ -403,8 +390,8 @@ export class StandardProcessDrivers {
|
|
|
403
390
|
: null, // scheduledEndDate
|
|
404
391
|
item.closedDate ? new Date(item.closedDate).toISOString() : null, // closedDate
|
|
405
392
|
item.quantityRequired || 0, // quantityRequired
|
|
406
|
-
|
|
407
|
-
|
|
393
|
+
item.partNumber || "", // partNumber
|
|
394
|
+
item.partRevision || "", // partRevision
|
|
408
395
|
item.method || "Standard" // method
|
|
409
396
|
)
|
|
410
397
|
);
|
|
@@ -413,15 +400,14 @@ export class StandardProcessDrivers {
|
|
|
413
400
|
(item) =>
|
|
414
401
|
new MMSendWorkOrderOperation(
|
|
415
402
|
item.workOrderId?.toString() || "", // workOrderId
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
403
|
+
item.lot || "", // lot
|
|
404
|
+
item.split || "", // split
|
|
405
|
+
item.sub || "", // sub
|
|
419
406
|
item.sequenceNumber?.toString() || "", // sequenceNumber
|
|
420
407
|
item.resourceId?.toString() || "", // resourceId
|
|
421
408
|
item.startQuantity || 0, // startQuantity
|
|
422
409
|
item.finishQuantity || 0, // finishQuantity
|
|
423
410
|
item.expectedRejectRate || 0, // expectedRejectRate
|
|
424
|
-
// Same UTC expectation as above; reserialize to ensure valid ISO.
|
|
425
411
|
item.scheduledStartDate
|
|
426
412
|
? new Date(item.scheduledStartDate).toISOString()
|
|
427
413
|
: null, // scheduledStartDate
|
|
@@ -431,8 +417,8 @@ export class StandardProcessDrivers {
|
|
|
431
417
|
item.closedDate ? new Date(item.closedDate).toISOString() : null, // closedDate
|
|
432
418
|
item.cycleTimeMs || 0, // cycleTimeMs
|
|
433
419
|
item.setupTimeMs || 0, // setupTimeMs
|
|
434
|
-
parseFloat(
|
|
435
|
-
parseFloat(
|
|
420
|
+
parseFloat(item.productionburdenRateHourly || "0"), // productionburdenRateHourly
|
|
421
|
+
parseFloat(item.setupburdenRatehourly || "0"), // setupburdenRatehourly
|
|
436
422
|
item.operationType || "Production", // operationType
|
|
437
423
|
item.quantityPerPart || 1, // quantityPerPart
|
|
438
424
|
item.status || "Open" // status
|
package/src/utils/time-utils.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { DateTime } from 'luxon';
|
|
2
1
|
import logger from "../services/reporting-service/logger.js";
|
|
3
2
|
import {
|
|
4
3
|
setTimezoneOffsetInCache,
|
|
@@ -118,16 +117,6 @@ export const getTimezoneOffsetAndPersist = async (
|
|
|
118
117
|
const { offset, timezone } = await getTimezoneOffset();
|
|
119
118
|
logger.info(`Timezone offset: ${offset} hours, timezone: ${timezone}`);
|
|
120
119
|
setTimezoneOffsetInCache(offset);
|
|
121
|
-
|
|
122
|
-
const now = DateTime.now().setZone(timezone);
|
|
123
|
-
if (!now.isValid) {
|
|
124
|
-
throw new Error(
|
|
125
|
-
`Invalid timezone name from Company properties: "${timezone}". ` +
|
|
126
|
-
`Must be a valid IANA timezone name (e.g., "America/Chicago"). ` +
|
|
127
|
-
`See: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones`
|
|
128
|
-
);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
120
|
setTimezoneNameInCache(timezone);
|
|
132
121
|
success = true;
|
|
133
122
|
} catch (error) {
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Canonical representation of a flattened work order row that contains the
|
|
3
|
-
* information needed to build MM work order entities plus their operations.
|
|
4
|
-
*
|
|
5
|
-
* All properties are optional to maintain backwards compatibility with
|
|
6
|
-
* existing connectors.
|
|
7
|
-
*/
|
|
8
|
-
export interface FlattenedWorkOrderPartFields {
|
|
9
|
-
/** ERP part number (required for Parts when present). */
|
|
10
|
-
partNumber?: string | number;
|
|
11
|
-
/** ERP part revision or version string. */
|
|
12
|
-
partRevision?: string | number;
|
|
13
|
-
/** Routing/method identifier (defaults to "Standard" when omitted). */
|
|
14
|
-
method?: string;
|
|
15
|
-
}
|
|
16
|
-
export interface FlattenedWorkOrderPartOperationFields {
|
|
17
|
-
/** Sequence number of the operation on the routing. */
|
|
18
|
-
sequenceNumber?: string | number;
|
|
19
|
-
/** Resource or machine identifier responsible for the operation. */
|
|
20
|
-
resourceId?: string | number;
|
|
21
|
-
/** Operation cycle time expressed in milliseconds. */
|
|
22
|
-
cycleTimeMs?: number;
|
|
23
|
-
/** Operation setup time expressed in milliseconds. */
|
|
24
|
-
setupTimeMs?: number;
|
|
25
|
-
/** Human-readable description of the operation. */
|
|
26
|
-
operationDescription?: string;
|
|
27
|
-
/** Quantity of parts operated on per cycle. */
|
|
28
|
-
quantityPerPart?: number;
|
|
29
|
-
}
|
|
30
|
-
export interface FlattenedWorkOrderFields extends FlattenedWorkOrderPartFields {
|
|
31
|
-
/** Unique identifier for the work order in the ERP. */
|
|
32
|
-
workOrderId?: string | number;
|
|
33
|
-
/** Lot number (if the ERP distinguishes lots). */
|
|
34
|
-
lot?: string | number;
|
|
35
|
-
/** Split identifier (if the ERP splits orders). */
|
|
36
|
-
split?: string | number;
|
|
37
|
-
/** Sub identifier (for multi-level orders). */
|
|
38
|
-
sub?: string | number;
|
|
39
|
-
/** Work order status (e.g., Open, Closed, Released). */
|
|
40
|
-
status?: string;
|
|
41
|
-
/**
|
|
42
|
-
* Due date expressed as an ISO-8601 UTC string (trailing `Z` or explicit offset).
|
|
43
|
-
* The SDK validates but does not shift timezones.
|
|
44
|
-
*/
|
|
45
|
-
dueDate?: string;
|
|
46
|
-
/** Free-form description of the work order. */
|
|
47
|
-
description?: string;
|
|
48
|
-
/** Scheduled start datetime in ISO-8601 UTC form. */
|
|
49
|
-
scheduledStartDate?: string;
|
|
50
|
-
/** Scheduled end datetime in ISO-8601 UTC form. */
|
|
51
|
-
scheduledEndDate?: string;
|
|
52
|
-
/** Closed datetime in ISO-8601 UTC form. */
|
|
53
|
-
closedDate?: string;
|
|
54
|
-
/** Quantity required by the work order. */
|
|
55
|
-
quantityRequired?: number;
|
|
56
|
-
}
|
|
57
|
-
export interface FlattenedWorkOrderOperationFields {
|
|
58
|
-
/** Work order identifier (repeated for each operation). */
|
|
59
|
-
workOrderId?: string | number;
|
|
60
|
-
/** Lot identifier for the operation row. */
|
|
61
|
-
lot?: string | number;
|
|
62
|
-
/** Split identifier for the operation row. */
|
|
63
|
-
split?: string | number;
|
|
64
|
-
/** Sub identifier for the operation row. */
|
|
65
|
-
sub?: string | number;
|
|
66
|
-
/** Sequence number for the specific operation. */
|
|
67
|
-
sequenceNumber?: string | number;
|
|
68
|
-
/** Resource or machine identifier for the operation. */
|
|
69
|
-
resourceId?: string | number;
|
|
70
|
-
/** Quantity started on the operation. */
|
|
71
|
-
startQuantity?: number;
|
|
72
|
-
/** Quantity finished on the operation. */
|
|
73
|
-
finishQuantity?: number;
|
|
74
|
-
/** Expected reject percentage (0-1). */
|
|
75
|
-
expectedRejectRate?: number;
|
|
76
|
-
/** Scheduled start datetime (ISO-8601 UTC). */
|
|
77
|
-
opScheduledStartDate?: string;
|
|
78
|
-
/** Scheduled finish datetime (ISO-8601 UTC). */
|
|
79
|
-
opScheduledFinishDate?: string;
|
|
80
|
-
/** Closed datetime for the operation (ISO-8601 UTC). */
|
|
81
|
-
opClosedDate?: string;
|
|
82
|
-
/** Production burden rate per hour. */
|
|
83
|
-
productionburdenRateHourly?: number | string;
|
|
84
|
-
/** Setup burden rate per hour. */
|
|
85
|
-
setupburdenRatehourly?: number | string;
|
|
86
|
-
/** Operation type (Production, Setup, etc.). */
|
|
87
|
-
operationType?: string;
|
|
88
|
-
/** Quantity per part for the operation. */
|
|
89
|
-
quantityPerPart?: number;
|
|
90
|
-
/** Operation status (defaults to work-order status when omitted). */
|
|
91
|
-
opStatus?: string;
|
|
92
|
-
}
|
|
93
|
-
export type FlattenedWorkOrderRowBase = FlattenedWorkOrderPartFields & FlattenedWorkOrderPartOperationFields & FlattenedWorkOrderFields & FlattenedWorkOrderOperationFields;
|
|
94
|
-
/**
|
|
95
|
-
* Canonical flattened row that callers pass into
|
|
96
|
-
* `StandardProcessDrivers.syncWorkOrderBatchFromFlattened`.
|
|
97
|
-
*/
|
|
98
|
-
export type FlattenedWorkOrderRow = FlattenedWorkOrderRowBase;
|
|
99
|
-
//# sourceMappingURL=flattened-work-order.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"flattened-work-order.d.ts","sourceRoot":"","sources":["../../src/types/flattened-work-order.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,WAAW,4BAA4B;IAC3C,yDAAyD;IACzD,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC7B,2CAA2C;IAC3C,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC/B,uEAAuE;IACvE,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,qCAAqC;IACpD,uDAAuD;IACvD,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACjC,oEAAoE;IACpE,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC7B,sDAAsD;IACtD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sDAAsD;IACtD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mDAAmD;IACnD,oBAA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cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,wCAAwC;IACxC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,+CAA+C;IAC/C,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,gDAAgD;IAChD,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,wDAAwD;IACxD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,uCAAuC;IACvC,0BAA0B,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC7C,kCAAkC;IAClC,qBAAqB,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxC,gDAAgD;IAChD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,2CAA2C;IAC3C,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,qEAAqE;IACrE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,yBAAyB,GACnC,4BAA4B,GAC5B,qCAAqC,GACrC,wBAAwB,GACxB,iCAAiC,CAAC;AAEpC;;;GAGG;AACH,MAAM,MAAM,qBAAqB,GAAG,yBAAyB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"flattened-work-order.js","sourceRoot":"","sources":["../../src/types/flattened-work-order.ts"],"names":[],"mappings":""}
|
package/dist/utils/env.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This module contains utility functions to get environment variables with default values and validation.
|
|
3
|
-
*/
|
|
4
|
-
export declare const getEnvString: (key: string, defaultValue?: string) => string;
|
|
5
|
-
export declare const getEnvNumber: (key: string, defaultValue: number) => number;
|
|
6
|
-
export declare const getEnvBoolean: (key: string, defaultValue?: boolean) => boolean;
|
|
7
|
-
export declare const getOptionalEnv: (key: string) => string | undefined;
|
|
8
|
-
//# sourceMappingURL=env.d.ts.map
|
package/dist/utils/env.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/utils/env.ts"],"names":[],"mappings":"AAAA;;GAEG;AAyBH,eAAO,MAAM,YAAY,GAAI,KAAK,MAAM,EAAE,qBAAiB,KAAG,MAG7D,CAAC;AAEF,eAAO,MAAM,YAAY,GACvB,KAAK,MAAM,EACX,cAAc,MAAM,KACnB,MAaF,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,KAAK,MAAM,EAAE,sBAAoB,KAAG,OAmBjE,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,KAAK,MAAM,KAAG,MAAM,GAAG,SAErD,CAAC"}
|
package/dist/utils/env.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This module contains utility functions to get environment variables with default values and validation.
|
|
3
|
-
*/
|
|
4
|
-
const normalizeValue = (value) => {
|
|
5
|
-
if (value === undefined || value === null) {
|
|
6
|
-
return undefined;
|
|
7
|
-
}
|
|
8
|
-
const trimmed = value.trim();
|
|
9
|
-
if (!trimmed) {
|
|
10
|
-
return undefined;
|
|
11
|
-
}
|
|
12
|
-
const lowered = trimmed.toLowerCase();
|
|
13
|
-
if (lowered === "undefined" || lowered === "null") {
|
|
14
|
-
return undefined;
|
|
15
|
-
}
|
|
16
|
-
return trimmed;
|
|
17
|
-
};
|
|
18
|
-
const warnInvalid = (key, rawValue, reason) => {
|
|
19
|
-
const received = rawValue !== undefined ? `; received "${rawValue}"` : "";
|
|
20
|
-
console.warn(`[config] ${key} ${reason}${received}`); // eslint-disable-line no-console
|
|
21
|
-
};
|
|
22
|
-
export const getEnvString = (key, defaultValue = "") => {
|
|
23
|
-
const normalized = normalizeValue(process.env[key]);
|
|
24
|
-
return normalized ?? defaultValue;
|
|
25
|
-
};
|
|
26
|
-
export const getEnvNumber = (key, defaultValue) => {
|
|
27
|
-
const normalized = normalizeValue(process.env[key]);
|
|
28
|
-
if (normalized === undefined) {
|
|
29
|
-
return defaultValue;
|
|
30
|
-
}
|
|
31
|
-
const parsed = Number.parseInt(normalized, 10);
|
|
32
|
-
if (Number.isNaN(parsed)) {
|
|
33
|
-
warnInvalid(key, normalized, `is not a valid number for key ${key}; falling back to default ${defaultValue}`);
|
|
34
|
-
return defaultValue;
|
|
35
|
-
}
|
|
36
|
-
return parsed;
|
|
37
|
-
};
|
|
38
|
-
export const getEnvBoolean = (key, defaultValue = false) => {
|
|
39
|
-
const normalized = normalizeValue(process.env[key]);
|
|
40
|
-
if (normalized === undefined) {
|
|
41
|
-
return defaultValue;
|
|
42
|
-
}
|
|
43
|
-
const truthyValues = new Set(["true", "1", "yes", "y", "on"]);
|
|
44
|
-
const falsyValues = new Set(["false", "0", "no", "n", "off"]);
|
|
45
|
-
const lowered = normalized.toLowerCase();
|
|
46
|
-
if (truthyValues.has(lowered)) {
|
|
47
|
-
return true;
|
|
48
|
-
}
|
|
49
|
-
if (falsyValues.has(lowered)) {
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
warnInvalid(key, normalized, "is not a recognized boolean; falling back to default");
|
|
53
|
-
return defaultValue;
|
|
54
|
-
};
|
|
55
|
-
export const getOptionalEnv = (key) => {
|
|
56
|
-
return normalizeValue(process.env[key]);
|
|
57
|
-
};
|
|
58
|
-
//# sourceMappingURL=env.js.map
|
package/dist/utils/env.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"env.js","sourceRoot":"","sources":["../../src/utils/env.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,cAAc,GAAG,CAAC,KAAqB,EAAsB,EAAE;IACnE,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAC1C,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAC7B,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,OAAO,GAAG,OAAO,CAAC,WAAW,EAAE,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AAC,MAAM,aAAa,GAAG,CAAC,GAAW,EAAE,YAAY,GAAG,KAAK,EAAW,EAAE;IAC1E,MAAM,UAAU,GAAG,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IACpD,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC7B,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;IAC9D,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;IAC9D,MAAM,OAAO,GAAG,UAAU,CAAC,WAAW,EAAE,CAAC;IAEzC,IAAI,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;QAC9B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;QAC7B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,WAAW,CAAC,GAAG,EAAE,UAAU,EAAE,sDAAsD,CAAC,CAAC;IACrF,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,GAAW,EAAsB,EAAE;IAChE,OAAO,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;AAC1C,CAAC,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Retrieves the ERP timezone name that should have been cached during initialization.
|
|
3
|
-
* @throws Error when the timezone cache has not been populated.
|
|
4
|
-
*/
|
|
5
|
-
export declare function getERPTimezone(): string;
|
|
6
|
-
/**
|
|
7
|
-
* Converts a UTC ISO-8601 datetime string to the ERP's local timezone (also ISO-8601).
|
|
8
|
-
* @param utcDateTime ISO-8601 datetime string representing UTC time.
|
|
9
|
-
* @param timezone Optional timezone override; defaults to the cached ERP timezone.
|
|
10
|
-
* @returns ISO-8601 string in the ERP timezone.
|
|
11
|
-
*/
|
|
12
|
-
export declare function convertUtcDateTimeToErpLocal(utcDateTime: string, timezone?: string): string;
|
|
13
|
-
/**
|
|
14
|
-
* Converts an ERP-local ISO-8601 datetime string to UTC (still ISO-8601).
|
|
15
|
-
* @param localDateTime ISO-8601 datetime string representing ERP local time.
|
|
16
|
-
* @param timezone Optional timezone override; defaults to the cached ERP timezone.
|
|
17
|
-
* @returns ISO-8601 string in UTC.
|
|
18
|
-
*/
|
|
19
|
-
export declare function convertErpLocalDateTimeToUtc(localDateTime: string, timezone?: string): string;
|
|
20
|
-
//# sourceMappingURL=erp-timezone-utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"erp-timezone-utils.d.ts","sourceRoot":"","sources":["../../src/utils/erp-timezone-utils.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAQvC;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC1C,WAAW,EAAE,MAAM,EACnB,QAAQ,CAAC,EAAE,MAAM,GAChB,MAAM,CA8BR;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC1C,aAAa,EAAE,MAAM,EACrB,QAAQ,CAAC,EAAE,MAAM,GAChB,MAAM,CA8BR"}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { DateTime } from "luxon";
|
|
2
|
-
import logger from "../services/reporting-service/logger.js";
|
|
3
|
-
import { getCachedTimezoneName } from "./local-data-store/jobs-shared-data.js";
|
|
4
|
-
/**
|
|
5
|
-
* Retrieves the ERP timezone name that should have been cached during initialization.
|
|
6
|
-
* @throws Error when the timezone cache has not been populated.
|
|
7
|
-
*/
|
|
8
|
-
export function getERPTimezone() {
|
|
9
|
-
const timezone = getCachedTimezoneName();
|
|
10
|
-
if (!timezone) {
|
|
11
|
-
throw new Error("ERP timezone is not cached. Run getTimezoneOffsetAndPersist() to populate it.");
|
|
12
|
-
}
|
|
13
|
-
return timezone;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Converts a UTC ISO-8601 datetime string to the ERP's local timezone (also ISO-8601).
|
|
17
|
-
* @param utcDateTime ISO-8601 datetime string representing UTC time.
|
|
18
|
-
* @param timezone Optional timezone override; defaults to the cached ERP timezone.
|
|
19
|
-
* @returns ISO-8601 string in the ERP timezone.
|
|
20
|
-
*/
|
|
21
|
-
export function convertUtcDateTimeToErpLocal(utcDateTime, timezone) {
|
|
22
|
-
if (!utcDateTime) {
|
|
23
|
-
throw new Error("convertUtcDateTimeToErpLocal requires a non-empty UTC datetime string");
|
|
24
|
-
}
|
|
25
|
-
try {
|
|
26
|
-
const targetZone = timezone ?? getERPTimezone();
|
|
27
|
-
const parsedUtc = DateTime.fromISO(utcDateTime, { zone: "utc" });
|
|
28
|
-
if (!parsedUtc.isValid) {
|
|
29
|
-
throw new Error(`Invalid UTC datetime "${utcDateTime}": ${parsedUtc.invalidReason}`);
|
|
30
|
-
}
|
|
31
|
-
const localized = parsedUtc.setZone(targetZone);
|
|
32
|
-
if (!localized.isValid) {
|
|
33
|
-
throw new Error(`Unable to convert UTC datetime "${utcDateTime}" to target zone "${targetZone}": ${localized.invalidReason}`);
|
|
34
|
-
}
|
|
35
|
-
return localized.toISO();
|
|
36
|
-
}
|
|
37
|
-
catch (error) {
|
|
38
|
-
logger.error("convertUtcDateTimeToErpLocal: Failed to convert datetime", {
|
|
39
|
-
utcDateTime,
|
|
40
|
-
error,
|
|
41
|
-
});
|
|
42
|
-
throw new Error("Failed to convert UTC datetime to ERP local timezone. See logs for details.");
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Converts an ERP-local ISO-8601 datetime string to UTC (still ISO-8601).
|
|
47
|
-
* @param localDateTime ISO-8601 datetime string representing ERP local time.
|
|
48
|
-
* @param timezone Optional timezone override; defaults to the cached ERP timezone.
|
|
49
|
-
* @returns ISO-8601 string in UTC.
|
|
50
|
-
*/
|
|
51
|
-
export function convertErpLocalDateTimeToUtc(localDateTime, timezone) {
|
|
52
|
-
if (!localDateTime) {
|
|
53
|
-
throw new Error("convertErpLocalDateTimeToUtc requires a non-empty local datetime string");
|
|
54
|
-
}
|
|
55
|
-
try {
|
|
56
|
-
const sourceZone = timezone ?? getERPTimezone();
|
|
57
|
-
const parsedLocal = DateTime.fromISO(localDateTime, { zone: sourceZone });
|
|
58
|
-
if (!parsedLocal.isValid) {
|
|
59
|
-
throw new Error(`Invalid ERP local datetime "${localDateTime}" for zone "${sourceZone}": ${parsedLocal.invalidReason}`);
|
|
60
|
-
}
|
|
61
|
-
const utcDateTime = parsedLocal.setZone("utc");
|
|
62
|
-
if (!utcDateTime.isValid) {
|
|
63
|
-
throw new Error(`Unable to convert ERP local datetime "${localDateTime}" to UTC: ${utcDateTime.invalidReason}`);
|
|
64
|
-
}
|
|
65
|
-
return utcDateTime.toISO();
|
|
66
|
-
}
|
|
67
|
-
catch (error) {
|
|
68
|
-
logger.error("convertErpLocalDateTimeToUtc: Failed to convert datetime", {
|
|
69
|
-
localDateTime,
|
|
70
|
-
error,
|
|
71
|
-
});
|
|
72
|
-
throw new Error("Failed to convert ERP local datetime to UTC. See logs for details.");
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
//# sourceMappingURL=erp-timezone-utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"erp-timezone-utils.js","sourceRoot":"","sources":["../../src/utils/erp-timezone-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,MAAM,MAAM,yCAAyC,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAE/E;;;GAGG;AACH,MAAM,UAAU,cAAc;IA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,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,yEAAyE,CAAC,CAAC;IAC7F,CAAC;IACD,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,QAAQ,IAAI,cAAc,EAAE,CAAC;QAChD,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC;QAC1E,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CACb,+BAA+B,aAAa,eAAe,UAAU,MAAM,WAAW,CAAC,aAAa,EAAE,CACvG,CAAC;QACJ,CAAC;QAED,MAAM,WAAW,GAAG,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAC/C,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CACb,yCAAyC,aAAa,aAAa,WAAW,CAAC,aAAa,EAAE,CAC/F,CAAC;QACJ,CAAC;QAED,OAAO,WAAW,CAAC,KAAK,EAAE,CAAC;IAC7B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,KAAK,CAAC,0DAA0D,EAAE;YACvE,aAAa;YACb,KAAK;SACN,CAAC,CAAC;QACH,MAAM,IAAI,KAAK,CACb,oEAAoE,CACrE,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Canonical representation of a flattened work order row that contains the
|
|
3
|
-
* information needed to build MM work order entities plus their operations.
|
|
4
|
-
*
|
|
5
|
-
* All properties are optional to maintain backwards compatibility with
|
|
6
|
-
* existing connectors.
|
|
7
|
-
*/
|
|
8
|
-
export interface FlattenedWorkOrderPartFields {
|
|
9
|
-
/** ERP part number (required for Parts when present). */
|
|
10
|
-
partNumber?: string | number;
|
|
11
|
-
/** ERP part revision or version string. */
|
|
12
|
-
partRevision?: string | number;
|
|
13
|
-
/** Routing/method identifier (defaults to "Standard" when omitted). */
|
|
14
|
-
method?: string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface FlattenedWorkOrderPartOperationFields {
|
|
18
|
-
/** Sequence number of the operation on the routing. */
|
|
19
|
-
sequenceNumber?: string | number;
|
|
20
|
-
/** Resource or machine identifier responsible for the operation. */
|
|
21
|
-
resourceId?: string | number;
|
|
22
|
-
/** Operation cycle time expressed in milliseconds. */
|
|
23
|
-
cycleTimeMs?: number;
|
|
24
|
-
/** Operation setup time expressed in milliseconds. */
|
|
25
|
-
setupTimeMs?: number;
|
|
26
|
-
/** Human-readable description of the operation. */
|
|
27
|
-
operationDescription?: string;
|
|
28
|
-
/** Quantity of parts operated on per cycle. */
|
|
29
|
-
quantityPerPart?: number;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface FlattenedWorkOrderFields
|
|
33
|
-
extends FlattenedWorkOrderPartFields {
|
|
34
|
-
/** Unique identifier for the work order in the ERP. */
|
|
35
|
-
workOrderId?: string | number;
|
|
36
|
-
/** Lot number (if the ERP distinguishes lots). */
|
|
37
|
-
lot?: string | number;
|
|
38
|
-
/** Split identifier (if the ERP splits orders). */
|
|
39
|
-
split?: string | number;
|
|
40
|
-
/** Sub identifier (for multi-level orders). */
|
|
41
|
-
sub?: string | number;
|
|
42
|
-
/** Work order status (e.g., Open, Closed, Released). */
|
|
43
|
-
status?: string;
|
|
44
|
-
/**
|
|
45
|
-
* Due date expressed as an ISO-8601 UTC string (trailing `Z` or explicit offset).
|
|
46
|
-
* The SDK validates but does not shift timezones.
|
|
47
|
-
*/
|
|
48
|
-
dueDate?: string;
|
|
49
|
-
/** Free-form description of the work order. */
|
|
50
|
-
description?: string;
|
|
51
|
-
/** Scheduled start datetime in ISO-8601 UTC form. */
|
|
52
|
-
scheduledStartDate?: string;
|
|
53
|
-
/** Scheduled end datetime in ISO-8601 UTC form. */
|
|
54
|
-
scheduledEndDate?: string;
|
|
55
|
-
/** Closed datetime in ISO-8601 UTC form. */
|
|
56
|
-
closedDate?: string;
|
|
57
|
-
/** Quantity required by the work order. */
|
|
58
|
-
quantityRequired?: number;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export interface FlattenedWorkOrderOperationFields {
|
|
62
|
-
/** Work order identifier (repeated for each operation). */
|
|
63
|
-
workOrderId?: string | number;
|
|
64
|
-
/** Lot identifier for the operation row. */
|
|
65
|
-
lot?: string | number;
|
|
66
|
-
/** Split identifier for the operation row. */
|
|
67
|
-
split?: string | number;
|
|
68
|
-
/** Sub identifier for the operation row. */
|
|
69
|
-
sub?: string | number;
|
|
70
|
-
/** Sequence number for the specific operation. */
|
|
71
|
-
sequenceNumber?: string | number;
|
|
72
|
-
/** Resource or machine identifier for the operation. */
|
|
73
|
-
resourceId?: string | number;
|
|
74
|
-
/** Quantity started on the operation. */
|
|
75
|
-
startQuantity?: number;
|
|
76
|
-
/** Quantity finished on the operation. */
|
|
77
|
-
finishQuantity?: number;
|
|
78
|
-
/** Expected reject percentage (0-1). */
|
|
79
|
-
expectedRejectRate?: number;
|
|
80
|
-
/** Scheduled start datetime (ISO-8601 UTC). */
|
|
81
|
-
opScheduledStartDate?: string;
|
|
82
|
-
/** Scheduled finish datetime (ISO-8601 UTC). */
|
|
83
|
-
opScheduledFinishDate?: string;
|
|
84
|
-
/** Closed datetime for the operation (ISO-8601 UTC). */
|
|
85
|
-
opClosedDate?: string;
|
|
86
|
-
/** Production burden rate per hour. */
|
|
87
|
-
productionburdenRateHourly?: number | string;
|
|
88
|
-
/** Setup burden rate per hour. */
|
|
89
|
-
setupburdenRatehourly?: number | string;
|
|
90
|
-
/** Operation type (Production, Setup, etc.). */
|
|
91
|
-
operationType?: string;
|
|
92
|
-
/** Quantity per part for the operation. */
|
|
93
|
-
quantityPerPart?: number;
|
|
94
|
-
/** Operation status (defaults to work-order status when omitted). */
|
|
95
|
-
opStatus?: string;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export type FlattenedWorkOrderRowBase =
|
|
99
|
-
FlattenedWorkOrderPartFields &
|
|
100
|
-
FlattenedWorkOrderPartOperationFields &
|
|
101
|
-
FlattenedWorkOrderFields &
|
|
102
|
-
FlattenedWorkOrderOperationFields;
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Canonical flattened row that callers pass into
|
|
106
|
-
* `StandardProcessDrivers.syncWorkOrderBatchFromFlattened`.
|
|
107
|
-
*/
|
|
108
|
-
export type FlattenedWorkOrderRow = FlattenedWorkOrderRowBase;
|
package/src/utils/env.ts
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This module contains utility functions to get environment variables with default values and validation.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
const normalizeValue = (value?: string | null): string | undefined => {
|
|
6
|
-
if (value === undefined || value === null) {
|
|
7
|
-
return undefined;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const trimmed = value.trim();
|
|
11
|
-
if (!trimmed) {
|
|
12
|
-
return undefined;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const lowered = trimmed.toLowerCase();
|
|
16
|
-
if (lowered === "undefined" || lowered === "null") {
|
|
17
|
-
return undefined;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return trimmed;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const warnInvalid = (key: string, rawValue: string | undefined, reason: string) => {
|
|
24
|
-
const received = rawValue !== undefined ? `; received "${rawValue}"` : "";
|
|
25
|
-
console.warn(`[config] ${key} ${reason}${received}`); // eslint-disable-line no-console
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export const getEnvString = (key: string, defaultValue = ""): string => {
|
|
29
|
-
const normalized = normalizeValue(process.env[key]);
|
|
30
|
-
return normalized ?? defaultValue;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export const getEnvNumber = (
|
|
34
|
-
key: string,
|
|
35
|
-
defaultValue: number
|
|
36
|
-
): number => {
|
|
37
|
-
const normalized = normalizeValue(process.env[key]);
|
|
38
|
-
if (normalized === undefined) {
|
|
39
|
-
return defaultValue;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const parsed = Number.parseInt(normalized, 10);
|
|
43
|
-
if (Number.isNaN(parsed)) {
|
|
44
|
-
warnInvalid(key, normalized, `is not a valid number for key ${key}; falling back to default ${defaultValue}`);
|
|
45
|
-
return defaultValue;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return parsed;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export const getEnvBoolean = (key: string, defaultValue = false): boolean => {
|
|
52
|
-
const normalized = normalizeValue(process.env[key]);
|
|
53
|
-
if (normalized === undefined) {
|
|
54
|
-
return defaultValue;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const truthyValues = new Set(["true", "1", "yes", "y", "on"]);
|
|
58
|
-
const falsyValues = new Set(["false", "0", "no", "n", "off"]);
|
|
59
|
-
const lowered = normalized.toLowerCase();
|
|
60
|
-
|
|
61
|
-
if (truthyValues.has(lowered)) {
|
|
62
|
-
return true;
|
|
63
|
-
}
|
|
64
|
-
if (falsyValues.has(lowered)) {
|
|
65
|
-
return false;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
warnInvalid(key, normalized, "is not a recognized boolean; falling back to default");
|
|
69
|
-
return defaultValue;
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
export const getOptionalEnv = (key: string): string | undefined => {
|
|
73
|
-
return normalizeValue(process.env[key]);
|
|
74
|
-
};
|
|
75
|
-
|