@sprucelabs/spruce-calendar-components 25.5.2 → 25.5.3
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/.spruce/schemas/schemas.types.d.ts +1447 -1447
- package/build/esm/.spruce/schemas/schemas.types.d.ts +1447 -1447
- package/build/esm/stores/RemoteEventStore.d.ts +2 -1
- package/build/esm/stores/RemoteEventStore.js +5 -1
- package/build/esm/toolBelt/CalendarToolRegistrar.d.ts +6 -3
- package/build/esm/toolBelt/CalendarToolRegistrar.js +34 -10
- package/build/esm/toolBelt/states/AbstractCalendarEventToolBeltState.js +1 -0
- package/build/stores/RemoteEventStore.d.ts +2 -1
- package/build/stores/RemoteEventStore.js +5 -1
- package/build/toolBelt/CalendarToolRegistrar.d.ts +6 -3
- package/build/toolBelt/CalendarToolRegistrar.js +31 -9
- package/build/toolBelt/states/AbstractCalendarEventToolBeltState.js +1 -0
- package/package.json +1 -1
|
@@ -13,6 +13,7 @@ export default class RemoteEventStoreImpl implements RemoteEventStore {
|
|
|
13
13
|
private queueByEventId;
|
|
14
14
|
private busyByEvent;
|
|
15
15
|
private lastSavedById;
|
|
16
|
+
private calendarEventTypes?;
|
|
16
17
|
constructor(options: RemoteEventStoreOptions);
|
|
17
18
|
load(options: {
|
|
18
19
|
organizationId: string;
|
|
@@ -34,7 +35,7 @@ export default class RemoteEventStoreImpl implements RemoteEventStore {
|
|
|
34
35
|
waitForPendingSaves(): Promise<void>;
|
|
35
36
|
cancelEvent(id: string, options: CancelEventRecurringOptions): Promise<void>;
|
|
36
37
|
getSchedules(options: GetScheduleOptions): Promise<import("@sprucelabs/schema").SchemaStaticValues<SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEventSchema, false, import("@sprucelabs/schema").SchemaOptionalFieldNames<SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEventSchema>, import("@sprucelabs/schema").StaticSchemaAllValues<SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEventSchema, false>>[]>;
|
|
37
|
-
getEventTypes(): Promise<
|
|
38
|
+
getEventTypes(): Promise<SpruceSchemas.Calendar.v2021_05_19.CalendarEventType[]>;
|
|
38
39
|
getCalendars(): Promise<import("@sprucelabs/schema").SchemaStaticValues<SpruceSchemas.Calendar.v2021_05_19.CalendarSchema, false, import("@sprucelabs/schema").SchemaOptionalFieldNames<SpruceSchemas.Calendar.v2021_05_19.CalendarSchema>, import("@sprucelabs/schema").StaticSchemaAllValues<SpruceSchemas.Calendar.v2021_05_19.CalendarSchema, false>>[]>;
|
|
39
40
|
}
|
|
40
41
|
export interface RemoteEventStoreOptions {
|
|
@@ -248,8 +248,12 @@ export default class RemoteEventStoreImpl {
|
|
|
248
248
|
}
|
|
249
249
|
getEventTypes() {
|
|
250
250
|
return __awaiter(this, void 0, void 0, function* () {
|
|
251
|
+
if (this.calendarEventTypes) {
|
|
252
|
+
return this.calendarEventTypes;
|
|
253
|
+
}
|
|
251
254
|
const [{ calendarEventTypes }] = yield this.client.emitAndFlattenResponses('calendar.list-calendar-event-types::v2021_05_19');
|
|
252
|
-
|
|
255
|
+
this.calendarEventTypes = calendarEventTypes;
|
|
256
|
+
return this.calendarEventTypes;
|
|
253
257
|
});
|
|
254
258
|
}
|
|
255
259
|
getCalendars() {
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { RemoteCalendarTool, CalendarToolBeltStateMachine } from '../types/calendar.types';
|
|
2
|
-
export type AddToolHandler = (vc: RemoteCalendarTool & {
|
|
3
|
-
id: string;
|
|
4
|
-
}) => Promise<void> | void;
|
|
5
2
|
export default class CalendarToolRegistrar {
|
|
6
3
|
private sm;
|
|
7
4
|
private addToolHandler?;
|
|
5
|
+
private fetchedRecord;
|
|
8
6
|
constructor(sm: CalendarToolBeltStateMachine, addToolHandler?: AddToolHandler);
|
|
9
7
|
fetchAndAddCards(controllerOptionsHandler?: (vcId: string) => Record<string, any>): Promise<void>;
|
|
8
|
+
private get views();
|
|
9
|
+
private fetchUncached;
|
|
10
10
|
private addTool;
|
|
11
11
|
}
|
|
12
|
+
export type AddToolHandler = (vc: RemoteCalendarTool & {
|
|
13
|
+
id: string;
|
|
14
|
+
}) => Promise<void> | void;
|
|
@@ -10,10 +10,33 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import { CardRegistrar } from '@sprucelabs/spruce-heartwood-utils';
|
|
11
11
|
export default class CalendarToolRegistrar {
|
|
12
12
|
constructor(sm, addToolHandler) {
|
|
13
|
+
this.fetchedRecord = {};
|
|
13
14
|
this.sm = sm;
|
|
14
15
|
this.addToolHandler = addToolHandler;
|
|
15
16
|
}
|
|
16
17
|
fetchAndAddCards(controllerOptionsHandler) {
|
|
18
|
+
var _a;
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
const { event } = this.sm.getContext();
|
|
21
|
+
let cards = [];
|
|
22
|
+
const cacheKey = (_a = event.eventTypeSlug) !== null && _a !== void 0 ? _a : '';
|
|
23
|
+
if (!this.fetchedRecord[cacheKey]) {
|
|
24
|
+
const { cards: fetchedCards, vcIds } = yield this.fetchUncached(controllerOptionsHandler);
|
|
25
|
+
this.fetchedRecord[cacheKey] = vcIds;
|
|
26
|
+
cards = fetchedCards;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
cards = this.fetchedRecord[cacheKey].map((vcId) => this.views.Controller(vcId, {}));
|
|
30
|
+
}
|
|
31
|
+
for (const card of cards) {
|
|
32
|
+
yield this.addTool(card);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
get views() {
|
|
37
|
+
return this.sm.getVcFactory();
|
|
38
|
+
}
|
|
39
|
+
fetchUncached(controllerOptionsHandler) {
|
|
17
40
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18
41
|
const { scope, event } = this.sm.getContext();
|
|
19
42
|
const [org, location] = yield Promise.all([
|
|
@@ -23,21 +46,21 @@ export default class CalendarToolRegistrar {
|
|
|
23
46
|
const client = yield this.sm.connectToApi();
|
|
24
47
|
const registrar = new CardRegistrar({
|
|
25
48
|
client,
|
|
26
|
-
vcFactory: this.
|
|
49
|
+
vcFactory: this.views,
|
|
27
50
|
vcIdsTransformer: (response) => response.vcIds,
|
|
28
51
|
eventName: 'calendar.register-event-tools::v2021_05_19',
|
|
29
52
|
});
|
|
30
53
|
if (!org) {
|
|
31
54
|
throw new Error('No organization found!');
|
|
32
55
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
each: (
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
56
|
+
const vcIds = [];
|
|
57
|
+
const cards = (yield registrar.fetch({
|
|
58
|
+
each: () => __awaiter(this, void 0, void 0, function* () { }),
|
|
59
|
+
controllerOptionsHandler: (vcId) => {
|
|
60
|
+
var _a;
|
|
61
|
+
vcIds.push(vcId);
|
|
62
|
+
return (_a = controllerOptionsHandler === null || controllerOptionsHandler === void 0 ? void 0 : controllerOptionsHandler(vcId)) !== null && _a !== void 0 ? _a : {};
|
|
63
|
+
},
|
|
41
64
|
target: {
|
|
42
65
|
organizationId: org.id,
|
|
43
66
|
calendarEventId: event.id,
|
|
@@ -46,7 +69,8 @@ export default class CalendarToolRegistrar {
|
|
|
46
69
|
payload: {
|
|
47
70
|
eventTypeSlug: event.eventTypeSlug,
|
|
48
71
|
},
|
|
49
|
-
});
|
|
72
|
+
}));
|
|
73
|
+
return { cards, vcIds };
|
|
50
74
|
});
|
|
51
75
|
}
|
|
52
76
|
addTool(card) {
|
|
@@ -43,6 +43,7 @@ export default class AbstractCalendarEventToolBeltState {
|
|
|
43
43
|
}
|
|
44
44
|
loadRemoteCards() {
|
|
45
45
|
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
//TODO TODAY Rewrite to only load remote tools once
|
|
46
47
|
const registrar = new CalendarToolRegistrar(this.sm, (vc) => {
|
|
47
48
|
//@ts-ignore
|
|
48
49
|
return this.addVc(vc.id, vc.getLineIcon(), vc);
|
|
@@ -13,6 +13,7 @@ export default class RemoteEventStoreImpl implements RemoteEventStore {
|
|
|
13
13
|
private queueByEventId;
|
|
14
14
|
private busyByEvent;
|
|
15
15
|
private lastSavedById;
|
|
16
|
+
private calendarEventTypes?;
|
|
16
17
|
constructor(options: RemoteEventStoreOptions);
|
|
17
18
|
load(options: {
|
|
18
19
|
organizationId: string;
|
|
@@ -34,7 +35,7 @@ export default class RemoteEventStoreImpl implements RemoteEventStore {
|
|
|
34
35
|
waitForPendingSaves(): Promise<void>;
|
|
35
36
|
cancelEvent(id: string, options: CancelEventRecurringOptions): Promise<void>;
|
|
36
37
|
getSchedules(options: GetScheduleOptions): Promise<import("@sprucelabs/schema").SchemaStaticValues<SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEventSchema, false, import("@sprucelabs/schema").SchemaOptionalFieldNames<SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEventSchema>, import("@sprucelabs/schema").StaticSchemaAllValues<SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEventSchema, false>>[]>;
|
|
37
|
-
getEventTypes(): Promise<
|
|
38
|
+
getEventTypes(): Promise<SpruceSchemas.Calendar.v2021_05_19.CalendarEventType[]>;
|
|
38
39
|
getCalendars(): Promise<import("@sprucelabs/schema").SchemaStaticValues<SpruceSchemas.Calendar.v2021_05_19.CalendarSchema, false, import("@sprucelabs/schema").SchemaOptionalFieldNames<SpruceSchemas.Calendar.v2021_05_19.CalendarSchema>, import("@sprucelabs/schema").StaticSchemaAllValues<SpruceSchemas.Calendar.v2021_05_19.CalendarSchema, false>>[]>;
|
|
39
40
|
}
|
|
40
41
|
export interface RemoteEventStoreOptions {
|
|
@@ -225,8 +225,12 @@ class RemoteEventStoreImpl {
|
|
|
225
225
|
return events;
|
|
226
226
|
}
|
|
227
227
|
async getEventTypes() {
|
|
228
|
+
if (this.calendarEventTypes) {
|
|
229
|
+
return this.calendarEventTypes;
|
|
230
|
+
}
|
|
228
231
|
const [{ calendarEventTypes }] = await this.client.emitAndFlattenResponses('calendar.list-calendar-event-types::v2021_05_19');
|
|
229
|
-
|
|
232
|
+
this.calendarEventTypes = calendarEventTypes;
|
|
233
|
+
return this.calendarEventTypes;
|
|
230
234
|
}
|
|
231
235
|
async getCalendars() {
|
|
232
236
|
const [{ calendars }] = await this.client.emitAndFlattenResponses('calendar.list-calendars::v2021_05_19', {
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { RemoteCalendarTool, CalendarToolBeltStateMachine } from '../types/calendar.types';
|
|
2
|
-
export type AddToolHandler = (vc: RemoteCalendarTool & {
|
|
3
|
-
id: string;
|
|
4
|
-
}) => Promise<void> | void;
|
|
5
2
|
export default class CalendarToolRegistrar {
|
|
6
3
|
private sm;
|
|
7
4
|
private addToolHandler?;
|
|
5
|
+
private fetchedRecord;
|
|
8
6
|
constructor(sm: CalendarToolBeltStateMachine, addToolHandler?: AddToolHandler);
|
|
9
7
|
fetchAndAddCards(controllerOptionsHandler?: (vcId: string) => Record<string, any>): Promise<void>;
|
|
8
|
+
private get views();
|
|
9
|
+
private fetchUncached;
|
|
10
10
|
private addTool;
|
|
11
11
|
}
|
|
12
|
+
export type AddToolHandler = (vc: RemoteCalendarTool & {
|
|
13
|
+
id: string;
|
|
14
|
+
}) => Promise<void> | void;
|
|
@@ -3,10 +3,31 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const spruce_heartwood_utils_1 = require("@sprucelabs/spruce-heartwood-utils");
|
|
4
4
|
class CalendarToolRegistrar {
|
|
5
5
|
constructor(sm, addToolHandler) {
|
|
6
|
+
this.fetchedRecord = {};
|
|
6
7
|
this.sm = sm;
|
|
7
8
|
this.addToolHandler = addToolHandler;
|
|
8
9
|
}
|
|
9
10
|
async fetchAndAddCards(controllerOptionsHandler) {
|
|
11
|
+
var _a;
|
|
12
|
+
const { event } = this.sm.getContext();
|
|
13
|
+
let cards = [];
|
|
14
|
+
const cacheKey = (_a = event.eventTypeSlug) !== null && _a !== void 0 ? _a : '';
|
|
15
|
+
if (!this.fetchedRecord[cacheKey]) {
|
|
16
|
+
const { cards: fetchedCards, vcIds } = await this.fetchUncached(controllerOptionsHandler);
|
|
17
|
+
this.fetchedRecord[cacheKey] = vcIds;
|
|
18
|
+
cards = fetchedCards;
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
cards = this.fetchedRecord[cacheKey].map((vcId) => this.views.Controller(vcId, {}));
|
|
22
|
+
}
|
|
23
|
+
for (const card of cards) {
|
|
24
|
+
await this.addTool(card);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
get views() {
|
|
28
|
+
return this.sm.getVcFactory();
|
|
29
|
+
}
|
|
30
|
+
async fetchUncached(controllerOptionsHandler) {
|
|
10
31
|
const { scope, event } = this.sm.getContext();
|
|
11
32
|
const [org, location] = await Promise.all([
|
|
12
33
|
scope.getCurrentOrganization(),
|
|
@@ -15,21 +36,21 @@ class CalendarToolRegistrar {
|
|
|
15
36
|
const client = await this.sm.connectToApi();
|
|
16
37
|
const registrar = new spruce_heartwood_utils_1.CardRegistrar({
|
|
17
38
|
client,
|
|
18
|
-
vcFactory: this.
|
|
39
|
+
vcFactory: this.views,
|
|
19
40
|
vcIdsTransformer: (response) => response.vcIds,
|
|
20
41
|
eventName: 'calendar.register-event-tools::v2021_05_19',
|
|
21
42
|
});
|
|
22
43
|
if (!org) {
|
|
23
44
|
throw new Error('No organization found!');
|
|
24
45
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
each: async (
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
46
|
+
const vcIds = [];
|
|
47
|
+
const cards = (await registrar.fetch({
|
|
48
|
+
each: async () => { },
|
|
49
|
+
controllerOptionsHandler: (vcId) => {
|
|
50
|
+
var _a;
|
|
51
|
+
vcIds.push(vcId);
|
|
52
|
+
return (_a = controllerOptionsHandler === null || controllerOptionsHandler === void 0 ? void 0 : controllerOptionsHandler(vcId)) !== null && _a !== void 0 ? _a : {};
|
|
31
53
|
},
|
|
32
|
-
controllerOptionsHandler,
|
|
33
54
|
target: {
|
|
34
55
|
organizationId: org.id,
|
|
35
56
|
calendarEventId: event.id,
|
|
@@ -38,7 +59,8 @@ class CalendarToolRegistrar {
|
|
|
38
59
|
payload: {
|
|
39
60
|
eventTypeSlug: event.eventTypeSlug,
|
|
40
61
|
},
|
|
41
|
-
});
|
|
62
|
+
}));
|
|
63
|
+
return { cards, vcIds };
|
|
42
64
|
}
|
|
43
65
|
async addTool(card) {
|
|
44
66
|
var _a;
|
|
@@ -36,6 +36,7 @@ class AbstractCalendarEventToolBeltState {
|
|
|
36
36
|
return this.isLoaded;
|
|
37
37
|
}
|
|
38
38
|
async loadRemoteCards() {
|
|
39
|
+
//TODO TODAY Rewrite to only load remote tools once
|
|
39
40
|
const registrar = new CalendarToolRegistrar_1.default(this.sm, (vc) => {
|
|
40
41
|
//@ts-ignore
|
|
41
42
|
return this.addVc(vc.id, vc.getLineIcon(), vc);
|