@sprucelabs/spruce-invite-utils 3.5.1 → 5.0.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.
@@ -1,12 +1,16 @@
1
+ import { SpruceSchemas } from '@sprucelabs/mercury-types';
1
2
  import { LoginAndConfirmJoinOptions, PromptForLoginAndConfirmOptions } from '../../loggingInAndConfirmingJoin/LoginAndConfirmJoinController';
2
3
  export default class LoginAndConfirmTestFixture {
3
4
  private static hitCount;
4
5
  private static wasBeforeEachCalled;
5
6
  static lastPromptOptions?: PromptForLoginAndConfirmOptions;
6
7
  static lastFactoryOptions?: LoginAndConfirmJoinOptions;
8
+ private static loginAndJoinResponse;
7
9
  static beforeEach(): void;
8
10
  static getHitCount(): number;
9
11
  private static assertBeforeEachWasCalled;
10
- static setResponse(r: boolean): void;
12
+ static setResponse(person: Person | null): void;
11
13
  private static setClass;
12
14
  }
15
+ declare type Person = SpruceSchemas.Spruce.v2020_07_22.Person;
16
+ export {};
@@ -1,15 +1,14 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  const test_1 = require("@sprucelabs/test");
7
- const LoginAndConfirmJoinController_1 = __importDefault(require("../../loggingInAndConfirmingJoin/LoginAndConfirmJoinController"));
4
+ const test_utils_1 = require("@sprucelabs/test-utils");
5
+ const LoginAndConfirmJoinController_1 = require("../../loggingInAndConfirmingJoin/LoginAndConfirmJoinController");
8
6
  class LoginAndConfirmTestFixture {
9
7
  static beforeEach() {
10
8
  this.setClass(CountingLoginAndConfirmController);
11
9
  this.hitCount = 0;
12
10
  this.wasBeforeEachCalled = true;
11
+ this.loginAndJoinResponse = undefined;
13
12
  }
14
13
  static getHitCount() {
15
14
  this.assertBeforeEachWasCalled();
@@ -18,33 +17,39 @@ class LoginAndConfirmTestFixture {
18
17
  static assertBeforeEachWasCalled() {
19
18
  test_1.assert.isTrue(this.wasBeforeEachCalled, `Make sure you call 'LoginAndConfirmTestFixture.beforeEach()' in your test!`);
20
19
  }
21
- static setResponse(r) {
20
+ static setResponse(person) {
22
21
  this.assertBeforeEachWasCalled();
23
- const Class = r
24
- ? PassingLoginAndConfirmController
22
+ const Class = person
23
+ ? CountingLoginAndConfirmController
25
24
  : FailingLoginAndConfirmController;
26
25
  this.setClass(Class);
26
+ this.loginAndJoinResponse = person;
27
27
  }
28
28
  static setClass(Class) {
29
- LoginAndConfirmJoinController_1.default.setClass(Class);
29
+ LoginAndConfirmJoinController_1.LoginAndConfirmJoinControllerFactory.setClass(Class);
30
30
  }
31
31
  }
32
32
  exports.default = LoginAndConfirmTestFixture;
33
33
  LoginAndConfirmTestFixture.hitCount = 0;
34
34
  LoginAndConfirmTestFixture.wasBeforeEachCalled = false;
35
+ LoginAndConfirmTestFixture.loginAndJoinResponse = undefined;
35
36
  class CountingLoginAndConfirmController {
36
37
  constructor(options) {
37
38
  LoginAndConfirmTestFixture.lastFactoryOptions = options;
39
+ this.auth = options.authenticator;
38
40
  }
39
41
  async promptForLoginAndConfirmJoin(options) {
40
42
  //@ts-ignore
41
43
  LoginAndConfirmTestFixture.hitCount++;
42
44
  LoginAndConfirmTestFixture.lastPromptOptions = options;
43
- return true;
44
- }
45
- }
46
- class PassingLoginAndConfirmController {
47
- async promptForLoginAndConfirmJoin() {
45
+ //@ts-ignore
46
+ const response = LoginAndConfirmTestFixture.loginAndJoinResponse;
47
+ if (response) {
48
+ this.auth.setSessionToken((0, test_utils_1.generateId)(), response);
49
+ }
50
+ else if (response === null) {
51
+ this.auth.clearSession();
52
+ }
48
53
  return true;
49
54
  }
50
55
  }
@@ -1,12 +1,16 @@
1
+ import { SpruceSchemas } from '@sprucelabs/mercury-types';
1
2
  import { LoginAndConfirmJoinOptions, PromptForLoginAndConfirmOptions } from '../../loggingInAndConfirmingJoin/LoginAndConfirmJoinController';
2
3
  export default class LoginAndConfirmTestFixture {
3
4
  private static hitCount;
4
5
  private static wasBeforeEachCalled;
5
6
  static lastPromptOptions?: PromptForLoginAndConfirmOptions;
6
7
  static lastFactoryOptions?: LoginAndConfirmJoinOptions;
8
+ private static loginAndJoinResponse;
7
9
  static beforeEach(): void;
8
10
  static getHitCount(): number;
9
11
  private static assertBeforeEachWasCalled;
10
- static setResponse(r: boolean): void;
12
+ static setResponse(person: Person | null): void;
11
13
  private static setClass;
12
14
  }
15
+ declare type Person = SpruceSchemas.Spruce.v2020_07_22.Person;
16
+ export {};
@@ -8,12 +8,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { assert } from '@sprucelabs/test';
11
- import LoginAndConfirmJoinControllerImpl from '../../loggingInAndConfirmingJoin/LoginAndConfirmJoinController.js';
11
+ import { generateId } from '@sprucelabs/test-utils';
12
+ import { LoginAndConfirmJoinControllerFactory, } from '../../loggingInAndConfirmingJoin/LoginAndConfirmJoinController.js';
12
13
  export default class LoginAndConfirmTestFixture {
13
14
  static beforeEach() {
14
15
  this.setClass(CountingLoginAndConfirmController);
15
16
  this.hitCount = 0;
16
17
  this.wasBeforeEachCalled = true;
18
+ this.loginAndJoinResponse = undefined;
17
19
  }
18
20
  static getHitCount() {
19
21
  this.assertBeforeEachWasCalled();
@@ -22,35 +24,39 @@ export default class LoginAndConfirmTestFixture {
22
24
  static assertBeforeEachWasCalled() {
23
25
  assert.isTrue(this.wasBeforeEachCalled, `Make sure you call 'LoginAndConfirmTestFixture.beforeEach()' in your test!`);
24
26
  }
25
- static setResponse(r) {
27
+ static setResponse(person) {
26
28
  this.assertBeforeEachWasCalled();
27
- const Class = r
28
- ? PassingLoginAndConfirmController
29
+ const Class = person
30
+ ? CountingLoginAndConfirmController
29
31
  : FailingLoginAndConfirmController;
30
32
  this.setClass(Class);
33
+ this.loginAndJoinResponse = person;
31
34
  }
32
35
  static setClass(Class) {
33
- LoginAndConfirmJoinControllerImpl.setClass(Class);
36
+ LoginAndConfirmJoinControllerFactory.setClass(Class);
34
37
  }
35
38
  }
36
39
  LoginAndConfirmTestFixture.hitCount = 0;
37
40
  LoginAndConfirmTestFixture.wasBeforeEachCalled = false;
41
+ LoginAndConfirmTestFixture.loginAndJoinResponse = undefined;
38
42
  class CountingLoginAndConfirmController {
39
43
  constructor(options) {
40
44
  LoginAndConfirmTestFixture.lastFactoryOptions = options;
45
+ this.auth = options.authenticator;
41
46
  }
42
47
  promptForLoginAndConfirmJoin(options) {
43
48
  return __awaiter(this, void 0, void 0, function* () {
44
49
  //@ts-ignore
45
50
  LoginAndConfirmTestFixture.hitCount++;
46
51
  LoginAndConfirmTestFixture.lastPromptOptions = options;
47
- return true;
48
- });
49
- }
50
- }
51
- class PassingLoginAndConfirmController {
52
- promptForLoginAndConfirmJoin() {
53
- return __awaiter(this, void 0, void 0, function* () {
52
+ //@ts-ignore
53
+ const response = LoginAndConfirmTestFixture.loginAndJoinResponse;
54
+ if (response) {
55
+ this.auth.setSessionToken(generateId(), response);
56
+ }
57
+ else if (response === null) {
58
+ this.auth.clearSession();
59
+ }
54
60
  return true;
55
61
  });
56
62
  }
@@ -1,5 +1,5 @@
1
1
  export { default as buildRouteToCreateInvite } from './sending/buildRouteToCreateInvite';
2
- export { default as LoginAndConfirmJoinController } from './loggingInAndConfirmingJoin/LoginAndConfirmJoinController';
2
+ export { default as LoginAndConfirmJoinControllerImpl } from './loggingInAndConfirmingJoin/LoginAndConfirmJoinController';
3
3
  export * from './loggingInAndConfirmingJoin/LoginAndConfirmJoinController';
4
4
  export { default as LoginAndConfirmTestFixture } from './__tests__/support/LoginAndConfirmTestFixture';
5
5
  export * from './__tests__/support/LoginAndConfirmTestFixture';
@@ -1,5 +1,5 @@
1
1
  export { default as buildRouteToCreateInvite } from './sending/buildRouteToCreateInvite.js';
2
- export { default as LoginAndConfirmJoinController } from './loggingInAndConfirmingJoin/LoginAndConfirmJoinController.js';
2
+ export { default as LoginAndConfirmJoinControllerImpl } from './loggingInAndConfirmingJoin/LoginAndConfirmJoinController.js';
3
3
  export * from './loggingInAndConfirmingJoin/LoginAndConfirmJoinController.js';
4
4
  export { default as LoginAndConfirmTestFixture } from './__tests__/support/LoginAndConfirmTestFixture.js';
5
5
  export * from './__tests__/support/LoginAndConfirmTestFixture.js';
@@ -1,19 +1,21 @@
1
1
  import { Authenticator, CardViewControllerImpl, ViewControllerFactory } from '@sprucelabs/heartwood-view-controllers';
2
2
  import { MercuryClient } from '@sprucelabs/mercury-client';
3
+ export declare class LoginAndConfirmJoinControllerFactory {
4
+ private static Class?;
5
+ static setClass(Class?: LoginAndConfirmJoinConstructor): void;
6
+ static Controller(options: LoginAndConfirmJoinOptions): LoginAndConfirmJoinController;
7
+ }
3
8
  export default class LoginAndConfirmJoinControllerImpl implements LoginAndConfirmJoinController {
4
9
  private views;
5
10
  protected vc: CardViewControllerImpl;
6
11
  private authenticator;
7
12
  private dialog?;
8
- private static Class?;
9
13
  private organizationId;
10
14
  private connectToApi;
11
15
  private client;
12
16
  private locationId?;
13
17
  private confirmJoinContext?;
14
- protected constructor(options: LoginAndConfirmJoinOptions);
15
- static setClass(Class?: LoginAndConfirmJoinConstructor): void;
16
- static Controller(options: LoginAndConfirmJoinOptions): LoginAndConfirmJoinController;
18
+ constructor(options: LoginAndConfirmJoinOptions);
17
19
  promptForLoginAndConfirmJoin(options?: PromptForLoginAndConfirmOptions): Promise<boolean>;
18
20
  private listRoles;
19
21
  private confirmTheJoin;
@@ -9,16 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import { assertOptions } from '@sprucelabs/schema';
11
11
  import ConfirmJoinCardViewController from '../accepting/ConfirmJoinCard.vc.js';
12
- export default class LoginAndConfirmJoinControllerImpl {
13
- constructor(options) {
14
- const { views, authenticator, organizationId, connectToApi, locationId } = options;
15
- this.views = views;
16
- this.authenticator = authenticator;
17
- this.organizationId = organizationId;
18
- this.connectToApi = connectToApi;
19
- this.locationId = locationId;
20
- this.vc = this.views.Controller('card', {});
21
- }
12
+ export class LoginAndConfirmJoinControllerFactory {
22
13
  static setClass(Class) {
23
14
  this.Class = Class;
24
15
  }
@@ -33,7 +24,18 @@ export default class LoginAndConfirmJoinControllerImpl {
33
24
  if (!views.hasController('invite.confirm-join-card')) {
34
25
  views.setController('invite.confirm-join-card', ConfirmJoinCardViewController);
35
26
  }
36
- return new ((_a = this.Class) !== null && _a !== void 0 ? _a : this)(options);
27
+ return new ((_a = this.Class) !== null && _a !== void 0 ? _a : LoginAndConfirmJoinControllerImpl)(options);
28
+ }
29
+ }
30
+ export default class LoginAndConfirmJoinControllerImpl {
31
+ constructor(options) {
32
+ const { views, authenticator, organizationId, connectToApi, locationId } = options;
33
+ this.views = views;
34
+ this.authenticator = authenticator;
35
+ this.organizationId = organizationId;
36
+ this.connectToApi = connectToApi;
37
+ this.locationId = locationId;
38
+ this.vc = this.views.Controller('card', {});
37
39
  }
38
40
  promptForLoginAndConfirmJoin(options) {
39
41
  return __awaiter(this, void 0, void 0, function* () {
@@ -1,5 +1,5 @@
1
1
  export { default as buildRouteToCreateInvite } from './sending/buildRouteToCreateInvite';
2
- export { default as LoginAndConfirmJoinController } from './loggingInAndConfirmingJoin/LoginAndConfirmJoinController';
2
+ export { default as LoginAndConfirmJoinControllerImpl } from './loggingInAndConfirmingJoin/LoginAndConfirmJoinController';
3
3
  export * from './loggingInAndConfirmingJoin/LoginAndConfirmJoinController';
4
4
  export { default as LoginAndConfirmTestFixture } from './__tests__/support/LoginAndConfirmTestFixture';
5
5
  export * from './__tests__/support/LoginAndConfirmTestFixture';
@@ -17,11 +17,11 @@ 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.LoginAndConfirmTestFixture = exports.LoginAndConfirmJoinController = exports.buildRouteToCreateInvite = void 0;
20
+ exports.LoginAndConfirmTestFixture = exports.LoginAndConfirmJoinControllerImpl = exports.buildRouteToCreateInvite = void 0;
21
21
  var buildRouteToCreateInvite_1 = require("./sending/buildRouteToCreateInvite");
22
22
  Object.defineProperty(exports, "buildRouteToCreateInvite", { enumerable: true, get: function () { return __importDefault(buildRouteToCreateInvite_1).default; } });
23
23
  var LoginAndConfirmJoinController_1 = require("./loggingInAndConfirmingJoin/LoginAndConfirmJoinController");
24
- Object.defineProperty(exports, "LoginAndConfirmJoinController", { enumerable: true, get: function () { return __importDefault(LoginAndConfirmJoinController_1).default; } });
24
+ Object.defineProperty(exports, "LoginAndConfirmJoinControllerImpl", { enumerable: true, get: function () { return __importDefault(LoginAndConfirmJoinController_1).default; } });
25
25
  __exportStar(require("./loggingInAndConfirmingJoin/LoginAndConfirmJoinController"), exports);
26
26
  var LoginAndConfirmTestFixture_1 = require("./__tests__/support/LoginAndConfirmTestFixture");
27
27
  Object.defineProperty(exports, "LoginAndConfirmTestFixture", { enumerable: true, get: function () { return __importDefault(LoginAndConfirmTestFixture_1).default; } });
@@ -1,19 +1,21 @@
1
1
  import { Authenticator, CardViewControllerImpl, ViewControllerFactory } from '@sprucelabs/heartwood-view-controllers';
2
2
  import { MercuryClient } from '@sprucelabs/mercury-client';
3
+ export declare class LoginAndConfirmJoinControllerFactory {
4
+ private static Class?;
5
+ static setClass(Class?: LoginAndConfirmJoinConstructor): void;
6
+ static Controller(options: LoginAndConfirmJoinOptions): LoginAndConfirmJoinController;
7
+ }
3
8
  export default class LoginAndConfirmJoinControllerImpl implements LoginAndConfirmJoinController {
4
9
  private views;
5
10
  protected vc: CardViewControllerImpl;
6
11
  private authenticator;
7
12
  private dialog?;
8
- private static Class?;
9
13
  private organizationId;
10
14
  private connectToApi;
11
15
  private client;
12
16
  private locationId?;
13
17
  private confirmJoinContext?;
14
- protected constructor(options: LoginAndConfirmJoinOptions);
15
- static setClass(Class?: LoginAndConfirmJoinConstructor): void;
16
- static Controller(options: LoginAndConfirmJoinOptions): LoginAndConfirmJoinController;
18
+ constructor(options: LoginAndConfirmJoinOptions);
17
19
  promptForLoginAndConfirmJoin(options?: PromptForLoginAndConfirmOptions): Promise<boolean>;
18
20
  private listRoles;
19
21
  private confirmTheJoin;
@@ -3,18 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.LoginAndConfirmJoinControllerFactory = void 0;
6
7
  const schema_1 = require("@sprucelabs/schema");
7
8
  const ConfirmJoinCard_vc_1 = __importDefault(require("../accepting/ConfirmJoinCard.vc"));
8
- class LoginAndConfirmJoinControllerImpl {
9
- constructor(options) {
10
- const { views, authenticator, organizationId, connectToApi, locationId } = options;
11
- this.views = views;
12
- this.authenticator = authenticator;
13
- this.organizationId = organizationId;
14
- this.connectToApi = connectToApi;
15
- this.locationId = locationId;
16
- this.vc = this.views.Controller('card', {});
17
- }
9
+ class LoginAndConfirmJoinControllerFactory {
18
10
  static setClass(Class) {
19
11
  this.Class = Class;
20
12
  }
@@ -29,7 +21,19 @@ class LoginAndConfirmJoinControllerImpl {
29
21
  if (!views.hasController('invite.confirm-join-card')) {
30
22
  views.setController('invite.confirm-join-card', ConfirmJoinCard_vc_1.default);
31
23
  }
32
- return new ((_a = this.Class) !== null && _a !== void 0 ? _a : this)(options);
24
+ return new ((_a = this.Class) !== null && _a !== void 0 ? _a : LoginAndConfirmJoinControllerImpl)(options);
25
+ }
26
+ }
27
+ exports.LoginAndConfirmJoinControllerFactory = LoginAndConfirmJoinControllerFactory;
28
+ class LoginAndConfirmJoinControllerImpl {
29
+ constructor(options) {
30
+ const { views, authenticator, organizationId, connectToApi, locationId } = options;
31
+ this.views = views;
32
+ this.authenticator = authenticator;
33
+ this.organizationId = organizationId;
34
+ this.connectToApi = connectToApi;
35
+ this.locationId = locationId;
36
+ this.vc = this.views.Controller('card', {});
33
37
  }
34
38
  async promptForLoginAndConfirmJoin(options) {
35
39
  this.client = await this.connectToApi();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sprucelabs/spruce-invite-utils",
3
3
  "description": "Invite Utilities",
4
- "version": "3.5.1",
4
+ "version": "5.0.1",
5
5
  "skill": {
6
6
  "namespace": "invite"
7
7
  },