truflow 0.0.191 → 0.0.192

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.
@@ -23,7 +23,7 @@
23
23
  /// <reference types="mongoose/types/virtuals" />
24
24
  /// <reference types="mongoose/types/inferschematype" />
25
25
  import mongoose, { Document } from "mongoose";
26
- export type AutomationTriggerType = "order.created" | "order.updated" | "order.status_changed" | "schedule.entry_added" | "schedule.field_changed" | "measurement.added" | "measurement.completed";
26
+ export type AutomationTriggerType = "order.created" | "order.updated" | "order.statusChanged" | "schedule.entryAdded" | "schedule.fieldChanged" | "measurement.added" | "measurement.completed" | "walkthrough.submitted" | "walkthrough.arrived";
27
27
  export type AutomationActionType = "webhook" | "email" | "notification" | "sms" | "slack" | "update_field" | "add_note";
28
28
  export type AutomationConditionOperator = "equals" | "notEquals" | "contains" | "notContains" | "greaterThan" | "lessThan" | "greaterThanOrEqual" | "lessThanOrEqual" | "exists" | "notExists" | "in" | "notIn";
29
29
  export interface IAutomationCondition {
@@ -69,6 +69,8 @@ export interface IAutomationEmailAction {
69
69
  body: string;
70
70
  cc?: string[];
71
71
  bcc?: string[];
72
+ useTemplate?: boolean;
73
+ templateId?: string;
72
74
  }
73
75
  export interface IAutomationNotificationAction {
74
76
  type: "notification";
@@ -169,6 +171,27 @@ export interface IAutomationContext {
169
171
  oldValue: any;
170
172
  newValue: any;
171
173
  };
174
+ walkthrough?: {
175
+ id: string;
176
+ templateId: string;
177
+ templateName: string;
178
+ submittedBy: {
179
+ id: string;
180
+ firstName: string;
181
+ lastName: string;
182
+ email?: string;
183
+ };
184
+ submittedAt: string;
185
+ comments?: string;
186
+ fields: Array<{
187
+ fieldId: string;
188
+ label: string;
189
+ type: "number" | "yesno" | "comment";
190
+ value: any;
191
+ status?: string;
192
+ }>;
193
+ [key: string]: any;
194
+ };
172
195
  triggeredBy?: {
173
196
  userId?: string;
174
197
  userName?: string;
@@ -0,0 +1,47 @@
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 { Document } from "mongoose";
26
+ export interface IEmailTemplateVariable {
27
+ key: string;
28
+ label: string;
29
+ description: string;
30
+ example?: string;
31
+ }
32
+ export interface ILeanEmailTemplate {
33
+ _id: string;
34
+ name: string;
35
+ description?: string;
36
+ triggerType: string;
37
+ subject: string;
38
+ bodyHtml: string;
39
+ bodyText?: string;
40
+ isDefault: boolean;
41
+ isEditable: boolean;
42
+ variables: IEmailTemplateVariable[];
43
+ previewData?: any;
44
+ createdAt: Date;
45
+ updatedAt: Date;
46
+ }
47
+ export type IEmailTemplate = ILeanEmailTemplate & Document;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/dist/index.d.ts CHANGED
@@ -36,3 +36,4 @@ export * from "./IInventory";
36
36
  export * from "./ISupplier";
37
37
  export * from "./ISchedule";
38
38
  export * from "./IAutomation";
39
+ export * from "./IEmailTemplate";
package/dist/index.js CHANGED
@@ -52,3 +52,4 @@ __exportStar(require("./IInventory"), exports);
52
52
  __exportStar(require("./ISupplier"), exports);
53
53
  __exportStar(require("./ISchedule"), exports);
54
54
  __exportStar(require("./IAutomation"), exports);
55
+ __exportStar(require("./IEmailTemplate"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "truflow",
3
- "version": "0.0.191",
3
+ "version": "0.0.192",
4
4
  "main": "./dist/index.js",
5
5
  "license": "MIT",
6
6
  "scripts": {
@@ -23,6 +23,7 @@
23
23
  "@types/node": "^24.10.1",
24
24
  "express": "^5.2.1",
25
25
  "luxon": "^3.7.2",
26
+ "mongoose": "^9.1.4",
26
27
  "socket.io": "^4.5.1",
27
28
  "typescript": "5.3.3"
28
29
  }
@@ -4,11 +4,13 @@ import mongoose, { Document } from "mongoose";
4
4
  export type AutomationTriggerType =
5
5
  | "order.created" // When a new order is created
6
6
  | "order.updated" // When an order is updated
7
- | "order.status_changed" // When order status changes
8
- | "schedule.entry_added" // When order matches schedule filters and is added
9
- | "schedule.field_changed" // When a custom schedule field value changes
7
+ | "order.statusChanged" // When order status changes
8
+ | "schedule.entryAdded" // When order matches schedule filters and is added
9
+ | "schedule.fieldChanged" // When a custom schedule field value changes
10
10
  | "measurement.added" // When a measurement is added to an order product
11
- | "measurement.completed"; // When all measurements are completed for an order
11
+ | "measurement.completed" // When all measurements are completed for an order
12
+ | "walkthrough.submitted" // When a walkthrough template is submitted
13
+ | "walkthrough.arrived"; // When a walkthrough template is submitted (alias for notifications)
12
14
 
13
15
  // Action types that can be executed
14
16
  export type AutomationActionType =
@@ -95,6 +97,8 @@ export interface IAutomationEmailAction {
95
97
  body: string; // Email body (can use template variables)
96
98
  cc?: string[]; // Optional CC addresses
97
99
  bcc?: string[]; // Optional BCC addresses
100
+ useTemplate?: boolean; // Whether to use an email template
101
+ templateId?: string; // ID of the email template to use
98
102
  }
99
103
 
100
104
  // Notification action configuration
@@ -230,6 +234,27 @@ export interface IAutomationContext {
230
234
  oldValue: any; // Previous value
231
235
  newValue: any; // New value
232
236
  };
237
+ walkthrough?: {
238
+ id: string; // Submission ID
239
+ templateId: string; // Template ID
240
+ templateName: string; // Template name
241
+ submittedBy: {
242
+ id: string;
243
+ firstName: string;
244
+ lastName: string;
245
+ email?: string;
246
+ };
247
+ submittedAt: string; // ISO date string
248
+ comments?: string; // Optional general comments
249
+ fields: Array<{ // All field values from the submission
250
+ fieldId: string;
251
+ label: string;
252
+ type: "number" | "yesno" | "comment";
253
+ value: any;
254
+ status?: string; // Buffer zone status if applicable
255
+ }>;
256
+ [key: string]: any; // Allow dynamic field access
257
+ };
233
258
  triggeredBy?: {
234
259
  userId?: string;
235
260
  userName?: string;
@@ -0,0 +1,26 @@
1
+ import mongoose, { Document } from "mongoose";
2
+
3
+ export interface IEmailTemplateVariable {
4
+ key: string;
5
+ label: string;
6
+ description: string;
7
+ example?: string;
8
+ }
9
+
10
+ export interface ILeanEmailTemplate {
11
+ _id: string;
12
+ name: string;
13
+ description?: string;
14
+ triggerType: string; // Single trigger type this template is for (e.g., "walkthrough.submitted", "order.created")
15
+ subject: string;
16
+ bodyHtml: string;
17
+ bodyText?: string; // Optional plain text version
18
+ isDefault: boolean; // Whether this is a system-provided default template
19
+ isEditable: boolean; // Whether users can edit this template
20
+ variables: IEmailTemplateVariable[]; // Available variables for this template
21
+ previewData?: any; // Sample data for preview
22
+ createdAt: Date;
23
+ updatedAt: Date;
24
+ }
25
+
26
+ export type IEmailTemplate = ILeanEmailTemplate & Document;
package/src/index.ts CHANGED
@@ -36,3 +36,4 @@ export * from "./IInventory";
36
36
  export * from "./ISupplier";
37
37
  export * from "./ISchedule";
38
38
  export * from "./IAutomation";
39
+ export * from "./IEmailTemplate";