@sprucelabs/spruce-calendar-components 39.4.0 → 39.5.0
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.
- package/build/__tests__/support/CalendarToolBeltStateMachineTestFactory.js +8 -2
- package/build/esm/__tests__/support/CalendarToolBeltStateMachineTestFactory.js +9 -4
- package/build/esm/toolBelt/states/PrerequisitesToolBeltState.d.ts +10 -9
- package/build/esm/toolBelt/states/PrerequisitesToolBeltState.js +10 -5
- package/build/esm/types/calendar.types.d.ts +1 -0
- package/build/toolBelt/states/PrerequisitesToolBeltState.d.ts +10 -9
- package/build/toolBelt/states/PrerequisitesToolBeltState.js +10 -5
- package/build/types/calendar.types.d.ts +1 -0
- package/package.json +1 -1
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.FakeRemoteEventStore = void 0;
|
|
7
7
|
const calendar_utils_1 = require("@sprucelabs/calendar-utils");
|
|
8
8
|
const heartwood_view_controllers_1 = require("@sprucelabs/heartwood-view-controllers");
|
|
9
|
+
const spruce_agent_utils_1 = require("@sprucelabs/spruce-agent-utils");
|
|
9
10
|
const spruce_test_fixtures_1 = require("@sprucelabs/spruce-test-fixtures");
|
|
10
11
|
const test_utils_1 = require("@sprucelabs/test-utils");
|
|
11
12
|
const RemotePreferencesStore_1 = __importDefault(require("../../stores/RemotePreferencesStore"));
|
|
@@ -30,18 +31,23 @@ class CalendarToolBeltStateMachineTestFactory {
|
|
|
30
31
|
},
|
|
31
32
|
});
|
|
32
33
|
calendarVc.addEvent(event);
|
|
34
|
+
const client = spruce_test_fixtures_1.fake.getClient();
|
|
35
|
+
test_utils_1.assert.isTruthy(client, `Make sure to attach @fake.login() to your test class!`);
|
|
36
|
+
await spruce_agent_utils_1.agentAssert.beforeEach(client);
|
|
37
|
+
spruce_agent_utils_1.SpruceAgent.setup(client);
|
|
38
|
+
const connectToApi = async () => spruce_test_fixtures_1.fake.getClient();
|
|
33
39
|
const sm = new heartwood_view_controllers_1.ToolBeltStateMachine({
|
|
34
40
|
vcFactory: views.getFactory(),
|
|
35
41
|
toolBeltVc,
|
|
36
|
-
connectToApi
|
|
42
|
+
connectToApi,
|
|
37
43
|
context: {
|
|
38
44
|
...views.getRouter().buildLoadOptions(),
|
|
39
45
|
event,
|
|
40
46
|
calendarVc: calendarVc,
|
|
47
|
+
agentName: await spruce_agent_utils_1.SpruceAgent.getInstance().getName(),
|
|
41
48
|
cancelEvent: () => { },
|
|
42
49
|
},
|
|
43
50
|
});
|
|
44
|
-
const connectToApi = async () => spruce_test_fixtures_1.fake.getClient();
|
|
45
51
|
const preferences = new FakeRemotePreferences({ connectToApi });
|
|
46
52
|
const remoteEventsStore = new FakeRemoteEventStore();
|
|
47
53
|
const events = new (EventManagerClass ?? SpyEventManager_1.default)({
|
|
@@ -9,8 +9,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { dateUtil } from '@sprucelabs/calendar-utils';
|
|
11
11
|
import { calendarSeeder, ToolBeltStateMachine, } from '@sprucelabs/heartwood-view-controllers';
|
|
12
|
+
import { agentAssert, SpruceAgent } from '@sprucelabs/spruce-agent-utils';
|
|
12
13
|
import { fake } from '@sprucelabs/spruce-test-fixtures';
|
|
13
|
-
import { generateId } from '@sprucelabs/test-utils';
|
|
14
|
+
import { assert, generateId } from '@sprucelabs/test-utils';
|
|
14
15
|
import RemotePreferencesStore from '../../stores/RemotePreferencesStore.js';
|
|
15
16
|
import draftEventGenerator from '../../utilities/draftGenerator.js';
|
|
16
17
|
import SpyEventManager from './SpyEventManager.js';
|
|
@@ -33,13 +34,17 @@ export default class CalendarToolBeltStateMachineTestFactory {
|
|
|
33
34
|
},
|
|
34
35
|
});
|
|
35
36
|
calendarVc.addEvent(event);
|
|
37
|
+
const client = fake.getClient();
|
|
38
|
+
assert.isTruthy(client, `Make sure to attach @fake.login() to your test class!`);
|
|
39
|
+
yield agentAssert.beforeEach(client);
|
|
40
|
+
SpruceAgent.setup(client);
|
|
41
|
+
const connectToApi = () => __awaiter(this, void 0, void 0, function* () { return fake.getClient(); });
|
|
36
42
|
const sm = new ToolBeltStateMachine({
|
|
37
43
|
vcFactory: views.getFactory(),
|
|
38
44
|
toolBeltVc,
|
|
39
|
-
connectToApi
|
|
40
|
-
context: Object.assign(Object.assign({}, views.getRouter().buildLoadOptions()), { event, calendarVc: calendarVc, cancelEvent: () => { } }),
|
|
45
|
+
connectToApi,
|
|
46
|
+
context: Object.assign(Object.assign({}, views.getRouter().buildLoadOptions()), { event, calendarVc: calendarVc, agentName: yield SpruceAgent.getInstance().getName(), cancelEvent: () => { } }),
|
|
41
47
|
});
|
|
42
|
-
const connectToApi = () => __awaiter(this, void 0, void 0, function* () { return fake.getClient(); });
|
|
43
48
|
const preferences = new FakeRemotePreferences({ connectToApi });
|
|
44
49
|
const remoteEventsStore = new FakeRemoteEventStore();
|
|
45
50
|
const events = new (EventManagerClass !== null && EventManagerClass !== void 0 ? EventManagerClass : SpyEventManager)({
|
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
import { CardViewController, SpruceSchemas, ToolBeltState } from '@sprucelabs/heartwood-view-controllers';
|
|
2
2
|
import { CalendarToolBeltStateMachine } from '../../types/calendar.types';
|
|
3
|
-
type Calendar = SpruceSchemas.Calendar.v2021_05_19.Calendar;
|
|
4
|
-
type EventType = SpruceSchemas.Calendar.v2021_05_19.CalendarEventType;
|
|
5
|
-
type SelectCalendarHandler = (calendar: Calendar) => Promise<void> | void;
|
|
6
|
-
type SelectTypeHandler = (type: EventType) => Promise<void> | void;
|
|
7
|
-
export interface PrerequisitesToolBeltStateOptions {
|
|
8
|
-
onSelectCalendar?: SelectCalendarHandler;
|
|
9
|
-
onSelectEventType?: SelectTypeHandler;
|
|
10
|
-
}
|
|
11
3
|
export declare class PrerequisitesToolBeltState implements ToolBeltState {
|
|
12
4
|
readonly id = "prerequisites";
|
|
13
5
|
private calendarSelectCardVc?;
|
|
@@ -17,7 +9,6 @@ export declare class PrerequisitesToolBeltState implements ToolBeltState {
|
|
|
17
9
|
private selectCalendarHandler?;
|
|
18
10
|
private selectEventTypeHandler?;
|
|
19
11
|
private calendar?;
|
|
20
|
-
private get calendars();
|
|
21
12
|
constructor(options?: PrerequisitesToolBeltStateOptions);
|
|
22
13
|
load(stateMachine: CalendarToolBeltStateMachine): Promise<void>;
|
|
23
14
|
destroy(): void;
|
|
@@ -32,5 +23,15 @@ export declare class PrerequisitesToolBeltState implements ToolBeltState {
|
|
|
32
23
|
getTypeSelectCardVc(): CardViewController | undefined;
|
|
33
24
|
private SelectCalendarCardVc;
|
|
34
25
|
private connectToApi;
|
|
26
|
+
private get calendars();
|
|
27
|
+
private get context();
|
|
28
|
+
}
|
|
29
|
+
type Calendar = SpruceSchemas.Calendar.v2021_05_19.Calendar;
|
|
30
|
+
type EventType = SpruceSchemas.Calendar.v2021_05_19.CalendarEventType;
|
|
31
|
+
type SelectCalendarHandler = (calendar: Calendar) => Promise<void> | void;
|
|
32
|
+
type SelectTypeHandler = (type: EventType) => Promise<void> | void;
|
|
33
|
+
export interface PrerequisitesToolBeltStateOptions {
|
|
34
|
+
onSelectCalendar?: SelectCalendarHandler;
|
|
35
|
+
onSelectEventType?: SelectTypeHandler;
|
|
35
36
|
}
|
|
36
37
|
export {};
|
|
@@ -9,9 +9,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import makeEventTyped from './makeEventTyped.js';
|
|
11
11
|
export class PrerequisitesToolBeltState {
|
|
12
|
-
get calendars() {
|
|
13
|
-
return this.sm.getContext().events.getCalendars();
|
|
14
|
-
}
|
|
15
12
|
constructor(options) {
|
|
16
13
|
this.id = 'prerequisites';
|
|
17
14
|
this.selectCalendarHandler = options === null || options === void 0 ? void 0 : options.onSelectCalendar;
|
|
@@ -32,7 +29,7 @@ export class PrerequisitesToolBeltState {
|
|
|
32
29
|
}
|
|
33
30
|
this.setupCalendarSelectCard(this.calendars);
|
|
34
31
|
yield this.sm.updateContext({
|
|
35
|
-
event: Object.assign(Object.assign({}, this.
|
|
32
|
+
event: Object.assign(Object.assign({}, this.context.event), { isBusy: false }),
|
|
36
33
|
});
|
|
37
34
|
});
|
|
38
35
|
}
|
|
@@ -54,9 +51,11 @@ export class PrerequisitesToolBeltState {
|
|
|
54
51
|
});
|
|
55
52
|
}
|
|
56
53
|
else {
|
|
54
|
+
const agentName = this.context.agentName;
|
|
57
55
|
this.calendarSelectCardVc.addSection({
|
|
56
|
+
id: 'no-calendars',
|
|
58
57
|
text: {
|
|
59
|
-
content: `You don't have any calendars. The only way to get one is to book an appointment or work at a place that uses
|
|
58
|
+
content: `You don't have any calendars. The only way to get one is to book an appointment or work at a place that uses ${agentName}! 🌲🤖`,
|
|
60
59
|
},
|
|
61
60
|
});
|
|
62
61
|
}
|
|
@@ -174,4 +173,10 @@ export class PrerequisitesToolBeltState {
|
|
|
174
173
|
return yield this.sm.connectToApi();
|
|
175
174
|
});
|
|
176
175
|
}
|
|
176
|
+
get calendars() {
|
|
177
|
+
return this.context.events.getCalendars();
|
|
178
|
+
}
|
|
179
|
+
get context() {
|
|
180
|
+
return this.sm.getContext();
|
|
181
|
+
}
|
|
177
182
|
}
|
|
@@ -37,6 +37,7 @@ type ICalendarToolBeltContext = SkillViewControllerLoadOptions & {
|
|
|
37
37
|
cancelEvent: CancelEventHandler;
|
|
38
38
|
events: CalendarEventManager;
|
|
39
39
|
people: CalendarPeopleManager;
|
|
40
|
+
agentName: string;
|
|
40
41
|
};
|
|
41
42
|
export interface CalendarToolBeltContext extends ICalendarToolBeltContext {
|
|
42
43
|
}
|
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
import { CardViewController, SpruceSchemas, ToolBeltState } from '@sprucelabs/heartwood-view-controllers';
|
|
2
2
|
import { CalendarToolBeltStateMachine } from '../../types/calendar.types';
|
|
3
|
-
type Calendar = SpruceSchemas.Calendar.v2021_05_19.Calendar;
|
|
4
|
-
type EventType = SpruceSchemas.Calendar.v2021_05_19.CalendarEventType;
|
|
5
|
-
type SelectCalendarHandler = (calendar: Calendar) => Promise<void> | void;
|
|
6
|
-
type SelectTypeHandler = (type: EventType) => Promise<void> | void;
|
|
7
|
-
export interface PrerequisitesToolBeltStateOptions {
|
|
8
|
-
onSelectCalendar?: SelectCalendarHandler;
|
|
9
|
-
onSelectEventType?: SelectTypeHandler;
|
|
10
|
-
}
|
|
11
3
|
export declare class PrerequisitesToolBeltState implements ToolBeltState {
|
|
12
4
|
readonly id = "prerequisites";
|
|
13
5
|
private calendarSelectCardVc?;
|
|
@@ -17,7 +9,6 @@ export declare class PrerequisitesToolBeltState implements ToolBeltState {
|
|
|
17
9
|
private selectCalendarHandler?;
|
|
18
10
|
private selectEventTypeHandler?;
|
|
19
11
|
private calendar?;
|
|
20
|
-
private get calendars();
|
|
21
12
|
constructor(options?: PrerequisitesToolBeltStateOptions);
|
|
22
13
|
load(stateMachine: CalendarToolBeltStateMachine): Promise<void>;
|
|
23
14
|
destroy(): void;
|
|
@@ -32,5 +23,15 @@ export declare class PrerequisitesToolBeltState implements ToolBeltState {
|
|
|
32
23
|
getTypeSelectCardVc(): CardViewController | undefined;
|
|
33
24
|
private SelectCalendarCardVc;
|
|
34
25
|
private connectToApi;
|
|
26
|
+
private get calendars();
|
|
27
|
+
private get context();
|
|
28
|
+
}
|
|
29
|
+
type Calendar = SpruceSchemas.Calendar.v2021_05_19.Calendar;
|
|
30
|
+
type EventType = SpruceSchemas.Calendar.v2021_05_19.CalendarEventType;
|
|
31
|
+
type SelectCalendarHandler = (calendar: Calendar) => Promise<void> | void;
|
|
32
|
+
type SelectTypeHandler = (type: EventType) => Promise<void> | void;
|
|
33
|
+
export interface PrerequisitesToolBeltStateOptions {
|
|
34
|
+
onSelectCalendar?: SelectCalendarHandler;
|
|
35
|
+
onSelectEventType?: SelectTypeHandler;
|
|
35
36
|
}
|
|
36
37
|
export {};
|
|
@@ -6,9 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.PrerequisitesToolBeltState = void 0;
|
|
7
7
|
const makeEventTyped_1 = __importDefault(require("./makeEventTyped"));
|
|
8
8
|
class PrerequisitesToolBeltState {
|
|
9
|
-
get calendars() {
|
|
10
|
-
return this.sm.getContext().events.getCalendars();
|
|
11
|
-
}
|
|
12
9
|
constructor(options) {
|
|
13
10
|
this.id = 'prerequisites';
|
|
14
11
|
this.selectCalendarHandler = options?.onSelectCalendar;
|
|
@@ -29,7 +26,7 @@ class PrerequisitesToolBeltState {
|
|
|
29
26
|
this.setupCalendarSelectCard(this.calendars);
|
|
30
27
|
await this.sm.updateContext({
|
|
31
28
|
event: {
|
|
32
|
-
...this.
|
|
29
|
+
...this.context.event,
|
|
33
30
|
isBusy: false,
|
|
34
31
|
},
|
|
35
32
|
});
|
|
@@ -52,9 +49,11 @@ class PrerequisitesToolBeltState {
|
|
|
52
49
|
});
|
|
53
50
|
}
|
|
54
51
|
else {
|
|
52
|
+
const agentName = this.context.agentName;
|
|
55
53
|
this.calendarSelectCardVc.addSection({
|
|
54
|
+
id: 'no-calendars',
|
|
56
55
|
text: {
|
|
57
|
-
content: `You don't have any calendars. The only way to get one is to book an appointment or work at a place that uses
|
|
56
|
+
content: `You don't have any calendars. The only way to get one is to book an appointment or work at a place that uses ${agentName}! 🌲🤖`,
|
|
58
57
|
},
|
|
59
58
|
});
|
|
60
59
|
}
|
|
@@ -159,5 +158,11 @@ class PrerequisitesToolBeltState {
|
|
|
159
158
|
async connectToApi() {
|
|
160
159
|
return await this.sm.connectToApi();
|
|
161
160
|
}
|
|
161
|
+
get calendars() {
|
|
162
|
+
return this.context.events.getCalendars();
|
|
163
|
+
}
|
|
164
|
+
get context() {
|
|
165
|
+
return this.sm.getContext();
|
|
166
|
+
}
|
|
162
167
|
}
|
|
163
168
|
exports.PrerequisitesToolBeltState = PrerequisitesToolBeltState;
|
|
@@ -37,6 +37,7 @@ type ICalendarToolBeltContext = SkillViewControllerLoadOptions & {
|
|
|
37
37
|
cancelEvent: CancelEventHandler;
|
|
38
38
|
events: CalendarEventManager;
|
|
39
39
|
people: CalendarPeopleManager;
|
|
40
|
+
agentName: string;
|
|
40
41
|
};
|
|
41
42
|
export interface CalendarToolBeltContext extends ICalendarToolBeltContext {
|
|
42
43
|
}
|