shuttlepro-shared 1.2.51 → 1.2.52

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.
Files changed (2) hide show
  1. package/models/Workspace.js +140 -27
  2. package/package.json +1 -1
@@ -1,26 +1,27 @@
1
1
  const mongoose = require("mongoose");
2
-
3
- const shiftSchema = new mongoose.Schema({
4
- _id: {
5
- type: mongoose.Schema.Types.ObjectId,
6
- default: mongoose.Types.ObjectId,
7
- },
8
- shiftName: {
9
- type: String,
10
- required: true,
11
- },
12
- days: [
13
- {
14
- day: { type: String, required: true },
15
- startTime: { type: String, required: true },
16
- endTime: { type: String, required: true },
17
- breakStartTime: { type: String, required: false },
18
- breakEndTime: { type: String, required: false },
19
- lateThreshold: { type: String, required: false },
2
+ const {
3
+ createDefaultLocations,
4
+ addTaskManagerDefaultData,
5
+ } = require("../libs/shared/helpers");
6
+ const shiftSchema = new mongoose.Schema(
7
+ {
8
+ shiftName: {
9
+ type: String,
10
+ required: true,
20
11
  },
21
- ],
22
- });
23
-
12
+ days: [
13
+ {
14
+ day: { type: String, required: true },
15
+ startTime: { type: String, required: true },
16
+ endTime: { type: String, required: true },
17
+ breakStartTime: { type: String, required: false },
18
+ breakEndTime: { type: String, required: false },
19
+ lateThreshold: { type: String, required: false },
20
+ },
21
+ ],
22
+ },
23
+ { _id: true }
24
+ );
24
25
  const scoreThresholdSchema = new mongoose.Schema({
25
26
  operator: {
26
27
  type: mongoose.Schema.Types.Mixed,
@@ -39,7 +40,6 @@ const scoreThresholdSchema = new mongoose.Schema({
39
40
  default: {},
40
41
  },
41
42
  });
42
-
43
43
  const kpiSchema = new mongoose.Schema({
44
44
  weight: {
45
45
  type: Number,
@@ -54,7 +54,95 @@ const kpiSchema = new mongoose.Schema({
54
54
  default: false,
55
55
  },
56
56
  });
57
-
57
+ const ReasonSchema = new mongoose.Schema({
58
+ _id: {
59
+ type: mongoose.Schema.Types.ObjectId,
60
+ default: null,
61
+ },
62
+ reason: { type: String, required: true },
63
+ color: { type: String, default: "#000000" },
64
+ categoryTitle: { type: String, required: true },
65
+ });
66
+ const ResolutionReasonCategorySchema = new mongoose.Schema({
67
+ _id: {
68
+ type: mongoose.Schema.Types.ObjectId,
69
+ default: null,
70
+ },
71
+ title: { type: String, required: true },
72
+ reasons: { type: [ReasonSchema], default: [] },
73
+ });
74
+ const feedbackFormSchema = new mongoose.Schema({
75
+ formName: { type: String, required: true, trim: true },
76
+ brandName: { type: String, default: "" },
77
+ brandLogoUrl: { type: String, default: "", trim: true },
78
+ type: { type: String, default: "agent", enum: ["agent", "order"] },
79
+ qr: {
80
+ data: { type: String, default: "", trim: true },
81
+ code: { type: String, default: "", trim: true },
82
+ link: { type: String, default: "", trim: true },
83
+ },
84
+ integrationId: [
85
+ {
86
+ type: mongoose.Schema.Types.ObjectId,
87
+ ref: "Integration",
88
+ default: null,
89
+ },
90
+ ],
91
+ enabled: {
92
+ type: Boolean,
93
+ default: true,
94
+ },
95
+ fields: [
96
+ {
97
+ fieldName: {
98
+ type: String,
99
+ required: true,
100
+ trim: true,
101
+ },
102
+ required: {
103
+ type: Boolean,
104
+ default: false,
105
+ },
106
+ enabled: {
107
+ type: Boolean,
108
+ default: true,
109
+ },
110
+ createdBy: {
111
+ type: mongoose.Schema.Types.ObjectId,
112
+ ref: "User",
113
+ default: null,
114
+ },
115
+ updatedBy: {
116
+ type: mongoose.Schema.Types.ObjectId,
117
+ ref: "User",
118
+ default: null,
119
+ },
120
+ fieldType: {
121
+ type: String,
122
+ enum: [
123
+ "text",
124
+ "autocomplete",
125
+ "radio",
126
+ "text area",
127
+ "number",
128
+ "date",
129
+ "time",
130
+ "email",
131
+ "range",
132
+ "url",
133
+ "colour",
134
+ "file",
135
+ "starRating",
136
+ "heading",
137
+ "paragraph",
138
+ ],
139
+ },
140
+ option: {
141
+ type: mongoose.Schema.Types.Mixed,
142
+ },
143
+ },
144
+ ],
145
+ });
58
146
  const workspaceSchema = new mongoose.Schema(
59
147
  {
60
148
  name: {
@@ -101,6 +189,7 @@ const workspaceSchema = new mongoose.Schema(
101
189
  {
102
190
  reason: { type: String, default: "" },
103
191
  type: { type: String, default: "" },
192
+ color: { type: String, default: "" },
104
193
  },
105
194
  ],
106
195
  chatGptApiKey: String,
@@ -113,7 +202,11 @@ const workspaceSchema = new mongoose.Schema(
113
202
  queueTracking: { type: Boolean, default: false },
114
203
  orderConfiguration: { type: String, default: "" },
115
204
  defaultModule: { type: String, default: "dashboard" },
116
- defaultShift: { type: String, default: "" },
205
+ resolutionReasonCategories: {
206
+ type: [ResolutionReasonCategorySchema],
207
+ default: [],
208
+ },
209
+ feedbackDynamicFields: [feedbackFormSchema],
117
210
  dynamicFieldsTemplate: [
118
211
  {
119
212
  groupName: { type: String, required: true, trim: true },
@@ -166,16 +259,20 @@ const workspaceSchema = new mongoose.Schema(
166
259
  ],
167
260
  },
168
261
  ],
262
+ crmVisibility: {
263
+ type: String,
264
+ enum: ["everyone", "assignee"],
265
+ default: "everyone",
266
+ },
267
+ defaultShift: { type: String, default: "" },
169
268
  },
170
269
  { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } }
171
270
  );
172
-
173
271
  const commonOptions = {
174
272
  type: String,
175
273
  trim: true,
176
274
  default: "",
177
275
  };
178
-
179
276
  workspaceSchema.add({
180
277
  contact: commonOptions,
181
278
  email: commonOptions,
@@ -186,6 +283,22 @@ workspaceSchema.add({
186
283
  instagramUrl: commonOptions,
187
284
  chatGptApiKey: commonOptions,
188
285
  });
189
-
286
+ workspaceSchema.post("save", async function (doc) {
287
+ try {
288
+ if (doc?.id) {
289
+ await Promise.all([
290
+ createDefaultLocations(doc.id, doc.createdBy || null),
291
+ addTaskManagerDefaultData(doc.id),
292
+ ]);
293
+ }
294
+ } catch (err) {
295
+ console.log("err", err);
296
+ }
297
+ });
298
+ workspaceSchema.virtual("integrations", {
299
+ ref: "Integration",
300
+ localField: "_id",
301
+ foreignField: "workspaceId",
302
+ });
190
303
  const Workspace = mongoose.model("Workspace", workspaceSchema);
191
304
  module.exports = Workspace;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shuttlepro-shared",
3
- "version": "1.2.51",
3
+ "version": "1.2.52",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {