truflow 0.0.193 → 0.0.195

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,9 +1,12 @@
1
- export type LogLevel = "INFO" | "WARNING" | "ERROR";
1
+ export type LogLevel = "INFO" | "WARNING" | "ERROR" | "ROUTE" | "INTEGRATION" | "AGENDA";
2
2
  export interface ILogger {
3
3
  db: any | null;
4
4
  log(message: string, level?: LogLevel): void;
5
5
  info(message: string): void;
6
6
  warning(message: string): void;
7
7
  error(message: string): void;
8
- saveToDatabase(message: string): void;
8
+ route(message: string): void;
9
+ integration(message: string): void;
10
+ agenda(message: string): void;
11
+ saveToDatabase(message: string, level: string, timestamp: Date, functionName?: string, fileName?: string, lineNumber?: number): void;
9
12
  }
@@ -27,7 +27,7 @@ export interface ILeanSavedAttribute {
27
27
  attributeName: string;
28
28
  productId: number;
29
29
  displayName: string;
30
- displayOn: [string];
30
+ displayOn: "qualityControl" | "scheduling" | "dailyStarts" | "shippingReport" | "redoPaper";
31
31
  showForAllProducts: boolean;
32
32
  }
33
33
  export type ISavedAttribute = ILeanSavedAttribute & Document;
@@ -0,0 +1,33 @@
1
+ /// <reference types="mongoose/types/aggregate" />
2
+ /// <reference types="mongoose/types/callback" />
3
+ /// <reference types="mongoose/types/collection" />
4
+ /// <reference types="mongoose/types/connection" />
5
+ /// <reference types="mongoose/types/cursor" />
6
+ /// <reference types="mongoose/types/document" />
7
+ /// <reference types="mongoose/types/error" />
8
+ /// <reference types="mongoose/types/expressions" />
9
+ /// <reference types="mongoose/types/helpers" />
10
+ /// <reference types="mongoose/types/middlewares" />
11
+ /// <reference types="mongoose/types/indexes" />
12
+ /// <reference types="mongoose/types/models" />
13
+ /// <reference types="mongoose/types/mongooseoptions" />
14
+ /// <reference types="mongoose/types/pipelinestage" />
15
+ /// <reference types="mongoose/types/populate" />
16
+ /// <reference types="mongoose/types/query" />
17
+ /// <reference types="mongoose/types/schemaoptions" />
18
+ /// <reference types="mongoose/types/schematypes" />
19
+ /// <reference types="mongoose/types/session" />
20
+ /// <reference types="mongoose/types/types" />
21
+ /// <reference types="mongoose/types/utility" />
22
+ /// <reference types="mongoose/types/validation" />
23
+ /// <reference types="mongoose/types/virtuals" />
24
+ /// <reference types="mongoose/types/inferschematype" />
25
+ import mongoose, { Document } from "mongoose";
26
+ export interface ILeanDepartment {
27
+ _id: mongoose.Types.ObjectId;
28
+ name: string;
29
+ enabled: boolean;
30
+ order: number;
31
+ description?: string;
32
+ }
33
+ export type IDepartment = ILeanDepartment & Document;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,77 @@
1
+ /// <reference types="mongoose/types/aggregate" />
2
+ /// <reference types="mongoose/types/callback" />
3
+ /// <reference types="mongoose/types/collection" />
4
+ /// <reference types="mongoose/types/connection" />
5
+ /// <reference types="mongoose/types/cursor" />
6
+ /// <reference types="mongoose/types/document" />
7
+ /// <reference types="mongoose/types/error" />
8
+ /// <reference types="mongoose/types/expressions" />
9
+ /// <reference types="mongoose/types/helpers" />
10
+ /// <reference types="mongoose/types/middlewares" />
11
+ /// <reference types="mongoose/types/indexes" />
12
+ /// <reference types="mongoose/types/models" />
13
+ /// <reference types="mongoose/types/mongooseoptions" />
14
+ /// <reference types="mongoose/types/pipelinestage" />
15
+ /// <reference types="mongoose/types/populate" />
16
+ /// <reference types="mongoose/types/query" />
17
+ /// <reference types="mongoose/types/schemaoptions" />
18
+ /// <reference types="mongoose/types/schematypes" />
19
+ /// <reference types="mongoose/types/session" />
20
+ /// <reference types="mongoose/types/types" />
21
+ /// <reference types="mongoose/types/utility" />
22
+ /// <reference types="mongoose/types/validation" />
23
+ /// <reference types="mongoose/types/virtuals" />
24
+ /// <reference types="mongoose/types/inferschematype" />
25
+ import mongoose, { Document } from "mongoose";
26
+ export interface IRedoAttribute {
27
+ attributeName: string;
28
+ value: string | number;
29
+ }
30
+ export interface IRedoLineItem {
31
+ id: number;
32
+ width?: number;
33
+ height?: number;
34
+ thickness?: number;
35
+ quantity: number;
36
+ description?: string;
37
+ reason: string;
38
+ attributes?: IRedoAttribute[];
39
+ measurements?: any[];
40
+ measured?: boolean;
41
+ measuredAt?: Date;
42
+ measuredBy?: mongoose.Types.ObjectId;
43
+ }
44
+ export interface IRedoAllmoxyData {
45
+ groupId?: number;
46
+ opId?: number;
47
+ opiId?: number;
48
+ productId: number;
49
+ productAttributes?: IRedoAttribute[];
50
+ lineItems?: IRedoLineItem[];
51
+ }
52
+ export interface IRedoOrderProduct {
53
+ _id?: string;
54
+ quantity: number;
55
+ type: string;
56
+ productionLine?: string;
57
+ startDate?: string;
58
+ hasStarted?: boolean;
59
+ highlight?: boolean;
60
+ allmoxyData?: IRedoAllmoxyData;
61
+ }
62
+ export interface IRedoEntry {
63
+ _id?: mongoose.Types.ObjectId;
64
+ orderId?: number;
65
+ orderName?: string;
66
+ orderProducts: IRedoOrderProduct[];
67
+ rejectedBy?: mongoose.Types.ObjectId;
68
+ rejectedByDepartment?: string;
69
+ createdBy: mongoose.Types.ObjectId;
70
+ assignedTo?: mongoose.Types.ObjectId;
71
+ status: "pending" | "in-progress" | "completed" | "cancelled";
72
+ completedAt?: Date;
73
+ notes?: string;
74
+ createdAt?: Date;
75
+ updatedAt?: Date;
76
+ }
77
+ export type IRedo = IRedoEntry & Document;
package/dist/IRedo.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -23,6 +23,7 @@
23
23
  /// <reference types="mongoose/types/virtuals" />
24
24
  /// <reference types="mongoose/types/inferschematype" />
25
25
  import mongoose, { Document } from "mongoose";
26
+ import { IDepartment } from "./IDepartment";
26
27
  export interface ILeanSetting {
27
28
  _id: mongoose.Types.ObjectId;
28
29
  modifiedAt: string;
@@ -83,8 +84,15 @@ export interface ILeanMachine extends ILeanSetting {
83
84
  type: "machine" | "station";
84
85
  enabled: boolean;
85
86
  dailyCapacity?: number;
86
- location?: string;
87
+ department?: mongoose.Types.ObjectId | IDepartment;
87
88
  visibleOnDashboard?: boolean;
89
+ trainingSteps?: string[];
90
+ publicDashboard?: {
91
+ enabled: boolean;
92
+ };
93
+ hiddenSOPs?: mongoose.Types.ObjectId[];
94
+ sopOrder?: mongoose.Types.ObjectId[];
95
+ pinnedSOPs?: mongoose.Types.ObjectId[];
88
96
  }
89
97
  export interface ILeanOrderFlag extends ILeanSetting {
90
98
  name: string;
@@ -0,0 +1,46 @@
1
+ /// <reference types="mongoose/types/aggregate" />
2
+ /// <reference types="mongoose/types/callback" />
3
+ /// <reference types="mongoose/types/collection" />
4
+ /// <reference types="mongoose/types/connection" />
5
+ /// <reference types="mongoose/types/cursor" />
6
+ /// <reference types="mongoose/types/document" />
7
+ /// <reference types="mongoose/types/error" />
8
+ /// <reference types="mongoose/types/expressions" />
9
+ /// <reference types="mongoose/types/helpers" />
10
+ /// <reference types="mongoose/types/middlewares" />
11
+ /// <reference types="mongoose/types/indexes" />
12
+ /// <reference types="mongoose/types/models" />
13
+ /// <reference types="mongoose/types/mongooseoptions" />
14
+ /// <reference types="mongoose/types/pipelinestage" />
15
+ /// <reference types="mongoose/types/populate" />
16
+ /// <reference types="mongoose/types/query" />
17
+ /// <reference types="mongoose/types/schemaoptions" />
18
+ /// <reference types="mongoose/types/schematypes" />
19
+ /// <reference types="mongoose/types/session" />
20
+ /// <reference types="mongoose/types/types" />
21
+ /// <reference types="mongoose/types/utility" />
22
+ /// <reference types="mongoose/types/validation" />
23
+ /// <reference types="mongoose/types/virtuals" />
24
+ /// <reference types="mongoose/types/inferschematype" />
25
+ import mongoose, { Document } from "mongoose";
26
+ export type TrainingStatus = "P" | "25%" | "50%" | "75%" | "100%";
27
+ export interface ITrainingStepEntry {
28
+ step: string;
29
+ status: TrainingStatus;
30
+ notes?: string;
31
+ trainedBy?: mongoose.Types.ObjectId;
32
+ lastUpdated?: Date;
33
+ }
34
+ export interface ITrainingMatrixEntry {
35
+ _id?: mongoose.Types.ObjectId;
36
+ employeeId: mongoose.Types.ObjectId;
37
+ machineId: mongoose.Types.ObjectId;
38
+ status?: TrainingStatus;
39
+ notes?: string;
40
+ trainedBy?: mongoose.Types.ObjectId;
41
+ trainingSteps?: ITrainingStepEntry[];
42
+ lastUpdated?: Date;
43
+ createdAt?: Date;
44
+ updatedAt?: Date;
45
+ }
46
+ export type ITrainingMatrix = ITrainingMatrixEntry & Document;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/dist/IUser.d.ts CHANGED
@@ -35,6 +35,10 @@ export interface ILeanUser {
35
35
  groups: any[];
36
36
  pushSubscriptions?: PushSubscription[];
37
37
  pushNotificationTags?: NotificationTag[];
38
+ enableSignin?: boolean;
39
+ position?: string;
40
+ department?: mongoose.Types.ObjectId | string;
41
+ employeeId?: string;
38
42
  }
39
43
  export interface PushSubscription {
40
44
  endpoint: string;
package/dist/index.d.ts CHANGED
@@ -9,6 +9,8 @@ export * from "./IJWT";
9
9
  export * from "./IExpress";
10
10
  export * from "./IConfig";
11
11
  export * from "./IWebsocket";
12
+ export * from "./ITrainingMatrix";
13
+ export * from "./IRedo";
12
14
  export * from "./Routes/IOrderRoutes";
13
15
  export * from "./Helpers/IOrders";
14
16
  export * from "./Helpers/IEvents";
package/dist/index.js CHANGED
@@ -25,6 +25,8 @@ __exportStar(require("./IJWT"), exports);
25
25
  __exportStar(require("./IExpress"), exports);
26
26
  __exportStar(require("./IConfig"), exports);
27
27
  __exportStar(require("./IWebsocket"), exports);
28
+ __exportStar(require("./ITrainingMatrix"), exports);
29
+ __exportStar(require("./IRedo"), exports);
28
30
  __exportStar(require("./Routes/IOrderRoutes"), exports);
29
31
  __exportStar(require("./Helpers/IOrders"), exports);
30
32
  __exportStar(require("./Helpers/IEvents"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "truflow",
3
- "version": "0.0.193",
3
+ "version": "0.0.195",
4
4
  "main": "./dist/index.js",
5
5
  "license": "MIT",
6
6
  "scripts": {
@@ -20,7 +20,7 @@
20
20
  "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e",
21
21
  "devDependencies": {
22
22
  "@hokify/agenda": "^6.3.0",
23
- "@types/node": "^24.10.1",
23
+ "@types/node": "^25.0.9",
24
24
  "express": "^5.2.1",
25
25
  "luxon": "^3.7.2",
26
26
  "mongoose": "^9.1.4",
@@ -1,5 +1,5 @@
1
1
  // Define the log levels as a type for better type-checking
2
- export type LogLevel = "INFO" | "WARNING" | "ERROR";
2
+ export type LogLevel = "INFO" | "WARNING" | "ERROR" | "ROUTE" | "INTEGRATION" | "AGENDA";
3
3
 
4
4
  // Interface for the Logger class
5
5
  export interface ILogger {
@@ -11,7 +11,17 @@ export interface ILogger {
11
11
  info(message: string): void;
12
12
  warning(message: string): void;
13
13
  error(message: string): void;
14
+ route(message: string): void;
15
+ integration(message: string): void;
16
+ agenda(message: string): void;
14
17
 
15
18
  // Method to save logs to the database
16
- saveToDatabase(message: string): void;
19
+ saveToDatabase(
20
+ message: string,
21
+ level: string,
22
+ timestamp: Date,
23
+ functionName?: string,
24
+ fileName?: string,
25
+ lineNumber?: number
26
+ ): void;
17
27
  }
package/src/IAllmoxy.ts CHANGED
@@ -4,7 +4,7 @@ export interface ILeanSavedAttribute {
4
4
  attributeName: string;
5
5
  productId: number;
6
6
  displayName: string;
7
- displayOn: [string];
7
+ displayOn: "qualityControl" | "scheduling" | "dailyStarts" | "shippingReport" | "redoPaper";
8
8
  showForAllProducts: boolean;
9
9
  }
10
10
 
@@ -0,0 +1,11 @@
1
+ import mongoose, { Document } from "mongoose";
2
+
3
+ export interface ILeanDepartment {
4
+ _id: mongoose.Types.ObjectId;
5
+ name: string;
6
+ enabled: boolean;
7
+ order: number;
8
+ description?: string;
9
+ }
10
+
11
+ export type IDepartment = ILeanDepartment & Document;
package/src/IRedo.ts ADDED
@@ -0,0 +1,59 @@
1
+ import mongoose, { Document } from "mongoose";
2
+
3
+ export interface IRedoAttribute {
4
+ attributeName: string;
5
+ value: string | number;
6
+ }
7
+
8
+ export interface IRedoLineItem {
9
+ id: number; // Line item ID
10
+ width?: number;
11
+ height?: number;
12
+ thickness?: number;
13
+ quantity: number;
14
+ description?: string; // For manual entry
15
+ reason: string; // Per-line-item reason (REQUIRED)
16
+ attributes?: IRedoAttribute[]; // Line item attributes from Allmoxy
17
+ measurements?: any[]; // Keep measurements structure consistent with orders
18
+ measured?: boolean; // Track if this line item has been measured
19
+ measuredAt?: Date; // Timestamp when measured
20
+ measuredBy?: mongoose.Types.ObjectId; // User who measured this item
21
+ }
22
+
23
+ export interface IRedoAllmoxyData {
24
+ groupId?: number;
25
+ opId?: number;
26
+ opiId?: number;
27
+ productId: number;
28
+ productAttributes?: IRedoAttribute[]; // Product-level attributes
29
+ lineItems?: IRedoLineItem[]; // Filtered to only selected line items for this redo
30
+ }
31
+
32
+ export interface IRedoOrderProduct {
33
+ _id?: string;
34
+ quantity: number;
35
+ type: string;
36
+ productionLine?: string;
37
+ startDate?: string;
38
+ hasStarted?: boolean;
39
+ highlight?: boolean;
40
+ allmoxyData?: IRedoAllmoxyData;
41
+ }
42
+
43
+ export interface IRedoEntry {
44
+ _id?: mongoose.Types.ObjectId;
45
+ orderId?: number; // Reference to Order._id (optional for manual entry)
46
+ orderName?: string; // PO number or order name
47
+ orderProducts: IRedoOrderProduct[]; // Stores order products structure (filtered line items only)
48
+ rejectedBy?: mongoose.Types.ObjectId; // Employee who rejected the item
49
+ rejectedByDepartment?: string; // Department of employee who rejected
50
+ createdBy: mongoose.Types.ObjectId; // User who created the redo
51
+ assignedTo?: mongoose.Types.ObjectId; // User assigned to handle the redo
52
+ status: "pending" | "in-progress" | "completed" | "cancelled";
53
+ completedAt?: Date;
54
+ notes?: string;
55
+ createdAt?: Date;
56
+ updatedAt?: Date;
57
+ }
58
+
59
+ export type IRedo = IRedoEntry & Document;
package/src/ISetting.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import mongoose, { Document } from "mongoose";
2
+ import { IDepartment } from "./IDepartment";
2
3
 
3
4
  export interface ILeanSetting {
4
5
  _id: mongoose.Types.ObjectId;
@@ -25,12 +26,12 @@ export interface ILeanHoliday extends ILeanSetting {
25
26
  recurs?: string;
26
27
  }
27
28
 
28
- export type AttributeFilterOperator =
29
- | "equals"
30
- | "notEquals"
31
- | "contains"
32
- | "notContains"
33
- | "startsWith"
29
+ export type AttributeFilterOperator =
30
+ | "equals"
31
+ | "notEquals"
32
+ | "contains"
33
+ | "notContains"
34
+ | "startsWith"
34
35
  | "endsWith";
35
36
 
36
37
  export interface IAttributeFilter {
@@ -80,8 +81,20 @@ export interface ILeanMachine extends ILeanSetting {
80
81
  // Optional capacity or throughput metrics
81
82
  dailyCapacity?: number;
82
83
  // Optional location or area information
83
- location?: string;
84
+ department?: mongoose.Types.ObjectId | IDepartment;
84
85
  visibleOnDashboard?: boolean;
86
+ // Optional training steps for granular training tracking
87
+ trainingSteps?: string[]; // e.g., ["Setup", "Operation", "Maintenance"]
88
+
89
+ // Public dashboard configuration
90
+ publicDashboard?: {
91
+ enabled: boolean;
92
+ // Add more fields if needed in the future
93
+ };
94
+ // SOP visibility and ordering
95
+ hiddenSOPs?: mongoose.Types.ObjectId[];
96
+ sopOrder?: mongoose.Types.ObjectId[];
97
+ pinnedSOPs?: mongoose.Types.ObjectId[];
85
98
  }
86
99
 
87
100
  export interface ILeanOrderFlag extends ILeanSetting {
@@ -0,0 +1,26 @@
1
+ import mongoose, { Document } from "mongoose";
2
+
3
+ export type TrainingStatus = "P" | "25%" | "50%" | "75%" | "100%";
4
+
5
+ export interface ITrainingStepEntry {
6
+ step: string; // Training step name (e.g., "Setup", "Operation", "Maintenance")
7
+ status: TrainingStatus;
8
+ notes?: string;
9
+ trainedBy?: mongoose.Types.ObjectId; // Reference to User who trained them
10
+ lastUpdated?: Date;
11
+ }
12
+
13
+ export interface ITrainingMatrixEntry {
14
+ _id?: mongoose.Types.ObjectId;
15
+ employeeId: mongoose.Types.ObjectId; // Reference to User
16
+ machineId: mongoose.Types.ObjectId; // Reference to Machine/Station
17
+ status?: TrainingStatus; // Overall status (for machines without training steps)
18
+ notes?: string;
19
+ trainedBy?: mongoose.Types.ObjectId; // Reference to User who trained them
20
+ trainingSteps?: ITrainingStepEntry[]; // Array of training steps with individual statuses
21
+ lastUpdated?: Date;
22
+ createdAt?: Date;
23
+ updatedAt?: Date;
24
+ }
25
+
26
+ export type ITrainingMatrix = ITrainingMatrixEntry & Document;
package/src/IUser.ts CHANGED
@@ -13,6 +13,11 @@ export interface ILeanUser {
13
13
  groups: any[];
14
14
  pushSubscriptions?: PushSubscription[];
15
15
  pushNotificationTags?: NotificationTag[]; // Tags user wants to receive push notifications for
16
+ // Employee fields
17
+ enableSignin?: boolean; // If true, this person can sign in (user), if false they're employee-only
18
+ position?: string; // Job title/position
19
+ department?: mongoose.Types.ObjectId | string; // Department reference (ObjectId) or populated name
20
+ employeeId?: string; // Employee ID number (optional)
16
21
  }
17
22
 
18
23
  export interface PushSubscription {
package/src/index.ts CHANGED
@@ -9,6 +9,8 @@ export * from "./IJWT";
9
9
  export * from "./IExpress";
10
10
  export * from "./IConfig";
11
11
  export * from "./IWebsocket";
12
+ export * from "./ITrainingMatrix";
13
+ export * from "./IRedo";
12
14
  export * from "./Routes/IOrderRoutes";
13
15
  export * from "./Helpers/IOrders";
14
16
  export * from "./Helpers/IEvents";