shuttlepro-shared 1.3.35 → 1.3.37

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.
@@ -133,6 +133,10 @@ const AutomationAction = new Schema({
133
133
  },
134
134
  flow: {},
135
135
  },
136
+ chatbot: {
137
+ enabled: { type: Boolean, default: false },
138
+ id: defaultStringType,
139
+ },
136
140
  });
137
141
  const AutomationCondition = new Schema({
138
142
  criteriaType: {
@@ -3,6 +3,15 @@ const SettingModel = require("./Setting");
3
3
  const SocialMediaSettingModel = require("./SocialMediaSetting");
4
4
  const { Schema } = mongoose;
5
5
 
6
+ const generateSlug = (input) => {
7
+ return input
8
+ .trim()
9
+ .toLowerCase()
10
+ .replace(/[^a-z0-9\s-]/g, "")
11
+ .replace(/\s+/g, "-")
12
+ .replace(/-+/g, "-");
13
+ };
14
+
6
15
  //TODO: task manager and default location creation
7
16
  const shiftSchema = new mongoose.Schema(
8
17
  {
@@ -364,5 +373,22 @@ workspaceSchema.add({
364
373
  chatGptApiKey: commonOptions,
365
374
  });
366
375
 
376
+ workspaceSchema.pre("save", async function (next) {
377
+ if (this.isModified("name")) {
378
+ let slug = generateSlug(this.name);
379
+ let slugExists = await mongoose.models.Workspace.findOne({ slug });
380
+
381
+ let counter = 1;
382
+ while (slugExists) {
383
+ slug = `${slug}-${counter}`;
384
+ slugExists = await mongoose.models.Workspace.findOne({ slug });
385
+ counter++;
386
+ }
387
+
388
+ this.slug = slug;
389
+ }
390
+ next();
391
+ });
392
+
367
393
  const Workspace = mongoose.model("Workspace", workspaceSchema);
368
394
  module.exports = Workspace;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shuttlepro-shared",
3
- "version": "1.3.35",
3
+ "version": "1.3.37",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {