@sprucelabs/heartwood-view-controllers 126.10.8 → 126.11.0

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,20 @@ 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
+ });
26
+ }
27
+ this.shouldAllowPhoneLogin = shouldAllowPhoneLogin;
21
28
  this.shouldAllowEmailLogin = shouldAllowEmailLogin !== null && shouldAllowEmailLogin !== void 0 ? shouldAllowEmailLogin : false;
22
29
  this.loginHandler = onLogin;
23
30
  this.loginFailedHandler = onLoginFailed;
@@ -52,15 +59,18 @@ class LoginCardViewController extends AbstractViewController {
52
59
  }
53
60
  handleClickLoginWithEmail() {
54
61
  return __awaiter(this, void 0, void 0, function* () {
55
- this.bigFormVc.updateSection(0, {
56
- title: this.renderEmailSlideTitle(),
57
- fields: ['email'],
58
- });
62
+ this.bigFormVc.updateSection(0, this.renderEmailSection());
59
63
  this.bigFormVc.setFooter({
60
64
  buttons: [this.renderLoginWithPhoneButton()],
61
65
  });
62
66
  });
63
67
  }
68
+ renderEmailSection() {
69
+ return {
70
+ title: this.renderEmailSlideTitle(),
71
+ fields: ['email'],
72
+ };
73
+ }
64
74
  renderLoginWithPhoneButton() {
65
75
  return {
66
76
  id: 'login-with-phone',
@@ -106,24 +116,33 @@ class LoginCardViewController extends AbstractViewController {
106
116
  id: this._id,
107
117
  schema: loginSchema,
108
118
  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,
119
+ sections: [this.renderFirstSection(), this.renderPinSection()],
120
+ footer: this.renderFooter(),
125
121
  }));
126
122
  }
123
+ renderFirstSection() {
124
+ if (!this.shouldAllowPhoneLogin) {
125
+ return this.renderEmailSection();
126
+ }
127
+ return this.renderPhoneSection();
128
+ }
129
+ renderPinSection() {
130
+ return {
131
+ title: randomUtil.rand([
132
+ 'Now the pin! 👇',
133
+ 'The pin is next!',
134
+ 'Time for pin.',
135
+ ]),
136
+ fields: [{ name: 'code', renderAs: 'number' }],
137
+ };
138
+ }
139
+ renderFooter() {
140
+ return this.shouldAllowEmailLogin && this.shouldAllowPhoneLogin
141
+ ? {
142
+ buttons: [this.renderLoginWithEmailButton()],
143
+ }
144
+ : null;
145
+ }
127
146
  renderPhoneSection() {
128
147
  var _a;
129
148
  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,20 @@ 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
+ });
22
+ }
23
+ this.shouldAllowPhoneLogin = shouldAllowPhoneLogin;
17
24
  this.shouldAllowEmailLogin = shouldAllowEmailLogin ?? false;
18
25
  this.loginHandler = onLogin;
19
26
  this.loginFailedHandler = onLoginFailed;
@@ -47,14 +54,17 @@ class LoginCardViewController extends Abstract_vc_1.default {
47
54
  };
48
55
  }
49
56
  async handleClickLoginWithEmail() {
50
- this.bigFormVc.updateSection(0, {
51
- title: this.renderEmailSlideTitle(),
52
- fields: ['email'],
53
- });
57
+ this.bigFormVc.updateSection(0, this.renderEmailSection());
54
58
  this.bigFormVc.setFooter({
55
59
  buttons: [this.renderLoginWithPhoneButton()],
56
60
  });
57
61
  }
62
+ renderEmailSection() {
63
+ return {
64
+ title: this.renderEmailSlideTitle(),
65
+ fields: ['email'],
66
+ };
67
+ }
58
68
  renderLoginWithPhoneButton() {
59
69
  return {
60
70
  id: 'login-with-phone',
@@ -98,24 +108,33 @@ class LoginCardViewController extends Abstract_vc_1.default {
98
108
  id: this._id,
99
109
  schema: loginSchema,
100
110
  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,
111
+ sections: [this.renderFirstSection(), this.renderPinSection()],
112
+ footer: this.renderFooter(),
117
113
  }));
118
114
  }
115
+ renderFirstSection() {
116
+ if (!this.shouldAllowPhoneLogin) {
117
+ return this.renderEmailSection();
118
+ }
119
+ return this.renderPhoneSection();
120
+ }
121
+ renderPinSection() {
122
+ return {
123
+ title: spruce_skill_utils_1.randomUtil.rand([
124
+ 'Now the pin! 👇',
125
+ 'The pin is next!',
126
+ 'Time for pin.',
127
+ ]),
128
+ fields: [{ name: 'code', renderAs: 'number' }],
129
+ };
130
+ }
131
+ renderFooter() {
132
+ return this.shouldAllowEmailLogin && this.shouldAllowPhoneLogin
133
+ ? {
134
+ buttons: [this.renderLoginWithEmailButton()],
135
+ }
136
+ : null;
137
+ }
119
138
  renderPhoneSection() {
120
139
  return {
121
140
  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.8",
16
+ "version": "126.11.0",
17
17
  "skill": {
18
18
  "namespace": "HeartwoodViewControllers",
19
19
  "commandOverrides": {
@@ -74,7 +74,7 @@
74
74
  "@babel/preset-env": "^7.28.3",
75
75
  "@babel/preset-typescript": "^7.27.1",
76
76
  "@babel/runtime": "^7.28.4",
77
- "@sprucelabs/calendar-utils": "^43.1.21",
77
+ "@sprucelabs/calendar-utils": "^43.1.22",
78
78
  "@sprucelabs/error": "^7.1.24",
79
79
  "@sprucelabs/globby": "^2.0.506",
80
80
  "@sprucelabs/mercury-core-events": "^27.2.3",
@@ -97,8 +97,8 @@
97
97
  "devDependencies": {
98
98
  "@sprucelabs/esm-postbuild": "^7.0.38",
99
99
  "@sprucelabs/jest-json-reporter": "^9.0.58",
100
- "@sprucelabs/mercury-client": "^43.0.143",
101
- "@sprucelabs/mercury-event-emitter": "^43.0.143",
100
+ "@sprucelabs/mercury-client": "^43.0.144",
101
+ "@sprucelabs/mercury-event-emitter": "^43.0.144",
102
102
  "@sprucelabs/resolve-path-aliases": "^3.0.26",
103
103
  "@sprucelabs/semantic-release": "^5.0.2",
104
104
  "@sprucelabs/test": "^10.0.22",