@machinemetrics/mm-erp-sdk 0.2.0-beta.2 → 0.2.0-beta.3

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.
@@ -1 +1 @@
1
- {"version":3,"file":"nats-labor-ticket-listener.d.ts","sourceRoot":"","sources":["../../../src/services/data-sync-service/nats-labor-ticket-listener.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,qBAAa,uBAAuB;IAClC,OAAO,CAAC,SAAS,CAAM;IACvB,OAAO,CAAC,WAAW,CAAC,CAAc;gBAEtB,SAAS,EAAE,GAAG;IAI1B;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IA0C5B;;OAEG;IACH,OAAO,CAAC,0BAA0B;IAoBlC;;OAEG;IACH,OAAO,CAAC,0BAA0B;IA8GlC;;OAEG;YACW,kBAAkB;IA6FhC;;;OAGG;YACW,gBAAgB;CAyC/B"}
1
+ {"version":3,"file":"nats-labor-ticket-listener.d.ts","sourceRoot":"","sources":["../../../src/services/data-sync-service/nats-labor-ticket-listener.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,qBAAa,uBAAuB;IAClC,OAAO,CAAC,SAAS,CAAM;IACvB,OAAO,CAAC,WAAW,CAAC,CAAc;gBAEtB,SAAS,EAAE,GAAG;IAI1B;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IA0C5B;;OAEG;IACH,OAAO,CAAC,0BAA0B;IAoBlC;;OAEG;IACH,OAAO,CAAC,0BAA0B;IA8GlC;;OAEG;YACW,kBAAkB;IA6FhC;;;OAGG;YACW,gBAAgB;CA0C/B"}
@@ -14,8 +14,8 @@ export interface NatsHandlerRegistration {
14
14
  /**
15
15
  * Subject pattern to subscribe to (supports wildcards: *, >)
16
16
  * Examples:
17
- * - "mm.14.epic01.labor-ticket.*" (single level wildcard)
18
- * - "mm.14.epic01.erp.>" (multi-level wildcard)
17
+ * - "mm.16.epic01.labor-ticket.*" (single level wildcard)
18
+ * - "mm.16.epic01.*" (multi-level wildcard)
19
19
  */
20
20
  subject: string;
21
21
  /**
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Simple proof-of-concept NATS subscriber
3
- * Subscribes to mm.14.> and replies with "hello world"
3
+ * Subscribes to mm.16.> and replies with "hello world"
4
4
  */
5
5
  export {};
6
6
  //# sourceMappingURL=test-nats-subscriber.d.ts.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@machinemetrics/mm-erp-sdk",
3
3
  "description": "A library for syncing data between MachineMetrics and ERP systems",
4
- "version": "0.2.0-beta.2",
4
+ "version": "0.2.0-beta.3",
5
5
  "license": "MIT",
6
6
  "author": "machinemetrics",
7
7
  "main": "dist/mm-erp-sdk.js",
@@ -52,7 +52,7 @@ export class NatsLaborTicketListener {
52
52
  await this.natsService.connect();
53
53
 
54
54
  logger.info("NATS listener started successfully", {
55
- subject: `mm.14.${companyInfo.locationRef}.labor-ticket.*`,
55
+ subject: `mm.16.${companyInfo.locationRef}.labor-ticket.*`,
56
56
  });
57
57
  } catch (error) {
58
58
  logger.error("Failed to start NATS listener", { error });
@@ -67,7 +67,7 @@ export class NatsLaborTicketListener {
67
67
  if (!this.natsService) return;
68
68
 
69
69
  this.natsService.registerHandler({
70
- subject: `mm.14.${locationRef}.erp.health`,
70
+ subject: `mm.16.${locationRef}.health`,
71
71
  description: "Health check - responds immediately to indicate connector is online",
72
72
  handler: {
73
73
  handle: async () => {
@@ -90,7 +90,7 @@ export class NatsLaborTicketListener {
90
90
  if (!this.natsService) return;
91
91
 
92
92
  this.natsService.registerHandler({
93
- subject: `mm.14.${locationRef}.labor-ticket.*`,
93
+ subject: `mm.16.${locationRef}.labor-ticket.*`,
94
94
  description: "Process labor tickets in real-time from NATS",
95
95
  handler: {
96
96
  handle: async ({ data }: any, subject: string) => {
@@ -301,6 +301,8 @@ export class NatsLaborTicketListener {
301
301
  result: { laborTicketRef: string; laborTicket: any }
302
302
  ): Promise<void> {
303
303
  const mmApiClient = new MMApiClient();
304
+ const newTimestamp = new Date().toISOString();
305
+
304
306
  const currentCheckpoint = await mmApiClient.getCheckpoint({
305
307
  system: erpType,
306
308
  table: "labor_tickets",
@@ -311,7 +313,6 @@ export class NatsLaborTicketListener {
311
313
  });
312
314
 
313
315
  const currentTimestamp = (currentCheckpoint as any)?.timestamp;
314
- const newTimestamp = result.laborTicket.updatedAt || new Date().toISOString();
315
316
 
316
317
  // Only update checkpoint if new timestamp is later than current (prevents moving backwards)
317
318
  if (!currentTimestamp || new Date(newTimestamp) > new Date(currentTimestamp)) {
@@ -21,8 +21,8 @@ export interface NatsHandlerRegistration {
21
21
  /**
22
22
  * Subject pattern to subscribe to (supports wildcards: *, >)
23
23
  * Examples:
24
- * - "mm.14.epic01.labor-ticket.*" (single level wildcard)
25
- * - "mm.14.epic01.erp.>" (multi-level wildcard)
24
+ * - "mm.16.epic01.labor-ticket.*" (single level wildcard)
25
+ * - "mm.16.epic01.*" (multi-level wildcard)
26
26
  */
27
27
  subject: string;
28
28
 
@@ -279,7 +279,7 @@ export class NatsService {
279
279
  };
280
280
 
281
281
  await this.publish(
282
- `mm.14.${this.config.locationRef}.erp.status`,
282
+ `mm.16.${this.config.locationRef}.status`,
283
283
  status
284
284
  );
285
285
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Simple proof-of-concept NATS subscriber
3
- * Subscribes to mm.14.> and replies with "hello world"
3
+ * Subscribes to mm.16.> and replies with "hello world"
4
4
  */
5
5
 
6
6
  import { connect, StringCodec } from "nats";
@@ -21,10 +21,10 @@ async function startTestSubscriber() {
21
21
  clientId: nc.info?.client_id,
22
22
  });
23
23
 
24
- // Subscribe to all messages on mm.14.>
25
- const sub = nc.subscribe("mm.14.>");
24
+ // Subscribe to all messages on mm.16.>
25
+ const sub = nc.subscribe("mm.16.>");
26
26
 
27
- logger.info("Subscribed to mm.14.> - waiting for messages...");
27
+ logger.info("Subscribed to mm.16.> - waiting for messages...");
28
28
 
29
29
  // Process incoming messages
30
30
  (async () => {