@sprucelabs/spruce-calendar-components 27.0.1 → 27.0.2
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/errors/errors.types.d.ts +19 -0
- package/build/.spruce/errors/options.types.d.ts +4 -1
- package/build/errors/SpruceError.js +3 -0
- package/build/esm/.spruce/errors/errors.types.d.ts +19 -0
- package/build/esm/.spruce/errors/options.types.d.ts +4 -1
- package/build/esm/errors/SpruceError.js +3 -0
- package/build/esm/toolBelt/states/AbstractCalendarEventToolBeltState.js +25 -6
- package/build/esm/types/calendar.types.d.ts +2 -1
- package/build/toolBelt/states/AbstractCalendarEventToolBeltState.js +25 -6
- package/build/types/calendar.types.d.ts +2 -1
- package/package.json +1 -1
|
@@ -101,6 +101,25 @@ export declare namespace SpruceErrors.Calendar {
|
|
|
101
101
|
}
|
|
102
102
|
type DuplicateCalendarEntity = SchemaEntity<SpruceErrors.Calendar.DuplicateCalendarSchema>;
|
|
103
103
|
}
|
|
104
|
+
export declare namespace SpruceErrors.Calendar {
|
|
105
|
+
interface CalendarToolInterface {
|
|
106
|
+
'vcId': string;
|
|
107
|
+
}
|
|
108
|
+
interface CalendarToolInterfaceSchema extends SpruceSchema.Schema {
|
|
109
|
+
id: 'calendarToolInterface';
|
|
110
|
+
namespace: 'Calendar';
|
|
111
|
+
name: 'Calendar tool interface';
|
|
112
|
+
fields: {
|
|
113
|
+
/** . */
|
|
114
|
+
'vcId': {
|
|
115
|
+
type: 'id';
|
|
116
|
+
isRequired: true;
|
|
117
|
+
options: undefined;
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
type CalendarToolInterfaceEntity = SchemaEntity<SpruceErrors.Calendar.CalendarToolInterfaceSchema>;
|
|
122
|
+
}
|
|
104
123
|
export declare namespace SpruceErrors.Calendar {
|
|
105
124
|
interface CalendarNotFound {
|
|
106
125
|
'calendarIds'?: string[] | undefined | null;
|
|
@@ -21,8 +21,11 @@ export interface DuplicateEventTypeErrorOptions extends SpruceErrors.Calendar.Du
|
|
|
21
21
|
export interface DuplicateCalendarErrorOptions extends SpruceErrors.Calendar.DuplicateCalendar, ISpruceErrorOptions {
|
|
22
22
|
code: 'DUPLICATE_CALENDAR';
|
|
23
23
|
}
|
|
24
|
+
export interface CalendarToolInterfaceErrorOptions extends SpruceErrors.Calendar.CalendarToolInterface, ISpruceErrorOptions {
|
|
25
|
+
code: 'CALENDAR_TOOL_INTERFACE';
|
|
26
|
+
}
|
|
24
27
|
export interface CalendarNotFoundErrorOptions extends SpruceErrors.Calendar.CalendarNotFound, ISpruceErrorOptions {
|
|
25
28
|
code: 'CALENDAR_NOT_FOUND';
|
|
26
29
|
}
|
|
27
|
-
type ErrorOptions = ValidatorNotInitializedErrorOptions | UnauthorizedAccessErrorOptions | RecordNotFoundErrorOptions | PersonNotFoundErrorOptions | EventNotFoundErrorOptions | DuplicateEventTypeErrorOptions | DuplicateCalendarErrorOptions | CalendarNotFoundErrorOptions;
|
|
30
|
+
type ErrorOptions = ValidatorNotInitializedErrorOptions | UnauthorizedAccessErrorOptions | RecordNotFoundErrorOptions | PersonNotFoundErrorOptions | EventNotFoundErrorOptions | DuplicateEventTypeErrorOptions | DuplicateCalendarErrorOptions | CalendarToolInterfaceErrorOptions | CalendarNotFoundErrorOptions;
|
|
28
31
|
export default ErrorOptions;
|
|
@@ -33,6 +33,9 @@ class SpruceError extends error_1.default {
|
|
|
33
33
|
case 'PERSON_NOT_FOUND':
|
|
34
34
|
message = `I could not find that person!!`;
|
|
35
35
|
break;
|
|
36
|
+
case 'CALENDAR_TOOL_INTERFACE':
|
|
37
|
+
message = 'A Calendar tool interface just happened!';
|
|
38
|
+
break;
|
|
36
39
|
default:
|
|
37
40
|
message = super.friendlyMessage();
|
|
38
41
|
}
|
|
@@ -101,6 +101,25 @@ export declare namespace SpruceErrors.Calendar {
|
|
|
101
101
|
}
|
|
102
102
|
type DuplicateCalendarEntity = SchemaEntity<SpruceErrors.Calendar.DuplicateCalendarSchema>;
|
|
103
103
|
}
|
|
104
|
+
export declare namespace SpruceErrors.Calendar {
|
|
105
|
+
interface CalendarToolInterface {
|
|
106
|
+
'vcId': string;
|
|
107
|
+
}
|
|
108
|
+
interface CalendarToolInterfaceSchema extends SpruceSchema.Schema {
|
|
109
|
+
id: 'calendarToolInterface';
|
|
110
|
+
namespace: 'Calendar';
|
|
111
|
+
name: 'Calendar tool interface';
|
|
112
|
+
fields: {
|
|
113
|
+
/** . */
|
|
114
|
+
'vcId': {
|
|
115
|
+
type: 'id';
|
|
116
|
+
isRequired: true;
|
|
117
|
+
options: undefined;
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
type CalendarToolInterfaceEntity = SchemaEntity<SpruceErrors.Calendar.CalendarToolInterfaceSchema>;
|
|
122
|
+
}
|
|
104
123
|
export declare namespace SpruceErrors.Calendar {
|
|
105
124
|
interface CalendarNotFound {
|
|
106
125
|
'calendarIds'?: string[] | undefined | null;
|
|
@@ -21,8 +21,11 @@ export interface DuplicateEventTypeErrorOptions extends SpruceErrors.Calendar.Du
|
|
|
21
21
|
export interface DuplicateCalendarErrorOptions extends SpruceErrors.Calendar.DuplicateCalendar, ISpruceErrorOptions {
|
|
22
22
|
code: 'DUPLICATE_CALENDAR';
|
|
23
23
|
}
|
|
24
|
+
export interface CalendarToolInterfaceErrorOptions extends SpruceErrors.Calendar.CalendarToolInterface, ISpruceErrorOptions {
|
|
25
|
+
code: 'CALENDAR_TOOL_INTERFACE';
|
|
26
|
+
}
|
|
24
27
|
export interface CalendarNotFoundErrorOptions extends SpruceErrors.Calendar.CalendarNotFound, ISpruceErrorOptions {
|
|
25
28
|
code: 'CALENDAR_NOT_FOUND';
|
|
26
29
|
}
|
|
27
|
-
type ErrorOptions = ValidatorNotInitializedErrorOptions | UnauthorizedAccessErrorOptions | RecordNotFoundErrorOptions | PersonNotFoundErrorOptions | EventNotFoundErrorOptions | DuplicateEventTypeErrorOptions | DuplicateCalendarErrorOptions | CalendarNotFoundErrorOptions;
|
|
30
|
+
type ErrorOptions = ValidatorNotInitializedErrorOptions | UnauthorizedAccessErrorOptions | RecordNotFoundErrorOptions | PersonNotFoundErrorOptions | EventNotFoundErrorOptions | DuplicateEventTypeErrorOptions | DuplicateCalendarErrorOptions | CalendarToolInterfaceErrorOptions | CalendarNotFoundErrorOptions;
|
|
28
31
|
export default ErrorOptions;
|
|
@@ -28,6 +28,9 @@ export default class SpruceError extends AbstractSpruceError {
|
|
|
28
28
|
case 'PERSON_NOT_FOUND':
|
|
29
29
|
message = `I could not find that person!!`;
|
|
30
30
|
break;
|
|
31
|
+
case 'CALENDAR_TOOL_INTERFACE':
|
|
32
|
+
message = 'A Calendar tool interface just happened!';
|
|
33
|
+
break;
|
|
31
34
|
default:
|
|
32
35
|
message = super.friendlyMessage();
|
|
33
36
|
}
|
|
@@ -9,6 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { assertOptions } from '@sprucelabs/schema';
|
|
11
11
|
import compare from 'just-compare';
|
|
12
|
+
import SpruceError from '../../errors/SpruceError.js';
|
|
12
13
|
import CalendarToolRegistrar from '../CalendarToolRegistrar.js';
|
|
13
14
|
export default class AbstractCalendarEventToolBeltState {
|
|
14
15
|
constructor() {
|
|
@@ -115,15 +116,27 @@ export default class AbstractCalendarEventToolBeltState {
|
|
|
115
116
|
});
|
|
116
117
|
}
|
|
117
118
|
addTool(options) {
|
|
119
|
+
var _a;
|
|
118
120
|
return __awaiter(this, void 0, void 0, function* () {
|
|
119
121
|
assertOptions(options, ['id', 'lineIcon', 'cardVcId']);
|
|
120
122
|
if (!this.sm) {
|
|
121
123
|
throw new Error("You can't add a tool until after load. Make sure you're calling 'await super.load()' inside your 'load()'.");
|
|
122
124
|
}
|
|
123
125
|
const { cardVcId, lineIcon, id } = options;
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
126
|
+
try {
|
|
127
|
+
const vc = this.sm.Controller(cardVcId, this.buildVcConstructorOptions(id));
|
|
128
|
+
yield this.addVc(id, lineIcon, vc);
|
|
129
|
+
return vc;
|
|
130
|
+
}
|
|
131
|
+
catch (err) {
|
|
132
|
+
if (((_a = err.options) === null || _a === void 0 ? void 0 : _a.code) === 'CALENDAR_TOOL_INTERFACE') {
|
|
133
|
+
throw err;
|
|
134
|
+
}
|
|
135
|
+
console.error(err);
|
|
136
|
+
const vc = this.sm.Controller('calendar.error-tool', {});
|
|
137
|
+
vc.setCriticalError(err);
|
|
138
|
+
return vc;
|
|
139
|
+
}
|
|
127
140
|
});
|
|
128
141
|
}
|
|
129
142
|
buildVcConstructorOptions(id) {
|
|
@@ -138,7 +151,8 @@ export default class AbstractCalendarEventToolBeltState {
|
|
|
138
151
|
return __awaiter(this, void 0, void 0, function* () {
|
|
139
152
|
this.vcs.push({ vc, toolId });
|
|
140
153
|
if (typeof vc.handleUpdateContext !== 'function') {
|
|
141
|
-
|
|
154
|
+
//@ts-ignore
|
|
155
|
+
throw new SpruceError({ code: 'CALENDAR_TOOL_INTERFACE', vcId: vc.id });
|
|
142
156
|
}
|
|
143
157
|
this.toolBeltVc.addTool({
|
|
144
158
|
id: toolId,
|
|
@@ -151,9 +165,14 @@ export default class AbstractCalendarEventToolBeltState {
|
|
|
151
165
|
});
|
|
152
166
|
}
|
|
153
167
|
loadVc(vc) {
|
|
154
|
-
var _a;
|
|
168
|
+
var _a, _b;
|
|
155
169
|
return __awaiter(this, void 0, void 0, function* () {
|
|
156
|
-
|
|
170
|
+
try {
|
|
171
|
+
yield ((_a = vc.load) === null || _a === void 0 ? void 0 : _a.call(vc));
|
|
172
|
+
}
|
|
173
|
+
catch (err) {
|
|
174
|
+
(_b = vc.setCriticalError) === null || _b === void 0 ? void 0 : _b.call(vc, err);
|
|
175
|
+
}
|
|
157
176
|
});
|
|
158
177
|
}
|
|
159
178
|
loadTools() {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AbstractViewController, LineIcon, SkillViewControllerLoadOptions, ToolBeltState, ToolBeltStateMachine } from '@sprucelabs/heartwood-view-controllers';
|
|
1
|
+
import { AbstractViewController, CriticalError, LineIcon, SkillViewControllerLoadOptions, ToolBeltState, ToolBeltStateMachine } from '@sprucelabs/heartwood-view-controllers';
|
|
2
2
|
import { SpruceSchemas } from '@sprucelabs/mercury-types';
|
|
3
3
|
import { EventTarget } from '@sprucelabs/spruce-event-utils';
|
|
4
4
|
import CalendarViewController from '../calendar/Calendar.vc';
|
|
@@ -46,6 +46,7 @@ export interface CalendarTool extends AbstractViewController<Card> {
|
|
|
46
46
|
shouldPersistContextChangesImmediately?: boolean;
|
|
47
47
|
handleUpdateContext(context: CalendarToolBeltContext): Promise<void> | void;
|
|
48
48
|
load?: () => Promise<void> | void;
|
|
49
|
+
setCriticalError?: (criticalError: CriticalError) => void;
|
|
49
50
|
}
|
|
50
51
|
export interface UpdateCalendarContextOptions {
|
|
51
52
|
shouldPersistContextChangesImmediately?: boolean;
|
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const schema_1 = require("@sprucelabs/schema");
|
|
7
7
|
const just_compare_1 = __importDefault(require("just-compare"));
|
|
8
|
+
const SpruceError_1 = __importDefault(require("../../errors/SpruceError"));
|
|
8
9
|
const CalendarToolRegistrar_1 = __importDefault(require("../CalendarToolRegistrar"));
|
|
9
10
|
class AbstractCalendarEventToolBeltState {
|
|
10
11
|
constructor() {
|
|
@@ -95,14 +96,26 @@ class AbstractCalendarEventToolBeltState {
|
|
|
95
96
|
}
|
|
96
97
|
}
|
|
97
98
|
async addTool(options) {
|
|
99
|
+
var _a;
|
|
98
100
|
(0, schema_1.assertOptions)(options, ['id', 'lineIcon', 'cardVcId']);
|
|
99
101
|
if (!this.sm) {
|
|
100
102
|
throw new Error("You can't add a tool until after load. Make sure you're calling 'await super.load()' inside your 'load()'.");
|
|
101
103
|
}
|
|
102
104
|
const { cardVcId, lineIcon, id } = options;
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
105
|
+
try {
|
|
106
|
+
const vc = this.sm.Controller(cardVcId, this.buildVcConstructorOptions(id));
|
|
107
|
+
await this.addVc(id, lineIcon, vc);
|
|
108
|
+
return vc;
|
|
109
|
+
}
|
|
110
|
+
catch (err) {
|
|
111
|
+
if (((_a = err.options) === null || _a === void 0 ? void 0 : _a.code) === 'CALENDAR_TOOL_INTERFACE') {
|
|
112
|
+
throw err;
|
|
113
|
+
}
|
|
114
|
+
console.error(err);
|
|
115
|
+
const vc = this.sm.Controller('calendar.error-tool', {});
|
|
116
|
+
vc.setCriticalError(err);
|
|
117
|
+
return vc;
|
|
118
|
+
}
|
|
106
119
|
}
|
|
107
120
|
buildVcConstructorOptions(id) {
|
|
108
121
|
return {
|
|
@@ -115,7 +128,8 @@ class AbstractCalendarEventToolBeltState {
|
|
|
115
128
|
async addVc(toolId, lineIcon, vc) {
|
|
116
129
|
this.vcs.push({ vc, toolId });
|
|
117
130
|
if (typeof vc.handleUpdateContext !== 'function') {
|
|
118
|
-
|
|
131
|
+
//@ts-ignore
|
|
132
|
+
throw new SpruceError_1.default({ code: 'CALENDAR_TOOL_INTERFACE', vcId: vc.id });
|
|
119
133
|
}
|
|
120
134
|
this.toolBeltVc.addTool({
|
|
121
135
|
id: toolId,
|
|
@@ -127,8 +141,13 @@ class AbstractCalendarEventToolBeltState {
|
|
|
127
141
|
}
|
|
128
142
|
}
|
|
129
143
|
async loadVc(vc) {
|
|
130
|
-
var _a;
|
|
131
|
-
|
|
144
|
+
var _a, _b;
|
|
145
|
+
try {
|
|
146
|
+
await ((_a = vc.load) === null || _a === void 0 ? void 0 : _a.call(vc));
|
|
147
|
+
}
|
|
148
|
+
catch (err) {
|
|
149
|
+
(_b = vc.setCriticalError) === null || _b === void 0 ? void 0 : _b.call(vc, err);
|
|
150
|
+
}
|
|
132
151
|
}
|
|
133
152
|
async loadTools() {
|
|
134
153
|
await Promise.all(this.vcs.map(({ vc }) => this.loadVc(vc)));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AbstractViewController, LineIcon, SkillViewControllerLoadOptions, ToolBeltState, ToolBeltStateMachine } from '@sprucelabs/heartwood-view-controllers';
|
|
1
|
+
import { AbstractViewController, CriticalError, LineIcon, SkillViewControllerLoadOptions, ToolBeltState, ToolBeltStateMachine } from '@sprucelabs/heartwood-view-controllers';
|
|
2
2
|
import { SpruceSchemas } from '@sprucelabs/mercury-types';
|
|
3
3
|
import { EventTarget } from '@sprucelabs/spruce-event-utils';
|
|
4
4
|
import CalendarViewController from '../calendar/Calendar.vc';
|
|
@@ -46,6 +46,7 @@ export interface CalendarTool extends AbstractViewController<Card> {
|
|
|
46
46
|
shouldPersistContextChangesImmediately?: boolean;
|
|
47
47
|
handleUpdateContext(context: CalendarToolBeltContext): Promise<void> | void;
|
|
48
48
|
load?: () => Promise<void> | void;
|
|
49
|
+
setCriticalError?: (criticalError: CriticalError) => void;
|
|
49
50
|
}
|
|
50
51
|
export interface UpdateCalendarContextOptions {
|
|
51
52
|
shouldPersistContextChangesImmediately?: boolean;
|