@sprucelabs/spruce-appointment-utils 8.0.13 → 8.0.14

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.
@@ -12,5 +12,6 @@ export default class RemoteRoleCapabilityStore {
12
12
  persist(): Promise<import("@sprucelabs/schema").SchemaStaticValues<import("@sprucelabs/mercury-types").SpruceSchemas.Appointments.v2021_06_23.UpdateRoleCapabilitySchema, false, import("@sprucelabs/schema").SchemaOptionalFieldNames<import("@sprucelabs/mercury-types").SpruceSchemas.Appointments.v2021_06_23.UpdateRoleCapabilitySchema>, import("@sprucelabs/schema").StaticSchemaAllValues<import("@sprucelabs/mercury-types").SpruceSchemas.Appointments.v2021_06_23.UpdateRoleCapabilitySchema, false>>[]>;
13
13
  protected createCapability(roleId: any, serviceId: any, values: any): Promise<import("@sprucelabs/schema").SchemaStaticValues<import("@sprucelabs/mercury-types").SpruceSchemas.Appointments.v2021_06_23.CreateRoleCapabilitySchema, false, import("@sprucelabs/schema").SchemaOptionalFieldNames<import("@sprucelabs/mercury-types").SpruceSchemas.Appointments.v2021_06_23.CreateRoleCapabilitySchema>, import("@sprucelabs/schema").StaticSchemaAllValues<import("@sprucelabs/mercury-types").SpruceSchemas.Appointments.v2021_06_23.CreateRoleCapabilitySchema, false>>>;
14
14
  protected updateCapability(id: any, values: any): Promise<import("@sprucelabs/schema").SchemaStaticValues<import("@sprucelabs/mercury-types").SpruceSchemas.Appointments.v2021_06_23.UpdateRoleCapabilitySchema, false, import("@sprucelabs/schema").SchemaOptionalFieldNames<import("@sprucelabs/mercury-types").SpruceSchemas.Appointments.v2021_06_23.UpdateRoleCapabilitySchema>, import("@sprucelabs/schema").StaticSchemaAllValues<import("@sprucelabs/mercury-types").SpruceSchemas.Appointments.v2021_06_23.UpdateRoleCapabilitySchema, false>>>;
15
+ protected clean(value: any): any;
15
16
  }
16
17
  export {};
@@ -22,8 +22,9 @@ class RemoteRoleCapabilityStore {
22
22
  async queue(value) {
23
23
  (0, schema_1.assertOptions)(value, ['serviceId', 'roleId']);
24
24
  const id = `${this.organizationId}-${value.serviceId}-${value.roleId}`;
25
- this.queuedCapabilities[id] = Object.assign(Object.assign({}, this.queuedCapabilities[id]), value);
26
- return value;
25
+ const cleaned = this.clean(value);
26
+ this.queuedCapabilities[id] = Object.assign(Object.assign({}, this.queuedCapabilities[id]), cleaned);
27
+ return this.queuedCapabilities[id];
27
28
  }
28
29
  async persist() {
29
30
  let response = [];
@@ -61,5 +62,21 @@ class RemoteRoleCapabilityStore {
61
62
  });
62
63
  return capability;
63
64
  }
65
+ clean(value) {
66
+ const cleaned = Object.assign({}, value);
67
+ if (!cleaned.timeBlocks) {
68
+ return cleaned;
69
+ }
70
+ const timeBlocks = [];
71
+ for (const t of cleaned.timeBlocks) {
72
+ timeBlocks.push({
73
+ durationMinutes: t.durationMinutes,
74
+ isBusy: t.isBusy,
75
+ title: t.title,
76
+ });
77
+ }
78
+ cleaned.timeBlocks = timeBlocks;
79
+ return cleaned;
80
+ }
64
81
  }
65
82
  exports.default = RemoteRoleCapabilityStore;
@@ -12,5 +12,6 @@ export default class RemoteRoleCapabilityStore {
12
12
  persist(): Promise<import("@sprucelabs/schema").SchemaStaticValues<import("@sprucelabs/mercury-types").SpruceSchemas.Appointments.v2021_06_23.UpdateRoleCapabilitySchema, false, import("@sprucelabs/schema").SchemaOptionalFieldNames<import("@sprucelabs/mercury-types").SpruceSchemas.Appointments.v2021_06_23.UpdateRoleCapabilitySchema>, import("@sprucelabs/schema").StaticSchemaAllValues<import("@sprucelabs/mercury-types").SpruceSchemas.Appointments.v2021_06_23.UpdateRoleCapabilitySchema, false>>[]>;
13
13
  protected createCapability(roleId: any, serviceId: any, values: any): Promise<import("@sprucelabs/schema").SchemaStaticValues<import("@sprucelabs/mercury-types").SpruceSchemas.Appointments.v2021_06_23.CreateRoleCapabilitySchema, false, import("@sprucelabs/schema").SchemaOptionalFieldNames<import("@sprucelabs/mercury-types").SpruceSchemas.Appointments.v2021_06_23.CreateRoleCapabilitySchema>, import("@sprucelabs/schema").StaticSchemaAllValues<import("@sprucelabs/mercury-types").SpruceSchemas.Appointments.v2021_06_23.CreateRoleCapabilitySchema, false>>>;
14
14
  protected updateCapability(id: any, values: any): Promise<import("@sprucelabs/schema").SchemaStaticValues<import("@sprucelabs/mercury-types").SpruceSchemas.Appointments.v2021_06_23.UpdateRoleCapabilitySchema, false, import("@sprucelabs/schema").SchemaOptionalFieldNames<import("@sprucelabs/mercury-types").SpruceSchemas.Appointments.v2021_06_23.UpdateRoleCapabilitySchema>, import("@sprucelabs/schema").StaticSchemaAllValues<import("@sprucelabs/mercury-types").SpruceSchemas.Appointments.v2021_06_23.UpdateRoleCapabilitySchema, false>>>;
15
+ protected clean(value: any): any;
15
16
  }
16
17
  export {};
@@ -30,8 +30,9 @@ export default class RemoteRoleCapabilityStore {
30
30
  return __awaiter(this, void 0, void 0, function* () {
31
31
  assertOptions(value, ['serviceId', 'roleId']);
32
32
  const id = `${this.organizationId}-${value.serviceId}-${value.roleId}`;
33
- this.queuedCapabilities[id] = Object.assign(Object.assign({}, this.queuedCapabilities[id]), value);
34
- return value;
33
+ const cleaned = this.clean(value);
34
+ this.queuedCapabilities[id] = Object.assign(Object.assign({}, this.queuedCapabilities[id]), cleaned);
35
+ return this.queuedCapabilities[id];
35
36
  });
36
37
  }
37
38
  persist() {
@@ -76,4 +77,20 @@ export default class RemoteRoleCapabilityStore {
76
77
  return capability;
77
78
  });
78
79
  }
80
+ clean(value) {
81
+ const cleaned = Object.assign({}, value);
82
+ if (!cleaned.timeBlocks) {
83
+ return cleaned;
84
+ }
85
+ const timeBlocks = [];
86
+ for (const t of cleaned.timeBlocks) {
87
+ timeBlocks.push({
88
+ durationMinutes: t.durationMinutes,
89
+ isBusy: t.isBusy,
90
+ title: t.title,
91
+ });
92
+ }
93
+ cleaned.timeBlocks = timeBlocks;
94
+ return cleaned;
95
+ }
79
96
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sprucelabs/spruce-appointment-utils",
3
3
  "description": "Utils for working with appointments and Sprucebot.",
4
- "version": "8.0.13",
4
+ "version": "8.0.14",
5
5
  "skill": {
6
6
  "namespace": "appointments"
7
7
  },