@sprucelabs/heartwood-view-controllers 126.10.9 → 126.11.1

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.
@@ -215,6 +215,18 @@ 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 InvalidLoginConfiguration {
220
+ }
221
+ interface InvalidLoginConfigurationSchema extends SpruceSchema.Schema {
222
+ id: 'invalidLoginConfiguration';
223
+ namespace: 'HeartwoodViewControllers';
224
+ name: 'Invalid login configuration';
225
+ moduleToImportFromWhenRemote: '@sprucelabs/heartwood-view-controllers';
226
+ fields: {};
227
+ }
228
+ type InvalidLoginConfigurationEntity = SchemaEntity<SpruceErrors.HeartwoodViewControllers.InvalidLoginConfigurationSchema>;
229
+ }
218
230
  export declare namespace SpruceErrors.HeartwoodViewControllers {
219
231
  interface InvalidAppController {
220
232
  'id': string;
@@ -0,0 +1,3 @@
1
+ import { SpruceErrors } from '../errors.types';
2
+ declare const invalidLoginConfigurationSchema: SpruceErrors.HeartwoodViewControllers.InvalidLoginConfigurationSchema;
3
+ export default invalidLoginConfigurationSchema;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const schema_1 = require("@sprucelabs/schema");
4
+ const invalidLoginConfigurationSchema = {
5
+ id: 'invalidLoginConfiguration',
6
+ namespace: 'HeartwoodViewControllers',
7
+ name: 'Invalid login configuration',
8
+ moduleToImportFromWhenRemote: '@sprucelabs/heartwood-view-controllers',
9
+ fields: {}
10
+ };
11
+ schema_1.SchemaRegistry.getInstance().trackSchema(invalidLoginConfigurationSchema);
12
+ exports.default = invalidLoginConfigurationSchema;
@@ -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 InvalidLoginConfigurationErrorOptions extends SpruceErrors.HeartwoodViewControllers.InvalidLoginConfiguration, ISpruceErrorOptions {
37
+ code: 'INVALID_LOGIN_CONFIGURATION';
38
+ }
36
39
  export interface InvalidAppControllerErrorOptions extends SpruceErrors.HeartwoodViewControllers.InvalidAppController, ISpruceErrorOptions {
37
40
  code: 'INVALID_APP_CONTROLLER';
38
41
  }
@@ -66,5 +69,5 @@ export interface CellDeletedErrorOptions extends SpruceErrors.HeartwoodViewContr
66
69
  export interface AppNotFoundErrorOptions extends SpruceErrors.HeartwoodViewControllers.AppNotFound, ISpruceErrorOptions {
67
70
  code: 'APP_NOT_FOUND';
68
71
  }
69
- type ErrorOptions = ViewAlreadyDestroyedErrorOptions | ToolNotFoundErrorOptions | StepNotCompleteErrorOptions | SlideNotFoundErrorOptions | RowDeletedErrorOptions | PersonNotFoundErrorOptions | NoFieldVcSetErrorOptions | MissingStorageErrorOptions | InvalidViewControllerSourceErrorOptions | InvalidViewControllerNameErrorOptions | InvalidSkillViewControllerErrorOptions | InvalidAppControllerErrorOptions | ExportFailedErrorOptions | EventNotFoundErrorOptions | DuplicateToolIdErrorOptions | DuplicateRowIdErrorOptions | DuplicateEventIdErrorOptions | DidNotGenerateOfferErrorOptions | DateNotSelectedErrorOptions | DateAlreadySelectedErrorOptions | CellDeletedErrorOptions | AppNotFoundErrorOptions;
72
+ type ErrorOptions = ViewAlreadyDestroyedErrorOptions | ToolNotFoundErrorOptions | StepNotCompleteErrorOptions | SlideNotFoundErrorOptions | RowDeletedErrorOptions | PersonNotFoundErrorOptions | NoFieldVcSetErrorOptions | MissingStorageErrorOptions | InvalidViewControllerSourceErrorOptions | InvalidViewControllerNameErrorOptions | InvalidSkillViewControllerErrorOptions | InvalidLoginConfigurationErrorOptions | InvalidAppControllerErrorOptions | ExportFailedErrorOptions | EventNotFoundErrorOptions | DuplicateToolIdErrorOptions | DuplicateRowIdErrorOptions | DuplicateEventIdErrorOptions | DidNotGenerateOfferErrorOptions | DateNotSelectedErrorOptions | DateAlreadySelectedErrorOptions | CellDeletedErrorOptions | AppNotFoundErrorOptions;
70
73
  export default ErrorOptions;
@@ -83,6 +83,9 @@ class SpruceError extends error_1.default {
83
83
  case 'DID_NOT_GENERATE_OFFER':
84
84
  message = `You have to generate an offer before setting an answer for streaming!`;
85
85
  break;
86
+ case 'INVALID_LOGIN_CONFIGURATION':
87
+ message = 'A Invalid login configuration just happened!';
88
+ break;
86
89
  default:
87
90
  message = super.friendlyMessage();
88
91
  }
@@ -0,0 +1,6 @@
1
+ declare const _default: {
2
+ id: string;
3
+ name: string;
4
+ fields: {};
5
+ };
6
+ export default _default;
@@ -0,0 +1,8 @@
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: 'invalidLoginConfiguration',
6
+ name: 'Invalid login configuration',
7
+ fields: {},
8
+ });
@@ -215,6 +215,18 @@ 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 InvalidLoginConfiguration {
220
+ }
221
+ interface InvalidLoginConfigurationSchema extends SpruceSchema.Schema {
222
+ id: 'invalidLoginConfiguration';
223
+ namespace: 'HeartwoodViewControllers';
224
+ name: 'Invalid login configuration';
225
+ moduleToImportFromWhenRemote: '@sprucelabs/heartwood-view-controllers';
226
+ fields: {};
227
+ }
228
+ type InvalidLoginConfigurationEntity = SchemaEntity<SpruceErrors.HeartwoodViewControllers.InvalidLoginConfigurationSchema>;
229
+ }
218
230
  export declare namespace SpruceErrors.HeartwoodViewControllers {
219
231
  interface InvalidAppController {
220
232
  'id': string;
@@ -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 InvalidLoginConfigurationErrorOptions extends SpruceErrors.HeartwoodViewControllers.InvalidLoginConfiguration, ISpruceErrorOptions {
37
+ code: 'INVALID_LOGIN_CONFIGURATION';
38
+ }
36
39
  export interface InvalidAppControllerErrorOptions extends SpruceErrors.HeartwoodViewControllers.InvalidAppController, ISpruceErrorOptions {
37
40
  code: 'INVALID_APP_CONTROLLER';
38
41
  }
@@ -66,5 +69,5 @@ export interface CellDeletedErrorOptions extends SpruceErrors.HeartwoodViewContr
66
69
  export interface AppNotFoundErrorOptions extends SpruceErrors.HeartwoodViewControllers.AppNotFound, ISpruceErrorOptions {
67
70
  code: 'APP_NOT_FOUND';
68
71
  }
69
- type ErrorOptions = ViewAlreadyDestroyedErrorOptions | ToolNotFoundErrorOptions | StepNotCompleteErrorOptions | SlideNotFoundErrorOptions | RowDeletedErrorOptions | PersonNotFoundErrorOptions | NoFieldVcSetErrorOptions | MissingStorageErrorOptions | InvalidViewControllerSourceErrorOptions | InvalidViewControllerNameErrorOptions | InvalidSkillViewControllerErrorOptions | InvalidAppControllerErrorOptions | ExportFailedErrorOptions | EventNotFoundErrorOptions | DuplicateToolIdErrorOptions | DuplicateRowIdErrorOptions | DuplicateEventIdErrorOptions | DidNotGenerateOfferErrorOptions | DateNotSelectedErrorOptions | DateAlreadySelectedErrorOptions | CellDeletedErrorOptions | AppNotFoundErrorOptions;
72
+ type ErrorOptions = ViewAlreadyDestroyedErrorOptions | ToolNotFoundErrorOptions | StepNotCompleteErrorOptions | SlideNotFoundErrorOptions | RowDeletedErrorOptions | PersonNotFoundErrorOptions | NoFieldVcSetErrorOptions | MissingStorageErrorOptions | InvalidViewControllerSourceErrorOptions | InvalidViewControllerNameErrorOptions | InvalidSkillViewControllerErrorOptions | InvalidLoginConfigurationErrorOptions | InvalidAppControllerErrorOptions | ExportFailedErrorOptions | EventNotFoundErrorOptions | DuplicateToolIdErrorOptions | DuplicateRowIdErrorOptions | DuplicateEventIdErrorOptions | DidNotGenerateOfferErrorOptions | DateNotSelectedErrorOptions | DateAlreadySelectedErrorOptions | CellDeletedErrorOptions | AppNotFoundErrorOptions;
70
73
  export default ErrorOptions;
@@ -79,6 +79,9 @@ export default class SpruceError extends AbstractSpruceError {
79
79
  case 'DID_NOT_GENERATE_OFFER':
80
80
  message = `You have to generate an offer before setting an answer for streaming!`;
81
81
  break;
82
+ case 'INVALID_LOGIN_CONFIGURATION':
83
+ message = 'A Invalid login configuration just happened!';
84
+ break;
82
85
  default:
83
86
  message = super.friendlyMessage();
84
87
  }
@@ -0,0 +1,6 @@
1
+ declare const _default: {
2
+ id: string;
3
+ name: string;
4
+ fields: {};
5
+ };
6
+ export default _default;
@@ -0,0 +1,6 @@
1
+ import { buildErrorSchema } from '@sprucelabs/schema';
2
+ export default buildErrorSchema({
3
+ id: 'invalidLoginConfiguration',
4
+ name: 'Invalid login configuration',
5
+ fields: {},
6
+ });
@@ -11,17 +11,22 @@ export default class LoginCardViewController extends AbstractViewController<Card
11
11
  private loginFailedHandler?;
12
12
  private cardVc;
13
13
  private shouldAllowEmailLogin;
14
+ private shouldAllowPhoneLogin;
14
15
  private smsDisclaimer?;
15
16
  constructor(options: LoginCardViewControllerOptions & ViewControllerOptions);
16
17
  private CardVc;
17
18
  private renderLoginWithEmailButton;
18
19
  private handleClickLoginWithEmail;
20
+ private renderEmailSection;
19
21
  private renderLoginWithPhoneButton;
20
22
  private handleClickLoginWithPhone;
21
23
  private renderEmailSlideTitle;
22
24
  private renderLoginSubtitle;
23
25
  private renderLoginTitle;
24
26
  private BigForm;
27
+ private renderFirstSection;
28
+ private renderPinSection;
29
+ private renderFooter;
25
30
  private renderPhoneSection;
26
31
  private renderPhoneSlideTitle;
27
32
  private handleSlideChange;
@@ -70,6 +75,7 @@ export interface LoginCardViewControllerOptions {
70
75
  id?: string | null;
71
76
  smsDisclaimer?: string | null;
72
77
  shouldAllowEmailLogin?: boolean;
78
+ shouldAllowPhoneLogin?: boolean;
73
79
  }
74
80
  declare const loginSchema: {
75
81
  id: string;
@@ -11,13 +11,21 @@ import { buildSchema } from '@sprucelabs/schema';
11
11
  import { randomUtil } from '@sprucelabs/spruce-skill-utils';
12
12
  import Authenticator from '../auth/Authenticator.js';
13
13
  import buildBigForm from '../builders/buildBigForm.js';
14
+ import SpruceError from '../errors/SpruceError.js';
14
15
  import AbstractViewController from './Abstract.vc.js';
15
16
  class LoginCardViewController extends AbstractViewController {
16
17
  constructor(options) {
17
18
  super(options);
18
- const { id, onLogin, onLoginFailed, smsDisclaimer, shouldAllowEmailLogin, } = options;
19
+ const { id, onLogin, onLoginFailed, smsDisclaimer, shouldAllowEmailLogin, shouldAllowPhoneLogin = true, } = options;
19
20
  this._id = id !== null && id !== void 0 ? id : `${LoginCardViewController._id}`;
20
21
  LoginCardViewController._id++;
22
+ if (!shouldAllowPhoneLogin && !shouldAllowEmailLogin) {
23
+ throw new SpruceError({
24
+ code: 'INVALID_LOGIN_CONFIGURATION',
25
+ friendlyMessage: 'You have to allow phone or email login.',
26
+ });
27
+ }
28
+ this.shouldAllowPhoneLogin = shouldAllowPhoneLogin;
21
29
  this.shouldAllowEmailLogin = shouldAllowEmailLogin !== null && shouldAllowEmailLogin !== void 0 ? shouldAllowEmailLogin : false;
22
30
  this.loginHandler = onLogin;
23
31
  this.loginFailedHandler = onLoginFailed;
@@ -52,15 +60,18 @@ class LoginCardViewController extends AbstractViewController {
52
60
  }
53
61
  handleClickLoginWithEmail() {
54
62
  return __awaiter(this, void 0, void 0, function* () {
55
- this.bigFormVc.updateSection(0, {
56
- title: this.renderEmailSlideTitle(),
57
- fields: ['email'],
58
- });
63
+ this.bigFormVc.updateSection(0, this.renderEmailSection());
59
64
  this.bigFormVc.setFooter({
60
65
  buttons: [this.renderLoginWithPhoneButton()],
61
66
  });
62
67
  });
63
68
  }
69
+ renderEmailSection() {
70
+ return {
71
+ title: this.renderEmailSlideTitle(),
72
+ fields: ['email'],
73
+ };
74
+ }
64
75
  renderLoginWithPhoneButton() {
65
76
  return {
66
77
  id: 'login-with-phone',
@@ -106,24 +117,33 @@ class LoginCardViewController extends AbstractViewController {
106
117
  id: this._id,
107
118
  schema: loginSchema,
108
119
  onSlideChange: this.handleSlideChange.bind(this),
109
- sections: [
110
- this.renderPhoneSection(),
111
- {
112
- title: randomUtil.rand([
113
- 'Now the pin! 👇',
114
- 'The pin is next!',
115
- 'Time for pin.',
116
- ]),
117
- fields: [{ name: 'code', renderAs: 'number' }],
118
- },
119
- ],
120
- footer: this.shouldAllowEmailLogin
121
- ? {
122
- buttons: [this.renderLoginWithEmailButton()],
123
- }
124
- : null,
120
+ sections: [this.renderFirstSection(), this.renderPinSection()],
121
+ footer: this.renderFooter(),
125
122
  }));
126
123
  }
124
+ renderFirstSection() {
125
+ if (!this.shouldAllowPhoneLogin) {
126
+ return this.renderEmailSection();
127
+ }
128
+ return this.renderPhoneSection();
129
+ }
130
+ renderPinSection() {
131
+ return {
132
+ title: randomUtil.rand([
133
+ 'Now the pin! 👇',
134
+ 'The pin is next!',
135
+ 'Time for pin.',
136
+ ]),
137
+ fields: [{ name: 'code', renderAs: 'number' }],
138
+ };
139
+ }
140
+ renderFooter() {
141
+ return this.shouldAllowEmailLogin && this.shouldAllowPhoneLogin
142
+ ? {
143
+ buttons: [this.renderLoginWithEmailButton()],
144
+ }
145
+ : null;
146
+ }
127
147
  renderPhoneSection() {
128
148
  var _a;
129
149
  return {
@@ -11,17 +11,22 @@ export default class LoginCardViewController extends AbstractViewController<Card
11
11
  private loginFailedHandler?;
12
12
  private cardVc;
13
13
  private shouldAllowEmailLogin;
14
+ private shouldAllowPhoneLogin;
14
15
  private smsDisclaimer?;
15
16
  constructor(options: LoginCardViewControllerOptions & ViewControllerOptions);
16
17
  private CardVc;
17
18
  private renderLoginWithEmailButton;
18
19
  private handleClickLoginWithEmail;
20
+ private renderEmailSection;
19
21
  private renderLoginWithPhoneButton;
20
22
  private handleClickLoginWithPhone;
21
23
  private renderEmailSlideTitle;
22
24
  private renderLoginSubtitle;
23
25
  private renderLoginTitle;
24
26
  private BigForm;
27
+ private renderFirstSection;
28
+ private renderPinSection;
29
+ private renderFooter;
25
30
  private renderPhoneSection;
26
31
  private renderPhoneSlideTitle;
27
32
  private handleSlideChange;
@@ -70,6 +75,7 @@ export interface LoginCardViewControllerOptions {
70
75
  id?: string | null;
71
76
  smsDisclaimer?: string | null;
72
77
  shouldAllowEmailLogin?: boolean;
78
+ shouldAllowPhoneLogin?: boolean;
73
79
  }
74
80
  declare const loginSchema: {
75
81
  id: string;
@@ -7,13 +7,21 @@ const schema_1 = require("@sprucelabs/schema");
7
7
  const spruce_skill_utils_1 = require("@sprucelabs/spruce-skill-utils");
8
8
  const Authenticator_1 = __importDefault(require("../auth/Authenticator"));
9
9
  const buildBigForm_1 = __importDefault(require("../builders/buildBigForm"));
10
+ const SpruceError_1 = __importDefault(require("../errors/SpruceError"));
10
11
  const Abstract_vc_1 = __importDefault(require("./Abstract.vc"));
11
12
  class LoginCardViewController extends Abstract_vc_1.default {
12
13
  constructor(options) {
13
14
  super(options);
14
- const { id, onLogin, onLoginFailed, smsDisclaimer, shouldAllowEmailLogin, } = options;
15
+ const { id, onLogin, onLoginFailed, smsDisclaimer, shouldAllowEmailLogin, shouldAllowPhoneLogin = true, } = options;
15
16
  this._id = id ?? `${LoginCardViewController._id}`;
16
17
  LoginCardViewController._id++;
18
+ if (!shouldAllowPhoneLogin && !shouldAllowEmailLogin) {
19
+ throw new SpruceError_1.default({
20
+ code: 'INVALID_LOGIN_CONFIGURATION',
21
+ friendlyMessage: 'You have to allow phone or email login.',
22
+ });
23
+ }
24
+ this.shouldAllowPhoneLogin = shouldAllowPhoneLogin;
17
25
  this.shouldAllowEmailLogin = shouldAllowEmailLogin ?? false;
18
26
  this.loginHandler = onLogin;
19
27
  this.loginFailedHandler = onLoginFailed;
@@ -47,14 +55,17 @@ class LoginCardViewController extends Abstract_vc_1.default {
47
55
  };
48
56
  }
49
57
  async handleClickLoginWithEmail() {
50
- this.bigFormVc.updateSection(0, {
51
- title: this.renderEmailSlideTitle(),
52
- fields: ['email'],
53
- });
58
+ this.bigFormVc.updateSection(0, this.renderEmailSection());
54
59
  this.bigFormVc.setFooter({
55
60
  buttons: [this.renderLoginWithPhoneButton()],
56
61
  });
57
62
  }
63
+ renderEmailSection() {
64
+ return {
65
+ title: this.renderEmailSlideTitle(),
66
+ fields: ['email'],
67
+ };
68
+ }
58
69
  renderLoginWithPhoneButton() {
59
70
  return {
60
71
  id: 'login-with-phone',
@@ -98,24 +109,33 @@ class LoginCardViewController extends Abstract_vc_1.default {
98
109
  id: this._id,
99
110
  schema: loginSchema,
100
111
  onSlideChange: this.handleSlideChange.bind(this),
101
- sections: [
102
- this.renderPhoneSection(),
103
- {
104
- title: spruce_skill_utils_1.randomUtil.rand([
105
- 'Now the pin! 👇',
106
- 'The pin is next!',
107
- 'Time for pin.',
108
- ]),
109
- fields: [{ name: 'code', renderAs: 'number' }],
110
- },
111
- ],
112
- footer: this.shouldAllowEmailLogin
113
- ? {
114
- buttons: [this.renderLoginWithEmailButton()],
115
- }
116
- : null,
112
+ sections: [this.renderFirstSection(), this.renderPinSection()],
113
+ footer: this.renderFooter(),
117
114
  }));
118
115
  }
116
+ renderFirstSection() {
117
+ if (!this.shouldAllowPhoneLogin) {
118
+ return this.renderEmailSection();
119
+ }
120
+ return this.renderPhoneSection();
121
+ }
122
+ renderPinSection() {
123
+ return {
124
+ title: spruce_skill_utils_1.randomUtil.rand([
125
+ 'Now the pin! 👇',
126
+ 'The pin is next!',
127
+ 'Time for pin.',
128
+ ]),
129
+ fields: [{ name: 'code', renderAs: 'number' }],
130
+ };
131
+ }
132
+ renderFooter() {
133
+ return this.shouldAllowEmailLogin && this.shouldAllowPhoneLogin
134
+ ? {
135
+ buttons: [this.renderLoginWithEmailButton()],
136
+ }
137
+ : null;
138
+ }
119
139
  renderPhoneSection() {
120
140
  return {
121
141
  title: this.renderPhoneSlideTitle(),
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": "126.10.9",
16
+ "version": "126.11.1",
17
17
  "skill": {
18
18
  "namespace": "HeartwoodViewControllers",
19
19
  "commandOverrides": {