@sprucelabs/heartwood-view-controllers 111.1.32 → 111.1.34
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 +20 -0
- package/build/.spruce/errors/heartwoodViewControllers/invalidAppController.schema.d.ts +3 -0
- package/build/.spruce/errors/heartwoodViewControllers/invalidAppController.schema.js +19 -0
- package/build/.spruce/errors/options.types.d.ts +4 -1
- package/build/errors/SpruceError.js +3 -0
- package/build/errors/invalidAppController.builder.d.ts +11 -0
- package/build/errors/invalidAppController.builder.js +13 -0
- package/build/esm/.spruce/errors/errors.types.d.ts +20 -0
- package/build/esm/.spruce/errors/options.types.d.ts +4 -1
- package/build/esm/errors/SpruceError.js +3 -0
- package/build/esm/errors/invalidAppController.builder.d.ts +11 -0
- package/build/esm/errors/invalidAppController.builder.js +11 -0
- package/build/esm/index.d.ts +1 -1
- package/build/esm/index.js +1 -1
- package/build/esm/tests/utilities/navigationAssert.d.ts +4 -2
- package/build/esm/tests/utilities/navigationAssert.js +10 -2
- package/build/esm/types/heartwood.types.d.ts +10 -4
- package/build/esm/viewControllers/Abstract.ac.d.ts +9 -0
- package/build/esm/viewControllers/Abstract.ac.js +22 -0
- package/build/esm/viewControllers/ViewControllerFactory.d.ts +8 -4
- package/build/esm/viewControllers/ViewControllerFactory.js +14 -2
- package/build/esm/viewControllers/ViewControllerImporter.d.ts +2 -2
- package/build/index.d.ts +1 -1
- package/build/index.js +3 -3
- package/build/tests/utilities/navigationAssert.d.ts +4 -2
- package/build/tests/utilities/navigationAssert.js +10 -2
- package/build/types/heartwood.types.d.ts +10 -4
- package/build/viewControllers/Abstract.ac.d.ts +9 -0
- package/build/viewControllers/Abstract.ac.js +14 -0
- package/build/viewControllers/ViewControllerFactory.d.ts +8 -4
- package/build/viewControllers/ViewControllerFactory.js +14 -2
- package/build/viewControllers/ViewControllerImporter.d.ts +2 -2
- package/package.json +1 -1
- package/build/esm/viewControllers/Abstract.avc.d.ts +0 -5
- package/build/esm/viewControllers/Abstract.avc.js +0 -3
- package/build/viewControllers/Abstract.avc.d.ts +0 -5
- package/build/viewControllers/Abstract.avc.js +0 -6
|
@@ -215,6 +215,26 @@ export declare namespace SpruceErrors.HeartwoodViewControllers {
|
|
|
215
215
|
}
|
|
216
216
|
type InvalidSkillViewControllerEntity = SchemaEntity<SpruceErrors.HeartwoodViewControllers.InvalidSkillViewControllerSchema>;
|
|
217
217
|
}
|
|
218
|
+
export declare namespace SpruceErrors.HeartwoodViewControllers {
|
|
219
|
+
interface InvalidAppController {
|
|
220
|
+
'id': string;
|
|
221
|
+
}
|
|
222
|
+
interface InvalidAppControllerSchema extends SpruceSchema.Schema {
|
|
223
|
+
id: 'invalidAppController';
|
|
224
|
+
namespace: 'HeartwoodViewControllers';
|
|
225
|
+
name: 'Invalid app controller';
|
|
226
|
+
moduleToImportFromWhenRemote: '@sprucelabs/heartwood-view-controllers';
|
|
227
|
+
fields: {
|
|
228
|
+
/** . */
|
|
229
|
+
'id': {
|
|
230
|
+
type: 'id';
|
|
231
|
+
isRequired: true;
|
|
232
|
+
options: undefined;
|
|
233
|
+
};
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
type InvalidAppControllerEntity = SchemaEntity<SpruceErrors.HeartwoodViewControllers.InvalidAppControllerSchema>;
|
|
237
|
+
}
|
|
218
238
|
export declare namespace SpruceErrors.HeartwoodViewControllers {
|
|
219
239
|
interface ExportFailed {
|
|
220
240
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const schema_1 = require("@sprucelabs/schema");
|
|
4
|
+
const invalidAppControllerSchema = {
|
|
5
|
+
id: 'invalidAppController',
|
|
6
|
+
namespace: 'HeartwoodViewControllers',
|
|
7
|
+
name: 'Invalid app controller',
|
|
8
|
+
moduleToImportFromWhenRemote: '@sprucelabs/heartwood-view-controllers',
|
|
9
|
+
fields: {
|
|
10
|
+
/** . */
|
|
11
|
+
'id': {
|
|
12
|
+
type: 'id',
|
|
13
|
+
isRequired: true,
|
|
14
|
+
options: undefined
|
|
15
|
+
},
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
schema_1.SchemaRegistry.getInstance().trackSchema(invalidAppControllerSchema);
|
|
19
|
+
exports.default = invalidAppControllerSchema;
|
|
@@ -33,6 +33,9 @@ export interface InvalidViewControllerNameErrorOptions extends SpruceErrors.Hear
|
|
|
33
33
|
export interface InvalidSkillViewControllerErrorOptions extends SpruceErrors.HeartwoodViewControllers.InvalidSkillViewController, ISpruceErrorOptions {
|
|
34
34
|
code: 'INVALID_SKILL_VIEW_CONTROLLER';
|
|
35
35
|
}
|
|
36
|
+
export interface InvalidAppControllerErrorOptions extends SpruceErrors.HeartwoodViewControllers.InvalidAppController, ISpruceErrorOptions {
|
|
37
|
+
code: 'INVALID_APP_CONTROLLER';
|
|
38
|
+
}
|
|
36
39
|
export interface ExportFailedErrorOptions extends SpruceErrors.HeartwoodViewControllers.ExportFailed, ISpruceErrorOptions {
|
|
37
40
|
code: 'EXPORT_FAILED';
|
|
38
41
|
}
|
|
@@ -60,5 +63,5 @@ export interface CellDeletedErrorOptions extends SpruceErrors.HeartwoodViewContr
|
|
|
60
63
|
export interface AppNotFoundErrorOptions extends SpruceErrors.HeartwoodViewControllers.AppNotFound, ISpruceErrorOptions {
|
|
61
64
|
code: 'APP_NOT_FOUND';
|
|
62
65
|
}
|
|
63
|
-
type ErrorOptions = ViewAlreadyDestroyedErrorOptions | ToolNotFoundErrorOptions | StepNotCompleteErrorOptions | SlideNotFoundErrorOptions | RowDeletedErrorOptions | PersonNotFoundErrorOptions | NoFieldVcSetErrorOptions | MissingStorageErrorOptions | InvalidViewControllerSourceErrorOptions | InvalidViewControllerNameErrorOptions | InvalidSkillViewControllerErrorOptions | ExportFailedErrorOptions | EventNotFoundErrorOptions | DuplicateToolIdErrorOptions | DuplicateRowIdErrorOptions | DuplicateEventIdErrorOptions | DateNotSelectedErrorOptions | DateAlreadySelectedErrorOptions | CellDeletedErrorOptions | AppNotFoundErrorOptions;
|
|
66
|
+
type ErrorOptions = ViewAlreadyDestroyedErrorOptions | ToolNotFoundErrorOptions | StepNotCompleteErrorOptions | SlideNotFoundErrorOptions | RowDeletedErrorOptions | PersonNotFoundErrorOptions | NoFieldVcSetErrorOptions | MissingStorageErrorOptions | InvalidViewControllerSourceErrorOptions | InvalidViewControllerNameErrorOptions | InvalidSkillViewControllerErrorOptions | InvalidAppControllerErrorOptions | ExportFailedErrorOptions | EventNotFoundErrorOptions | DuplicateToolIdErrorOptions | DuplicateRowIdErrorOptions | DuplicateEventIdErrorOptions | DateNotSelectedErrorOptions | DateAlreadySelectedErrorOptions | CellDeletedErrorOptions | AppNotFoundErrorOptions;
|
|
64
67
|
export default ErrorOptions;
|
|
@@ -77,6 +77,9 @@ class SpruceError extends error_1.default {
|
|
|
77
77
|
case 'APP_NOT_FOUND':
|
|
78
78
|
message = `I could not find an App with the namespace '${options.namespace}'!`;
|
|
79
79
|
break;
|
|
80
|
+
case 'INVALID_APP_CONTROLLER':
|
|
81
|
+
message = 'A Invalid app controller just happened!';
|
|
82
|
+
break;
|
|
80
83
|
default:
|
|
81
84
|
message = super.friendlyMessage();
|
|
82
85
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const schema_1 = require("@sprucelabs/schema");
|
|
4
|
+
exports.default = (0, schema_1.buildErrorSchema)({
|
|
5
|
+
id: 'invalidAppController',
|
|
6
|
+
name: 'Invalid app controller',
|
|
7
|
+
fields: {
|
|
8
|
+
id: {
|
|
9
|
+
type: 'id',
|
|
10
|
+
isRequired: true,
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
});
|
|
@@ -215,6 +215,26 @@ export declare namespace SpruceErrors.HeartwoodViewControllers {
|
|
|
215
215
|
}
|
|
216
216
|
type InvalidSkillViewControllerEntity = SchemaEntity<SpruceErrors.HeartwoodViewControllers.InvalidSkillViewControllerSchema>;
|
|
217
217
|
}
|
|
218
|
+
export declare namespace SpruceErrors.HeartwoodViewControllers {
|
|
219
|
+
interface InvalidAppController {
|
|
220
|
+
'id': string;
|
|
221
|
+
}
|
|
222
|
+
interface InvalidAppControllerSchema extends SpruceSchema.Schema {
|
|
223
|
+
id: 'invalidAppController';
|
|
224
|
+
namespace: 'HeartwoodViewControllers';
|
|
225
|
+
name: 'Invalid app controller';
|
|
226
|
+
moduleToImportFromWhenRemote: '@sprucelabs/heartwood-view-controllers';
|
|
227
|
+
fields: {
|
|
228
|
+
/** . */
|
|
229
|
+
'id': {
|
|
230
|
+
type: 'id';
|
|
231
|
+
isRequired: true;
|
|
232
|
+
options: undefined;
|
|
233
|
+
};
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
type InvalidAppControllerEntity = SchemaEntity<SpruceErrors.HeartwoodViewControllers.InvalidAppControllerSchema>;
|
|
237
|
+
}
|
|
218
238
|
export declare namespace SpruceErrors.HeartwoodViewControllers {
|
|
219
239
|
interface ExportFailed {
|
|
220
240
|
}
|
|
@@ -33,6 +33,9 @@ export interface InvalidViewControllerNameErrorOptions extends SpruceErrors.Hear
|
|
|
33
33
|
export interface InvalidSkillViewControllerErrorOptions extends SpruceErrors.HeartwoodViewControllers.InvalidSkillViewController, ISpruceErrorOptions {
|
|
34
34
|
code: 'INVALID_SKILL_VIEW_CONTROLLER';
|
|
35
35
|
}
|
|
36
|
+
export interface InvalidAppControllerErrorOptions extends SpruceErrors.HeartwoodViewControllers.InvalidAppController, ISpruceErrorOptions {
|
|
37
|
+
code: 'INVALID_APP_CONTROLLER';
|
|
38
|
+
}
|
|
36
39
|
export interface ExportFailedErrorOptions extends SpruceErrors.HeartwoodViewControllers.ExportFailed, ISpruceErrorOptions {
|
|
37
40
|
code: 'EXPORT_FAILED';
|
|
38
41
|
}
|
|
@@ -60,5 +63,5 @@ export interface CellDeletedErrorOptions extends SpruceErrors.HeartwoodViewContr
|
|
|
60
63
|
export interface AppNotFoundErrorOptions extends SpruceErrors.HeartwoodViewControllers.AppNotFound, ISpruceErrorOptions {
|
|
61
64
|
code: 'APP_NOT_FOUND';
|
|
62
65
|
}
|
|
63
|
-
type ErrorOptions = ViewAlreadyDestroyedErrorOptions | ToolNotFoundErrorOptions | StepNotCompleteErrorOptions | SlideNotFoundErrorOptions | RowDeletedErrorOptions | PersonNotFoundErrorOptions | NoFieldVcSetErrorOptions | MissingStorageErrorOptions | InvalidViewControllerSourceErrorOptions | InvalidViewControllerNameErrorOptions | InvalidSkillViewControllerErrorOptions | ExportFailedErrorOptions | EventNotFoundErrorOptions | DuplicateToolIdErrorOptions | DuplicateRowIdErrorOptions | DuplicateEventIdErrorOptions | DateNotSelectedErrorOptions | DateAlreadySelectedErrorOptions | CellDeletedErrorOptions | AppNotFoundErrorOptions;
|
|
66
|
+
type ErrorOptions = ViewAlreadyDestroyedErrorOptions | ToolNotFoundErrorOptions | StepNotCompleteErrorOptions | SlideNotFoundErrorOptions | RowDeletedErrorOptions | PersonNotFoundErrorOptions | NoFieldVcSetErrorOptions | MissingStorageErrorOptions | InvalidViewControllerSourceErrorOptions | InvalidViewControllerNameErrorOptions | InvalidSkillViewControllerErrorOptions | InvalidAppControllerErrorOptions | ExportFailedErrorOptions | EventNotFoundErrorOptions | DuplicateToolIdErrorOptions | DuplicateRowIdErrorOptions | DuplicateEventIdErrorOptions | DateNotSelectedErrorOptions | DateAlreadySelectedErrorOptions | CellDeletedErrorOptions | AppNotFoundErrorOptions;
|
|
64
67
|
export default ErrorOptions;
|
|
@@ -73,6 +73,9 @@ export default class SpruceError extends AbstractSpruceError {
|
|
|
73
73
|
case 'APP_NOT_FOUND':
|
|
74
74
|
message = `I could not find an App with the namespace '${options.namespace}'!`;
|
|
75
75
|
break;
|
|
76
|
+
case 'INVALID_APP_CONTROLLER':
|
|
77
|
+
message = 'A Invalid app controller just happened!';
|
|
78
|
+
break;
|
|
76
79
|
default:
|
|
77
80
|
message = super.friendlyMessage();
|
|
78
81
|
}
|
package/build/esm/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export * from './utilities/removeUniversalViewOptions';
|
|
|
4
4
|
export * from './.spruce/schemas/schemas.types';
|
|
5
5
|
export { default as AbstractSkillViewController } from './skillViewControllers/Abstract.svc';
|
|
6
6
|
export { default as AbstractViewController } from './viewControllers/Abstract.vc';
|
|
7
|
-
export { default as
|
|
7
|
+
export { default as AbstractAppController } from './viewControllers/Abstract.ac';
|
|
8
8
|
export * from './viewControllers/BigForm.vc';
|
|
9
9
|
export { default as ButtonGroupViewController } from './viewControllers/ButtonGroup.vc';
|
|
10
10
|
export * from './viewControllers/ButtonGroup.vc';
|
package/build/esm/index.js
CHANGED
|
@@ -4,7 +4,7 @@ export * from './utilities/removeUniversalViewOptions.js';
|
|
|
4
4
|
export * from './.spruce/schemas/schemas.types.js';
|
|
5
5
|
export { default as AbstractSkillViewController } from './skillViewControllers/Abstract.svc.js';
|
|
6
6
|
export { default as AbstractViewController } from './viewControllers/Abstract.vc.js';
|
|
7
|
-
export { default as
|
|
7
|
+
export { default as AbstractAppController } from './viewControllers/Abstract.ac.js';
|
|
8
8
|
export * from './viewControllers/BigForm.vc.js';
|
|
9
9
|
export { default as ButtonGroupViewController } from './viewControllers/ButtonGroup.vc.js';
|
|
10
10
|
export * from './viewControllers/ButtonGroup.vc.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PermissionContractId } from '@sprucelabs/mercury-types';
|
|
2
|
-
import { Navigation, SkillViewController, SkillViewControllerId, ViewController } from '../../types/heartwood.types';
|
|
2
|
+
import { AppController, Navigation, SkillViewController, SkillViewControllerId, ViewController } from '../../types/heartwood.types';
|
|
3
3
|
declare const navigationAssert: {
|
|
4
4
|
rendersButton(vc: ViewController<Navigation>, id: string): void;
|
|
5
5
|
buttonRedirectsTo(options: {
|
|
@@ -12,7 +12,9 @@ declare const navigationAssert: {
|
|
|
12
12
|
}): void;
|
|
13
13
|
rendersButtons(vc: ViewController<Navigation>, ids: string[]): void;
|
|
14
14
|
rendersButtonLabels(vc: ViewController<Navigation>): void;
|
|
15
|
-
skillViewRendersNavigation(vc: Pick<SkillViewController, "renderNavigation"
|
|
15
|
+
skillViewRendersNavigation(vc: Pick<SkillViewController, "renderNavigation">, msg?: string): ViewController<import("@sprucelabs/mercury-types").SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Navigation>;
|
|
16
|
+
appRendersNavigation(vc: Pick<AppController, "renderNavigation">): ViewController<import("@sprucelabs/mercury-types").SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Navigation>;
|
|
17
|
+
appDoesNotRenderNavigation(vc: Pick<AppController, "renderNavigation">): void;
|
|
16
18
|
skillViewDoesNotRenderNavigation(vc: Pick<SkillViewController, "renderNavigation">): void;
|
|
17
19
|
buttonRequiresViewPermissions(vc: ViewController<Navigation>, button: string, permissionContractId: PermissionContractId): void;
|
|
18
20
|
};
|
|
@@ -22,12 +22,20 @@ const navigationAssert = {
|
|
|
22
22
|
const model = renderUtil.render(vc);
|
|
23
23
|
assert.isTrue(model.shouldRenderButtonLabels, `Your navigation should render button labels but it is not! Try shouldRenderButtonLabels: true`);
|
|
24
24
|
},
|
|
25
|
-
skillViewRendersNavigation(vc) {
|
|
25
|
+
skillViewRendersNavigation(vc, msg) {
|
|
26
26
|
var _a;
|
|
27
27
|
const nav = (_a = vc.renderNavigation) === null || _a === void 0 ? void 0 : _a.call(vc);
|
|
28
|
-
assert.isTruthy(nav, `Your skill view did not render a navigation! Implement renderNavigation() and use this.Controller('navigation', {}) to render one.`);
|
|
28
|
+
assert.isTruthy(nav, msg !== null && msg !== void 0 ? msg : `Your skill view did not render a navigation! Implement renderNavigation() and use this.Controller('navigation', {}) to render one.`);
|
|
29
29
|
return nav.controller;
|
|
30
30
|
},
|
|
31
|
+
appRendersNavigation(vc) {
|
|
32
|
+
return this.skillViewRendersNavigation(vc, `Your AppController did not render a navigation! Implement renderNavigation() and use this.Controller('navigation', {}) to render one.`);
|
|
33
|
+
},
|
|
34
|
+
appDoesNotRenderNavigation(vc) {
|
|
35
|
+
var _a;
|
|
36
|
+
const nav = (_a = vc.renderNavigation) === null || _a === void 0 ? void 0 : _a.call(vc);
|
|
37
|
+
assert.isNull(nav, `Your AppController should not render a navigation! Implement renderNavigation() and return null.`);
|
|
38
|
+
},
|
|
31
39
|
skillViewDoesNotRenderNavigation(vc) {
|
|
32
40
|
var _a;
|
|
33
41
|
const nav = (_a = vc.renderNavigation) === null || _a === void 0 ? void 0 : _a.call(vc);
|
|
@@ -210,6 +210,7 @@ export type ImportedViewController = (new (options: ViewControllerOptions) => Vi
|
|
|
210
210
|
};
|
|
211
211
|
export type ViewControllerId = keyof ViewControllerMap;
|
|
212
212
|
export type SkillViewControllerId = keyof SkillViewControllerMap;
|
|
213
|
+
export type AppControllerId = keyof AppControllerMap;
|
|
213
214
|
export interface RedirectOptions {
|
|
214
215
|
shouldTrackHistory?: boolean;
|
|
215
216
|
}
|
|
@@ -349,6 +350,8 @@ export interface SkillViewControllerMap {
|
|
|
349
350
|
}
|
|
350
351
|
export interface SkillViewControllerArgsMap {
|
|
351
352
|
}
|
|
353
|
+
export interface AppControllerMap {
|
|
354
|
+
}
|
|
352
355
|
export type ControllerOptions<N extends ViewControllerId, O extends ViewControllerOptionsMap = ViewControllerOptionsMap> = Omit<N extends keyof O ? O[N] : Record<string, never>, UniversalViewOptionFields>;
|
|
353
356
|
export type MapUtil = typeof mapUtil;
|
|
354
357
|
export interface OpenNavigationOptions {
|
|
@@ -511,15 +514,18 @@ export interface ActiveRecordSearchOptions {
|
|
|
511
514
|
shouldSearchClientSide?: boolean;
|
|
512
515
|
placeholder?: string;
|
|
513
516
|
}
|
|
514
|
-
export interface
|
|
517
|
+
export interface AppController {
|
|
515
518
|
renderNavigation?(): Navigation | null | undefined;
|
|
516
519
|
renderToolBelt?(): ToolBelt | null | undefined;
|
|
517
|
-
load
|
|
520
|
+
load(options: AppControllerLoadOptions): Promise<void>;
|
|
518
521
|
}
|
|
519
|
-
export type
|
|
522
|
+
export type BuiltAppController = AppController & {
|
|
523
|
+
id: string;
|
|
524
|
+
};
|
|
525
|
+
export type AppControllerConstructor = (new (options: ViewControllerOptions) => AppController) & {
|
|
520
526
|
id: string;
|
|
521
527
|
};
|
|
522
|
-
export interface
|
|
528
|
+
export interface AppControllerLoadOptions {
|
|
523
529
|
router: Router;
|
|
524
530
|
authenticator: Authenticator;
|
|
525
531
|
authorizer: Authorizer;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AppController, AppControllerLoadOptions, ControllerOptions, ViewControllerId, ViewControllerMap, ViewControllerOptions, ViewControllerPlugins } from '../types/heartwood.types';
|
|
2
|
+
export default abstract class AbstractAppController implements AppController {
|
|
3
|
+
static id: string;
|
|
4
|
+
protected plugins: ViewControllerPlugins;
|
|
5
|
+
private views;
|
|
6
|
+
constructor(options: ViewControllerOptions);
|
|
7
|
+
load(options: AppControllerLoadOptions): Promise<void>;
|
|
8
|
+
Controller<N extends ViewControllerId, O extends ControllerOptions<N>>(id: N, options: O): ViewControllerMap[N];
|
|
9
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
export default class AbstractAppController {
|
|
11
|
+
constructor(options) {
|
|
12
|
+
const { plugins, vcFactory } = options;
|
|
13
|
+
this.plugins = plugins;
|
|
14
|
+
this.views = vcFactory;
|
|
15
|
+
}
|
|
16
|
+
load(options) {
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () { });
|
|
18
|
+
}
|
|
19
|
+
Controller(id, options) {
|
|
20
|
+
return this.views.Controller(id, options);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DateUtil } from '@sprucelabs/calendar-utils';
|
|
2
2
|
import { Log } from '@sprucelabs/spruce-skill-utils';
|
|
3
|
-
import { ConfirmHandler, ControllerOptions, ImportedViewController, RenderInDialogHandler, ViewController, ViewControllerMap, ViewControllerId, VoteHandler, Device, MapUtil, ViewControllerConstructor, ToastHandler, ViewControllerPlugins, ViewControllerPluginsByName, ConnectToApi, ViewControllerPlugin, ViewControllerPluginOptions, ViewControllerOptions,
|
|
3
|
+
import { ConfirmHandler, ControllerOptions, ImportedViewController, RenderInDialogHandler, ViewController, ViewControllerMap, ViewControllerId, VoteHandler, Device, MapUtil, ViewControllerConstructor, ToastHandler, ViewControllerPlugins, ViewControllerPluginsByName, ConnectToApi, ViewControllerPlugin, ViewControllerPluginOptions, ViewControllerOptions, AppController, AppControllerConstructor, AppControllerId, AppControllerMap } from '../types/heartwood.types';
|
|
4
4
|
export default class ViewControllerFactory {
|
|
5
5
|
static Class?: typeof ViewControllerFactory;
|
|
6
6
|
private controllerMap;
|
|
@@ -22,16 +22,20 @@ export default class ViewControllerFactory {
|
|
|
22
22
|
static Factory(options: ViewControllerFactoryOptions): ViewControllerFactory;
|
|
23
23
|
setController<Vc extends ViewController<any>>(name: string, Class: ViewControllerConstructor<Vc>): void;
|
|
24
24
|
mixinControllers(map: Record<string, ViewControllerConstructor<ViewController<any>>>): void;
|
|
25
|
-
importControllers<Vc extends ImportedViewController>(Vcs: Vc[], plugins?: ViewControllerPluginsByName, App?:
|
|
25
|
+
importControllers<Vc extends ImportedViewController>(Vcs: Vc[], plugins?: ViewControllerPluginsByName, App?: AppControllerConstructor): void;
|
|
26
26
|
private importPlugins;
|
|
27
27
|
BuildPlugin<P extends ViewControllerPlugin>(Plugin: new (options: ViewControllerPluginOptions) => P): P;
|
|
28
|
-
BuildApp<A extends
|
|
28
|
+
BuildApp<A extends AppController>(App: new (options: ViewControllerOptions) => A): A & {
|
|
29
|
+
id: string;
|
|
30
|
+
};
|
|
29
31
|
hasController(name: string): boolean;
|
|
30
32
|
hasApp(namespace: string): boolean;
|
|
31
33
|
getController<N extends ViewControllerId>(name: N): any;
|
|
32
34
|
setDates(dates: DateUtil): void;
|
|
33
35
|
addPlugin(named: string, plugin: ViewControllerPlugin): void;
|
|
34
|
-
App(namespace:
|
|
36
|
+
App<Id extends AppControllerId>(namespace: Id): AppControllerMap[Id] & {
|
|
37
|
+
id: Id;
|
|
38
|
+
};
|
|
35
39
|
Controller<N extends ViewControllerId, O extends ControllerOptions<N>>(id: N, options: O): ViewControllerMap[N];
|
|
36
40
|
protected buildViewContructorOptions(name: string, options?: Record<string, any>): ViewControllerOptions;
|
|
37
41
|
private sharedConstructorOptions;
|
|
@@ -84,7 +84,19 @@ export default class ViewControllerFactory {
|
|
|
84
84
|
return new Plugin(this.sharedConstructorOptions());
|
|
85
85
|
}
|
|
86
86
|
BuildApp(App) {
|
|
87
|
-
|
|
87
|
+
const app = new App(this.buildViewContructorOptions('App'));
|
|
88
|
+
//@ts-ignore
|
|
89
|
+
if (app.id) {
|
|
90
|
+
throw new SpruceError({
|
|
91
|
+
code: 'INVALID_APP_CONTROLLER',
|
|
92
|
+
friendlyMessage: `Property \`id\` is reserved in your AppController. Please rename it to \`_id\`.`,
|
|
93
|
+
//@ts-ignore
|
|
94
|
+
id: App.id,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
//@ts-ignore
|
|
98
|
+
app.id = App.id;
|
|
99
|
+
return app;
|
|
88
100
|
}
|
|
89
101
|
hasController(name) {
|
|
90
102
|
//@ts-ignore
|
|
@@ -131,7 +143,7 @@ export default class ViewControllerFactory {
|
|
|
131
143
|
if (instance.id) {
|
|
132
144
|
throw new SpruceError({
|
|
133
145
|
code: 'INVALID_SKILL_VIEW_CONTROLLER',
|
|
134
|
-
friendlyMessage: `Property \`id\` is reserved. Please rename it to \`_id\`.`,
|
|
146
|
+
friendlyMessage: `Property \`id\` is reserved in your ViewController. Please rename it to \`_id\`.`,
|
|
135
147
|
id,
|
|
136
148
|
});
|
|
137
149
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AppControllerConstructor, ImportedViewController, ViewControllerPluginsByName } from '../types/heartwood.types';
|
|
2
2
|
export default class ViewControllerImporter {
|
|
3
3
|
static Class?: typeof ViewControllerImporter;
|
|
4
4
|
protected constructor();
|
|
@@ -9,7 +9,7 @@ export default class ViewControllerImporter {
|
|
|
9
9
|
}
|
|
10
10
|
interface ImportResults {
|
|
11
11
|
controllers: ImportedViewController[];
|
|
12
|
-
App?:
|
|
12
|
+
App?: AppControllerConstructor;
|
|
13
13
|
plugins: ViewControllerPluginsByName;
|
|
14
14
|
}
|
|
15
15
|
export {};
|
package/build/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export * from './utilities/removeUniversalViewOptions';
|
|
|
4
4
|
export * from './.spruce/schemas/schemas.types';
|
|
5
5
|
export { default as AbstractSkillViewController } from './skillViewControllers/Abstract.svc';
|
|
6
6
|
export { default as AbstractViewController } from './viewControllers/Abstract.vc';
|
|
7
|
-
export { default as
|
|
7
|
+
export { default as AbstractAppController } from './viewControllers/Abstract.ac';
|
|
8
8
|
export * from './viewControllers/BigForm.vc';
|
|
9
9
|
export { default as ButtonGroupViewController } from './viewControllers/ButtonGroup.vc';
|
|
10
10
|
export * from './viewControllers/ButtonGroup.vc';
|
package/build/index.js
CHANGED
|
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.dialogSchema = exports.buttonSchema = exports.lineIconSchema = exports.fancyIconSchema = exports.selectInputSchema = exports.skillViewSchema = exports.bigFormSchema = exports.calendarEventColorsSchema = exports.buildSkillView = exports.buildForm = exports.buildBigForm = exports.AuthenticatorImpl = exports.PolarAreaViewController = exports.MockActiveRecordCard = exports.activeRecordCardAssert = exports.buildActiveRecordList = exports.buildActiveRecordCard = exports.AbstractInputViewController = exports.AutocompleteInputViewController = exports.AbstractCalendarEventViewController = exports.RatingsViewController = exports.ProgressViewController = exports.StatsViewController = exports.FeedViewController = exports.ActiveRecordListViewController = exports.ActiveRecordCardViewController = exports.TalkingSprucebotViewController = exports.ButtonBarViewController = exports.CalendarViewController = exports.SwipeCardViewControllerImpl = exports.SwipeViewControllerImpl = exports.PagerViewController = exports.ProgressNavigatorViewController = exports.CountdownTimerViewController = exports.FormBuilderCardViewControllerImpl = exports.LoginViewController = exports.BarChartViewController = exports.ToolBeltViewController = exports.FormViewControllerImpl = exports.ListCellViewController = exports.ListRowViewController = exports.ListViewController = exports.NavigationViewController = exports.DialogViewController = exports.ConfirmViewController = exports.CardViewControllerImpl = exports.ButtonGroupViewController = exports.
|
|
20
|
+
exports.dialogSchema = exports.buttonSchema = exports.lineIconSchema = exports.fancyIconSchema = exports.selectInputSchema = exports.skillViewSchema = exports.bigFormSchema = exports.calendarEventColorsSchema = exports.buildSkillView = exports.buildForm = exports.buildBigForm = exports.AuthenticatorImpl = exports.PolarAreaViewController = exports.MockActiveRecordCard = exports.activeRecordCardAssert = exports.buildActiveRecordList = exports.buildActiveRecordCard = exports.AbstractInputViewController = exports.AutocompleteInputViewController = exports.AbstractCalendarEventViewController = exports.RatingsViewController = exports.ProgressViewController = exports.StatsViewController = exports.FeedViewController = exports.ActiveRecordListViewController = exports.ActiveRecordCardViewController = exports.TalkingSprucebotViewController = exports.ButtonBarViewController = exports.CalendarViewController = exports.SwipeCardViewControllerImpl = exports.SwipeViewControllerImpl = exports.PagerViewController = exports.ProgressNavigatorViewController = exports.CountdownTimerViewController = exports.FormBuilderCardViewControllerImpl = exports.LoginViewController = exports.BarChartViewController = exports.ToolBeltViewController = exports.FormViewControllerImpl = exports.ListCellViewController = exports.ListRowViewController = exports.ListViewController = exports.NavigationViewController = exports.DialogViewController = exports.ConfirmViewController = exports.CardViewControllerImpl = exports.ButtonGroupViewController = exports.AbstractAppController = exports.AbstractViewController = exports.AbstractSkillViewController = void 0;
|
|
21
21
|
exports.ratingsInputSchema = exports.listRatingsInputSchema = exports.ratingsSchema = exports.progressSchema = exports.statsStatSchema = exports.statsSchema = exports.toggleInputSchema = exports.listToggleInputSchema = exports.addressInputSchema = exports.buttonBarButtonSchema = exports.buttonBarSchema = exports.toolBeltToolSchema = exports.toolBeltSchema = exports.calendarTimeSchema = exports.calendarPersonSchema = exports.calendarSchema = exports.themePropsSchema = exports.themeSchema = exports.cardFooterButtonSchema = exports.criticalErrorSchema = exports.sprucebotTypedMessageSentenceSchema = exports.sprucebotTypedMessageAvatarSchema = exports.selectInputChoiceSchema = exports.calendarEventColorOverrideSchema = exports.portalSchema = exports.listTextInputSchema = exports.listSelectInputSchema = exports.listCellButtonSchema = exports.dropdownButtonSchema = exports.bigFormSectionSchema = exports.textInputSchema = exports.phoneInputSchema = exports.inputSchema = exports.dropdownSchema = exports.sprucebotTypedMessageSchema = exports.talkingSprucebotSchema = exports.sprucebotAvatarSchema = exports.formBuilderImportExportObjectSchema = exports.listCellSchema = exports.listRowSchema = exports.listSchema = exports.layoutSchema = exports.cardSectionSchema = exports.cardHeaderSchema = exports.cardFooterSchema = exports.cardBodySchema = exports.cardSchema = exports.formSectionSchema = exports.formSchema = exports.textSchema = void 0;
|
|
22
22
|
exports.barChartAssert = exports.progressNavigatorAssert = exports.countdownTimerInteractor = exports.countdownTimerAssert = exports.calendarInteractor = exports.interactor = exports.normalizeScopeFromVc = exports.autocompleteInteractor = exports.formAssert = exports.autocompleteAssert = exports.listAssert = exports.buttonAssert = exports.deviceAssert = exports.navigationAssert = exports.toolBeltAssert = exports.toastAssert = exports.vcPluginAssert = exports.vcDurationAssert = exports.pagerAssert = exports.vcAssert = exports.vcAssertUtil = exports.feedAssert = exports.feedInteractor = exports.normalizeFormSectionFieldNamesUtil = exports.ViewControllerError = exports.SpyDevice = exports.StubStorage = exports.ViewControllerFactory = exports.ViewControllerImporter = exports.ViewControllerExporter = exports.pagerSchema = exports.polarAreaDataItemSchema = exports.polarAreaSchema = exports.inputButtonSchema = exports.mapPinSchema = exports.mapSchema = exports.latLngSchema = exports.formBuilderImportExportPageSchema = exports.autocompleteSuggestionSchema = exports.autocompleteInputSchema = exports.feedSchema = exports.calendarShiftSchema = exports.receiptTotalSchema = exports.receiptSectionSchema = exports.receiptLineItemSchema = exports.receiptHeaderSchema = exports.receiptSchema = exports.listDateInputSchema = exports.calendarSelectedDateSchema = exports.calendarEventSchema = void 0;
|
|
23
23
|
exports.barChartDataSetSchema = exports.barChartDataPointSchema = exports.barChartSchema = exports.progressDetailsSchema = exports.progressNavigatorStepSchema = exports.progressNavigatorSchema = exports.countdownTimerSchema = exports.destinationSkillViewControllerSchema = exports.permissionContractReferenceSchema = exports.navigationButtonSchema = exports.navigationSchema = exports.ToolBeltStateMachine = exports.removeUniversalViewOptions = exports.buildSkillViewLayout = exports.splitCardsIntoLayouts = exports.listUtil = exports.mapInteractor = exports.mapAssert = exports.renderUtil = exports.routerTestPatcher = exports.dialogTestPatcher = exports.confirmTestPatcher = exports.calendarSeeder = exports.interactionUtil = void 0;
|
|
@@ -29,8 +29,8 @@ var Abstract_svc_1 = require("./skillViewControllers/Abstract.svc");
|
|
|
29
29
|
Object.defineProperty(exports, "AbstractSkillViewController", { enumerable: true, get: function () { return __importDefault(Abstract_svc_1).default; } });
|
|
30
30
|
var Abstract_vc_1 = require("./viewControllers/Abstract.vc");
|
|
31
31
|
Object.defineProperty(exports, "AbstractViewController", { enumerable: true, get: function () { return __importDefault(Abstract_vc_1).default; } });
|
|
32
|
-
var
|
|
33
|
-
Object.defineProperty(exports, "
|
|
32
|
+
var Abstract_ac_1 = require("./viewControllers/Abstract.ac");
|
|
33
|
+
Object.defineProperty(exports, "AbstractAppController", { enumerable: true, get: function () { return __importDefault(Abstract_ac_1).default; } });
|
|
34
34
|
__exportStar(require("./viewControllers/BigForm.vc"), exports);
|
|
35
35
|
var ButtonGroup_vc_1 = require("./viewControllers/ButtonGroup.vc");
|
|
36
36
|
Object.defineProperty(exports, "ButtonGroupViewController", { enumerable: true, get: function () { return __importDefault(ButtonGroup_vc_1).default; } });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PermissionContractId } from '@sprucelabs/mercury-types';
|
|
2
|
-
import { Navigation, SkillViewController, SkillViewControllerId, ViewController } from '../../types/heartwood.types';
|
|
2
|
+
import { AppController, Navigation, SkillViewController, SkillViewControllerId, ViewController } from '../../types/heartwood.types';
|
|
3
3
|
declare const navigationAssert: {
|
|
4
4
|
rendersButton(vc: ViewController<Navigation>, id: string): void;
|
|
5
5
|
buttonRedirectsTo(options: {
|
|
@@ -12,7 +12,9 @@ declare const navigationAssert: {
|
|
|
12
12
|
}): void;
|
|
13
13
|
rendersButtons(vc: ViewController<Navigation>, ids: string[]): void;
|
|
14
14
|
rendersButtonLabels(vc: ViewController<Navigation>): void;
|
|
15
|
-
skillViewRendersNavigation(vc: Pick<SkillViewController, "renderNavigation"
|
|
15
|
+
skillViewRendersNavigation(vc: Pick<SkillViewController, "renderNavigation">, msg?: string): ViewController<import("@sprucelabs/mercury-types").SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Navigation>;
|
|
16
|
+
appRendersNavigation(vc: Pick<AppController, "renderNavigation">): ViewController<import("@sprucelabs/mercury-types").SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Navigation>;
|
|
17
|
+
appDoesNotRenderNavigation(vc: Pick<AppController, "renderNavigation">): void;
|
|
16
18
|
skillViewDoesNotRenderNavigation(vc: Pick<SkillViewController, "renderNavigation">): void;
|
|
17
19
|
buttonRequiresViewPermissions(vc: ViewController<Navigation>, button: string, permissionContractId: PermissionContractId): void;
|
|
18
20
|
};
|
|
@@ -26,11 +26,19 @@ const navigationAssert = {
|
|
|
26
26
|
const model = render_utility_1.default.render(vc);
|
|
27
27
|
test_utils_1.assert.isTrue(model.shouldRenderButtonLabels, `Your navigation should render button labels but it is not! Try shouldRenderButtonLabels: true`);
|
|
28
28
|
},
|
|
29
|
-
skillViewRendersNavigation(vc) {
|
|
29
|
+
skillViewRendersNavigation(vc, msg) {
|
|
30
30
|
const nav = vc.renderNavigation?.();
|
|
31
|
-
test_utils_1.assert.isTruthy(nav,
|
|
31
|
+
test_utils_1.assert.isTruthy(nav, msg ??
|
|
32
|
+
`Your skill view did not render a navigation! Implement renderNavigation() and use this.Controller('navigation', {}) to render one.`);
|
|
32
33
|
return nav.controller;
|
|
33
34
|
},
|
|
35
|
+
appRendersNavigation(vc) {
|
|
36
|
+
return this.skillViewRendersNavigation(vc, `Your AppController did not render a navigation! Implement renderNavigation() and use this.Controller('navigation', {}) to render one.`);
|
|
37
|
+
},
|
|
38
|
+
appDoesNotRenderNavigation(vc) {
|
|
39
|
+
const nav = vc.renderNavigation?.();
|
|
40
|
+
test_utils_1.assert.isNull(nav, `Your AppController should not render a navigation! Implement renderNavigation() and return null.`);
|
|
41
|
+
},
|
|
34
42
|
skillViewDoesNotRenderNavigation(vc) {
|
|
35
43
|
const nav = vc.renderNavigation?.();
|
|
36
44
|
test_utils_1.assert.isNull(nav, `Your skill view should not render a navigation! Implement renderNavigation() and return null.`);
|
|
@@ -210,6 +210,7 @@ export type ImportedViewController = (new (options: ViewControllerOptions) => Vi
|
|
|
210
210
|
};
|
|
211
211
|
export type ViewControllerId = keyof ViewControllerMap;
|
|
212
212
|
export type SkillViewControllerId = keyof SkillViewControllerMap;
|
|
213
|
+
export type AppControllerId = keyof AppControllerMap;
|
|
213
214
|
export interface RedirectOptions {
|
|
214
215
|
shouldTrackHistory?: boolean;
|
|
215
216
|
}
|
|
@@ -349,6 +350,8 @@ export interface SkillViewControllerMap {
|
|
|
349
350
|
}
|
|
350
351
|
export interface SkillViewControllerArgsMap {
|
|
351
352
|
}
|
|
353
|
+
export interface AppControllerMap {
|
|
354
|
+
}
|
|
352
355
|
export type ControllerOptions<N extends ViewControllerId, O extends ViewControllerOptionsMap = ViewControllerOptionsMap> = Omit<N extends keyof O ? O[N] : Record<string, never>, UniversalViewOptionFields>;
|
|
353
356
|
export type MapUtil = typeof mapUtil;
|
|
354
357
|
export interface OpenNavigationOptions {
|
|
@@ -511,15 +514,18 @@ export interface ActiveRecordSearchOptions {
|
|
|
511
514
|
shouldSearchClientSide?: boolean;
|
|
512
515
|
placeholder?: string;
|
|
513
516
|
}
|
|
514
|
-
export interface
|
|
517
|
+
export interface AppController {
|
|
515
518
|
renderNavigation?(): Navigation | null | undefined;
|
|
516
519
|
renderToolBelt?(): ToolBelt | null | undefined;
|
|
517
|
-
load
|
|
520
|
+
load(options: AppControllerLoadOptions): Promise<void>;
|
|
518
521
|
}
|
|
519
|
-
export type
|
|
522
|
+
export type BuiltAppController = AppController & {
|
|
523
|
+
id: string;
|
|
524
|
+
};
|
|
525
|
+
export type AppControllerConstructor = (new (options: ViewControllerOptions) => AppController) & {
|
|
520
526
|
id: string;
|
|
521
527
|
};
|
|
522
|
-
export interface
|
|
528
|
+
export interface AppControllerLoadOptions {
|
|
523
529
|
router: Router;
|
|
524
530
|
authenticator: Authenticator;
|
|
525
531
|
authorizer: Authorizer;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AppController, AppControllerLoadOptions, ControllerOptions, ViewControllerId, ViewControllerMap, ViewControllerOptions, ViewControllerPlugins } from '../types/heartwood.types';
|
|
2
|
+
export default abstract class AbstractAppController implements AppController {
|
|
3
|
+
static id: string;
|
|
4
|
+
protected plugins: ViewControllerPlugins;
|
|
5
|
+
private views;
|
|
6
|
+
constructor(options: ViewControllerOptions);
|
|
7
|
+
load(options: AppControllerLoadOptions): Promise<void>;
|
|
8
|
+
Controller<N extends ViewControllerId, O extends ControllerOptions<N>>(id: N, options: O): ViewControllerMap[N];
|
|
9
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class AbstractAppController {
|
|
4
|
+
constructor(options) {
|
|
5
|
+
const { plugins, vcFactory } = options;
|
|
6
|
+
this.plugins = plugins;
|
|
7
|
+
this.views = vcFactory;
|
|
8
|
+
}
|
|
9
|
+
async load(options) { }
|
|
10
|
+
Controller(id, options) {
|
|
11
|
+
return this.views.Controller(id, options);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.default = AbstractAppController;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DateUtil } from '@sprucelabs/calendar-utils';
|
|
2
2
|
import { Log } from '@sprucelabs/spruce-skill-utils';
|
|
3
|
-
import { ConfirmHandler, ControllerOptions, ImportedViewController, RenderInDialogHandler, ViewController, ViewControllerMap, ViewControllerId, VoteHandler, Device, MapUtil, ViewControllerConstructor, ToastHandler, ViewControllerPlugins, ViewControllerPluginsByName, ConnectToApi, ViewControllerPlugin, ViewControllerPluginOptions, ViewControllerOptions,
|
|
3
|
+
import { ConfirmHandler, ControllerOptions, ImportedViewController, RenderInDialogHandler, ViewController, ViewControllerMap, ViewControllerId, VoteHandler, Device, MapUtil, ViewControllerConstructor, ToastHandler, ViewControllerPlugins, ViewControllerPluginsByName, ConnectToApi, ViewControllerPlugin, ViewControllerPluginOptions, ViewControllerOptions, AppController, AppControllerConstructor, AppControllerId, AppControllerMap } from '../types/heartwood.types';
|
|
4
4
|
export default class ViewControllerFactory {
|
|
5
5
|
static Class?: typeof ViewControllerFactory;
|
|
6
6
|
private controllerMap;
|
|
@@ -22,16 +22,20 @@ export default class ViewControllerFactory {
|
|
|
22
22
|
static Factory(options: ViewControllerFactoryOptions): ViewControllerFactory;
|
|
23
23
|
setController<Vc extends ViewController<any>>(name: string, Class: ViewControllerConstructor<Vc>): void;
|
|
24
24
|
mixinControllers(map: Record<string, ViewControllerConstructor<ViewController<any>>>): void;
|
|
25
|
-
importControllers<Vc extends ImportedViewController>(Vcs: Vc[], plugins?: ViewControllerPluginsByName, App?:
|
|
25
|
+
importControllers<Vc extends ImportedViewController>(Vcs: Vc[], plugins?: ViewControllerPluginsByName, App?: AppControllerConstructor): void;
|
|
26
26
|
private importPlugins;
|
|
27
27
|
BuildPlugin<P extends ViewControllerPlugin>(Plugin: new (options: ViewControllerPluginOptions) => P): P;
|
|
28
|
-
BuildApp<A extends
|
|
28
|
+
BuildApp<A extends AppController>(App: new (options: ViewControllerOptions) => A): A & {
|
|
29
|
+
id: string;
|
|
30
|
+
};
|
|
29
31
|
hasController(name: string): boolean;
|
|
30
32
|
hasApp(namespace: string): boolean;
|
|
31
33
|
getController<N extends ViewControllerId>(name: N): any;
|
|
32
34
|
setDates(dates: DateUtil): void;
|
|
33
35
|
addPlugin(named: string, plugin: ViewControllerPlugin): void;
|
|
34
|
-
App(namespace:
|
|
36
|
+
App<Id extends AppControllerId>(namespace: Id): AppControllerMap[Id] & {
|
|
37
|
+
id: Id;
|
|
38
|
+
};
|
|
35
39
|
Controller<N extends ViewControllerId, O extends ControllerOptions<N>>(id: N, options: O): ViewControllerMap[N];
|
|
36
40
|
protected buildViewContructorOptions(name: string, options?: Record<string, any>): ViewControllerOptions;
|
|
37
41
|
private sharedConstructorOptions;
|
|
@@ -82,7 +82,19 @@ class ViewControllerFactory {
|
|
|
82
82
|
return new Plugin(this.sharedConstructorOptions());
|
|
83
83
|
}
|
|
84
84
|
BuildApp(App) {
|
|
85
|
-
|
|
85
|
+
const app = new App(this.buildViewContructorOptions('App'));
|
|
86
|
+
//@ts-ignore
|
|
87
|
+
if (app.id) {
|
|
88
|
+
throw new SpruceError_1.default({
|
|
89
|
+
code: 'INVALID_APP_CONTROLLER',
|
|
90
|
+
friendlyMessage: `Property \`id\` is reserved in your AppController. Please rename it to \`_id\`.`,
|
|
91
|
+
//@ts-ignore
|
|
92
|
+
id: App.id,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
//@ts-ignore
|
|
96
|
+
app.id = App.id;
|
|
97
|
+
return app;
|
|
86
98
|
}
|
|
87
99
|
hasController(name) {
|
|
88
100
|
//@ts-ignore
|
|
@@ -129,7 +141,7 @@ class ViewControllerFactory {
|
|
|
129
141
|
if (instance.id) {
|
|
130
142
|
throw new SpruceError_1.default({
|
|
131
143
|
code: 'INVALID_SKILL_VIEW_CONTROLLER',
|
|
132
|
-
friendlyMessage: `Property \`id\` is reserved. Please rename it to \`_id\`.`,
|
|
144
|
+
friendlyMessage: `Property \`id\` is reserved in your ViewController. Please rename it to \`_id\`.`,
|
|
133
145
|
id,
|
|
134
146
|
});
|
|
135
147
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AppControllerConstructor, ImportedViewController, ViewControllerPluginsByName } from '../types/heartwood.types';
|
|
2
2
|
export default class ViewControllerImporter {
|
|
3
3
|
static Class?: typeof ViewControllerImporter;
|
|
4
4
|
protected constructor();
|
|
@@ -9,7 +9,7 @@ export default class ViewControllerImporter {
|
|
|
9
9
|
}
|
|
10
10
|
interface ImportResults {
|
|
11
11
|
controllers: ImportedViewController[];
|
|
12
|
-
App?:
|
|
12
|
+
App?: AppControllerConstructor;
|
|
13
13
|
plugins: ViewControllerPluginsByName;
|
|
14
14
|
}
|
|
15
15
|
export {};
|
package/package.json
CHANGED