@sprucelabs/heartwood-view-controllers 111.1.33 → 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.
@@ -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">): ViewController<import("@sprucelabs/mercury-types").SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Navigation>;
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);
@@ -517,7 +517,7 @@ export interface ActiveRecordSearchOptions {
517
517
  export interface AppController {
518
518
  renderNavigation?(): Navigation | null | undefined;
519
519
  renderToolBelt?(): ToolBelt | null | undefined;
520
- load?(options: AppControllerLoadOptions): Promise<void>;
520
+ load(options: AppControllerLoadOptions): Promise<void>;
521
521
  }
522
522
  export type BuiltAppController = AppController & {
523
523
  id: string;
@@ -1,5 +1,9 @@
1
- import { AppController, ViewControllerOptions } from '../types/heartwood.types';
1
+ import { AppController, AppControllerLoadOptions, ControllerOptions, ViewControllerId, ViewControllerMap, ViewControllerOptions, ViewControllerPlugins } from '../types/heartwood.types';
2
2
  export default abstract class AbstractAppController implements AppController {
3
3
  static id: string;
4
- constructor(_options: ViewControllerOptions);
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];
5
9
  }
@@ -1,3 +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
+ };
1
10
  export default class AbstractAppController {
2
- constructor(_options) { }
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
+ }
3
22
  }
@@ -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">): ViewController<import("@sprucelabs/mercury-types").SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Navigation>;
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, `Your skill view did not render a navigation! Implement renderNavigation() and use this.Controller('navigation', {}) to render one.`);
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.`);
@@ -517,7 +517,7 @@ export interface ActiveRecordSearchOptions {
517
517
  export interface AppController {
518
518
  renderNavigation?(): Navigation | null | undefined;
519
519
  renderToolBelt?(): ToolBelt | null | undefined;
520
- load?(options: AppControllerLoadOptions): Promise<void>;
520
+ load(options: AppControllerLoadOptions): Promise<void>;
521
521
  }
522
522
  export type BuiltAppController = AppController & {
523
523
  id: string;
@@ -1,5 +1,9 @@
1
- import { AppController, ViewControllerOptions } from '../types/heartwood.types';
1
+ import { AppController, AppControllerLoadOptions, ControllerOptions, ViewControllerId, ViewControllerMap, ViewControllerOptions, ViewControllerPlugins } from '../types/heartwood.types';
2
2
  export default abstract class AbstractAppController implements AppController {
3
3
  static id: string;
4
- constructor(_options: ViewControllerOptions);
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];
5
9
  }
@@ -1,6 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  class AbstractAppController {
4
- constructor(_options) { }
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
+ }
5
13
  }
6
14
  exports.default = AbstractAppController;
package/package.json CHANGED
@@ -13,7 +13,7 @@
13
13
  "sideEffects": false,
14
14
  "license": "MIT",
15
15
  "description": "All the power of Heartwood in one, convenient package.",
16
- "version": "111.1.33",
16
+ "version": "111.1.34",
17
17
  "skill": {
18
18
  "namespace": "HeartwoodViewControllers",
19
19
  "commandOverrides": {