@sprucelabs/spruce-test-fixtures 62.3.44 → 62.3.45

Sign up to get free protection for your applications and to get access to all the features.
@@ -27,7 +27,7 @@ function login(phone) {
27
27
  Class.beforeEach = async () => {
28
28
  Class.Fixture('view').setProxyTokenGenerator(proxyGenerator);
29
29
  __1.MercuryFixture.setDefaultContractToLocalEventsIfExist(Class.cwd);
30
- await (beforeEach === null || beforeEach === void 0 ? void 0 : beforeEach());
30
+ await beforeEach?.();
31
31
  };
32
32
  const afterAll = Class.afterAll.bind(Class);
33
33
  Class.afterAll = async () => {
@@ -35,7 +35,7 @@ function login(phone) {
35
35
  await emitWillLogout(client);
36
36
  __1.MercuryFixture.clearDefaultClient();
37
37
  await afterAll();
38
- await (client === null || client === void 0 ? void 0 : client.disconnect());
38
+ await client?.disconnect();
39
39
  };
40
40
  };
41
41
  }
@@ -61,17 +61,15 @@ login.on = async (name, cb) => {
61
61
  login.listeners[name] = cb;
62
62
  };
63
63
  async function emitDidLogin(client) {
64
- var _a;
65
64
  //@ts-ignore
66
- let didLogin = (_a = login === null || login === void 0 ? void 0 : login.listeners) === null || _a === void 0 ? void 0 : _a['did-login'];
65
+ let didLogin = login?.listeners?.['did-login'];
67
66
  if (didLogin) {
68
67
  await didLogin(client);
69
68
  }
70
69
  }
71
70
  async function emitWillLogout(client) {
72
- var _a;
73
71
  //@ts-ignore
74
- let willLogout = (_a = login === null || login === void 0 ? void 0 : login.listeners) === null || _a === void 0 ? void 0 : _a['will-logout'];
72
+ let willLogout = login?.listeners?.['will-logout'];
75
73
  if (willLogout) {
76
74
  await willLogout(client);
77
75
  }
@@ -10,7 +10,6 @@ const StoreFixture_1 = __importDefault(require("../fixtures/StoreFixture"));
10
10
  const login_1 = __importDefault(require("./login"));
11
11
  function seed(storeName, totalToSeed, ...params) {
12
12
  return function (Class, key, descriptor) {
13
- var _a, _b;
14
13
  if ((storeName === 'organizations' || storeName === 'locations') &&
15
14
  !Class.beforeAll.__patched) {
16
15
  const beforeAll = Class.beforeAll.bind(Class);
@@ -33,12 +32,12 @@ function seed(storeName, totalToSeed, ...params) {
33
32
  StoreFixture_1.default.setShouldAutomaticallyResetDatabase(false);
34
33
  StoreFixture_1.default.resetDbConnectionSettings();
35
34
  const seed = attachSeeder(storeName, Class, totalToSeed, params);
36
- const bound = (_b = (_a = descriptor === null || descriptor === void 0 ? void 0 : descriptor.value) === null || _a === void 0 ? void 0 : _a.bind) === null || _b === void 0 ? void 0 : _b.call(_a, Class);
35
+ const bound = descriptor?.value?.bind?.(Class);
37
36
  attachCleanup(Class);
38
37
  descriptor.value = async (...args) => {
39
38
  await optionallyReset(Class, key);
40
39
  await seed();
41
- await (bound === null || bound === void 0 ? void 0 : bound(...args));
40
+ await bound?.(...args);
42
41
  };
43
42
  };
44
43
  }
@@ -71,18 +70,17 @@ function attachCleanup(Class) {
71
70
  const afterEach = Class.afterEach.bind(Class);
72
71
  const beforeEach = Class.beforeEach.bind(Class);
73
72
  Class.afterEach = async () => {
74
- await (afterEach === null || afterEach === void 0 ? void 0 : afterEach());
73
+ await afterEach?.();
75
74
  shouldResetTestClient && mercury_client_1.MercuryTestClient.reset();
76
75
  delete Class.__lastReset;
77
76
  };
78
77
  Class.beforeEach = async () => {
79
78
  await optionallyReset(Class, 'beforeEach');
80
- await (beforeEach === null || beforeEach === void 0 ? void 0 : beforeEach());
79
+ await beforeEach?.();
81
80
  };
82
81
  }
83
82
  }
84
83
  function attachSeeder(storeName, TestClass, totalToSeed, params) {
85
- var _a, _b, _c;
86
84
  //@ts-ignore
87
85
  const fixtureMap = {
88
86
  locations: 'seed',
@@ -113,9 +111,9 @@ function attachSeeder(storeName, TestClass, totalToSeed, params) {
113
111
  managers: 'totalManagers',
114
112
  owners: 'totalOwners',
115
113
  };
116
- const method = (_a = methodMap[storeName]) !== null && _a !== void 0 ? _a : 'seed';
117
- const optionsKey = (_b = keyMap[storeName]) !== null && _b !== void 0 ? _b : 'totalToSeed';
118
- const fixtureName = (_c = fixtureMap[storeName]) !== null && _c !== void 0 ? _c : 'store';
114
+ const method = methodMap[storeName] ?? 'seed';
115
+ const optionsKey = keyMap[storeName] ?? 'totalToSeed';
116
+ const fixtureName = fixtureMap[storeName] ?? 'store';
119
117
  const options = { [optionsKey]: totalToSeed };
120
118
  return async function () {
121
119
  let fixture = TestClass.Fixture(fixtureName);
@@ -127,7 +125,7 @@ function attachSeeder(storeName, TestClass, totalToSeed, params) {
127
125
  TestClass.__shouldResetAccount = true;
128
126
  }
129
127
  test_utils_1.assert.isFunction(fixture[method], `The '${storeName}' store you created needs a method called 'seed(options: StoreSeedOptions)' in order for seeding. You must implement it yourself... for now.`);
130
- const args = [options, ...(params !== null && params !== void 0 ? params : [])];
128
+ const args = [options, ...(params ?? [])];
131
129
  await fixture[method](...args);
132
130
  };
133
131
  }
@@ -10,10 +10,11 @@ const eventFaker = {
10
10
  const client = getClient(fqen);
11
11
  await client.off(fqen);
12
12
  await client.on(fqen, () => {
13
- throw (error !== null && error !== void 0 ? error : new SpruceError_1.default({
14
- code: 'FAKE_EVENT_ERROR',
15
- fqen,
16
- }));
13
+ throw (error ??
14
+ new SpruceError_1.default({
15
+ code: 'FAKE_EVENT_ERROR',
16
+ fqen,
17
+ }));
17
18
  });
18
19
  },
19
20
  async handleReactiveEvent(fqen) {
@@ -38,7 +38,6 @@ class FixtureFactory {
38
38
  this.namespace = namespace;
39
39
  }
40
40
  Fixture(named, options) {
41
- var _a, _b, _c, _d, _e;
42
41
  const mercuryFixture = this.getMercuryFixture(named);
43
42
  let fixture;
44
43
  switch (named) {
@@ -63,9 +62,10 @@ class FixtureFactory {
63
62
  case 'organization': {
64
63
  const people =
65
64
  //@ts-ignore
66
- (_a = options === null || options === void 0 ? void 0 : options.people) !== null && _a !== void 0 ? _a : new PersonFixture_1.default({
67
- connectToApi: mercuryFixture.getConnectFactory(),
68
- });
65
+ options?.people ??
66
+ new PersonFixture_1.default({
67
+ connectToApi: mercuryFixture.getConnectFactory(),
68
+ });
69
69
  fixture = new OrganizationFixture_1.default({
70
70
  people,
71
71
  roles: this.Fixture('role'),
@@ -75,7 +75,7 @@ class FixtureFactory {
75
75
  case 'skill': {
76
76
  const personFixture =
77
77
  //@ts-ignore
78
- (_b = options === null || options === void 0 ? void 0 : options.personFixture) !== null && _b !== void 0 ? _b : this.Fixture('person');
78
+ options?.personFixture ?? this.Fixture('person');
79
79
  fixture = new SkillFixture_1.default({
80
80
  personFixture,
81
81
  connectToApi: mercuryFixture.getConnectFactory(),
@@ -94,10 +94,10 @@ class FixtureFactory {
94
94
  fixture = new LocationFixture_1.default({
95
95
  roles: this.Fixture('role'),
96
96
  //@ts-ignore
97
- people: (_c = options === null || options === void 0 ? void 0 : options.people) !== null && _c !== void 0 ? _c : this.Fixture('person'),
97
+ people: options?.people ?? this.Fixture('person'),
98
98
  organizations:
99
99
  //@ts-ignore
100
- (_d = options === null || options === void 0 ? void 0 : options.organizations) !== null && _d !== void 0 ? _d : this.Fixture('organization'),
100
+ options?.organizations ?? this.Fixture('organization'),
101
101
  });
102
102
  break;
103
103
  }
@@ -115,9 +115,17 @@ class FixtureFactory {
115
115
  if (!this.namespace) {
116
116
  throw new Error('You need to be in a registered skill to load view controllers.');
117
117
  }
118
- fixture = new ViewFixture_1.default(Object.assign({
118
+ fixture = new ViewFixture_1.default({
119
119
  //@ts-ignore
120
- people: (_e = options === null || options === void 0 ? void 0 : options.personFixture) !== null && _e !== void 0 ? _e : this.Fixture('person'), connectToApi: mercuryFixture.getConnectFactory(), fixtureFactory: this, namespace: this.namespace, proxyDecorator: __1.ClientProxyDecorator.getInstance(), cwd: this.cwd, permissions: this.Fixture('permission') }, options));
120
+ people: options?.personFixture ?? this.Fixture('person'),
121
+ connectToApi: mercuryFixture.getConnectFactory(),
122
+ fixtureFactory: this,
123
+ namespace: this.namespace,
124
+ proxyDecorator: __1.ClientProxyDecorator.getInstance(),
125
+ cwd: this.cwd,
126
+ permissions: this.Fixture('permission'),
127
+ ...options,
128
+ });
121
129
  break;
122
130
  }
123
131
  }
@@ -1,15 +1,4 @@
1
1
  "use strict";
2
- var __rest = (this && this.__rest) || function (s, e) {
3
- var t = {};
4
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
- t[p] = s[p];
6
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
- t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
2
  Object.defineProperty(exports, "__esModule", { value: true });
14
3
  const spruce_event_utils_1 = require("@sprucelabs/spruce-event-utils");
15
4
  const test_utils_1 = require("@sprucelabs/test-utils");
@@ -22,18 +11,17 @@ class LocationFixture {
22
11
  this.roles = options.roles;
23
12
  }
24
13
  async seedDemoLocation(values) {
25
- var _a, _b, _c;
26
- const { client } = await this.people.loginAsDemoPerson((_a = values === null || values === void 0 ? void 0 : values.phone) !== null && _a !== void 0 ? _a : undefined);
27
- let _d = values !== null && values !== void 0 ? values : {}, { organizationId: orgId } = _d, rest = __rest(_d, ["organizationId"]);
14
+ const { client } = await this.people.loginAsDemoPerson(values?.phone ?? undefined);
15
+ let { organizationId: orgId, ...rest } = values ?? {};
28
16
  if (!orgId) {
29
- const last = await this.orgs.getNewestOrganization((_b = values === null || values === void 0 ? void 0 : values.phone) !== null && _b !== void 0 ? _b : undefined);
17
+ const last = await this.orgs.getNewestOrganization(values?.phone ?? undefined);
30
18
  if (last) {
31
19
  orgId = last.id;
32
20
  }
33
21
  else {
34
22
  const org = await this.orgs.seedDemoOrganization({
35
23
  name: 'Org to support seed location',
36
- phone: (_c = values === null || values === void 0 ? void 0 : values.phone) !== null && _c !== void 0 ? _c : undefined,
24
+ phone: values?.phone ?? undefined,
37
25
  });
38
26
  orgId = org.id;
39
27
  }
@@ -42,13 +30,19 @@ class LocationFixture {
42
30
  target: {
43
31
  organizationId: orgId,
44
32
  },
45
- payload: Object.assign({ name: `Location ${LocationFixture.locationCount++} - ${(0, test_utils_2.generateId)()}`, slug: this.generateLocationSlug(), isPublic: true, address: {
33
+ payload: {
34
+ name: `Location ${LocationFixture.locationCount++} - ${(0, test_utils_2.generateId)()}`,
35
+ slug: this.generateLocationSlug(),
36
+ isPublic: true,
37
+ address: {
46
38
  street1: '123 Main St',
47
39
  city: 'Denver',
48
40
  province: 'CO',
49
41
  zip: '80211',
50
42
  country: 'USA',
51
- } }, rest),
43
+ },
44
+ ...rest,
45
+ },
52
46
  });
53
47
  const { location } = spruce_event_utils_1.eventResponseUtil.getFirstResponseOrThrow(results);
54
48
  return location;
@@ -68,7 +62,6 @@ class LocationFixture {
68
62
  return location;
69
63
  }
70
64
  async getNewestLocation(organizationId) {
71
- var _a;
72
65
  const { client } = await this.people.loginAsDemoPerson();
73
66
  if (!organizationId) {
74
67
  const org = await this.orgs.getNewestOrganization();
@@ -86,7 +79,7 @@ class LocationFixture {
86
79
  },
87
80
  });
88
81
  const { locations } = spruce_event_utils_1.eventResponseUtil.getFirstResponseOrThrow(results);
89
- return (_a = locations.pop()) !== null && _a !== void 0 ? _a : null;
82
+ return locations.pop() ?? null;
90
83
  }
91
84
  async listLocations(organizationId) {
92
85
  const { client } = await this.people.loginAsDemoPerson();
@@ -95,7 +88,7 @@ class LocationFixture {
95
88
  if (!org) {
96
89
  throw new Error(`You have to @seed('organizations',1) before you can list locations.`);
97
90
  }
98
- organizationId = org === null || org === void 0 ? void 0 : org.id;
91
+ organizationId = org?.id;
99
92
  }
100
93
  const results = await client.emit('list-locations::v2020_12_25', {
101
94
  target: {
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
- var _a;
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
3
  const mercury_client_1 = require("@sprucelabs/mercury-client");
5
4
  require("@sprucelabs/mercury-core-events");
@@ -9,7 +8,7 @@ const spruce_event_utils_1 = require("@sprucelabs/spruce-event-utils");
9
8
  const spruce_skill_utils_1 = require("@sprucelabs/spruce-skill-utils");
10
9
  const env = require('dotenv');
11
10
  env.config();
12
- const TEST_HOST = (_a = process.env.TEST_HOST) !== null && _a !== void 0 ? _a : process.env.HOST;
11
+ const TEST_HOST = process.env.TEST_HOST ?? process.env.HOST;
13
12
  class MercuryFixture {
14
13
  static setDefaultClient(client) {
15
14
  //@ts-ignore
@@ -38,7 +37,7 @@ class MercuryFixture {
38
37
  this.connectToApi = this.connectToApi.bind(this);
39
38
  }
40
39
  async connectToApi(options) {
41
- const shouldReUseClient = (options === null || options === void 0 ? void 0 : options.shouldReUseClient) !== false;
40
+ const shouldReUseClient = options?.shouldReUseClient !== false;
42
41
  if (shouldReUseClient && MercuryFixture.defaultClient) {
43
42
  return MercuryFixture.defaultClient;
44
43
  }
@@ -63,7 +62,6 @@ class MercuryFixture {
63
62
  return promise;
64
63
  }
65
64
  static setDefaultContractToLocalEventsIfExist(cwd) {
66
- var _a;
67
65
  if (MercuryFixture.shouldAutoImportContracts &&
68
66
  spruce_skill_utils_1.diskUtil.doesBuiltHashSprucePathExist(cwd)) {
69
67
  try {
@@ -79,7 +77,7 @@ class MercuryFixture {
79
77
  }
80
78
  catch (err) {
81
79
  //since we default to the
82
- if (((_a = err.options) === null || _a === void 0 ? void 0 : _a.code) === 'EVENT_CONTRACTS_NOT_SYNCED') {
80
+ if (err.options?.code === 'EVENT_CONTRACTS_NOT_SYNCED') {
83
81
  MercuryFixture.setDefaultContract(mercury_core_events_1.coreEventContracts[0]);
84
82
  return;
85
83
  }
@@ -92,11 +90,10 @@ class MercuryFixture {
92
90
  }
93
91
  }
94
92
  static setDefaultContract(contract) {
95
- var _a;
96
93
  //@ts-ignore
97
94
  mercury_client_1.MercuryClientFactory.setDefaultContract(contract);
98
95
  //@ts-ignore
99
- (_a = mercury_client_1.MercuryTestClient.emitter) === null || _a === void 0 ? void 0 : _a.mixinOnlyUniqueSignatures(contract);
96
+ mercury_client_1.MercuryTestClient.emitter?.mixinOnlyUniqueSignatures(contract);
100
97
  }
101
98
  getConnectFactory() {
102
99
  return this.connectToApi;
@@ -112,12 +109,10 @@ class MercuryFixture {
112
109
  this.clientPromises = [];
113
110
  }
114
111
  static beforeAll() {
115
- var _a, _b;
116
112
  this.originalHost =
117
- (_b = (_a = process.env.TEST_HOST) !== null && _a !== void 0 ? _a : process.env.HOST) !== null && _b !== void 0 ? _b : TEST_HOST;
113
+ process.env.TEST_HOST ?? process.env.HOST ?? TEST_HOST;
118
114
  }
119
115
  static async beforeEach(cwd) {
120
- var _a;
121
116
  if (this.originalHost) {
122
117
  process.env.HOST = this.originalHost;
123
118
  }
@@ -133,14 +128,14 @@ class MercuryFixture {
133
128
  this.setDefaultContractToLocalEventsIfExist(cwd);
134
129
  try {
135
130
  const auth = spruce_skill_utils_1.AuthService.Auth(cwd);
136
- const namespace = (_a = auth.getCurrentSkill()) === null || _a === void 0 ? void 0 : _a.slug;
131
+ const namespace = auth.getCurrentSkill()?.slug;
137
132
  if (namespace) {
138
133
  mercury_client_1.MercuryTestClient.setNamespacesThatMustBeHandledLocally([
139
134
  namespace,
140
135
  ]);
141
136
  }
142
137
  }
143
- catch (_b) { }
138
+ catch { }
144
139
  }
145
140
  static setShouldRequireLocalListeners(shouldRequireLocal) {
146
141
  this.shouldRequireLocalListeners = shouldRequireLocal;
@@ -1,15 +1,4 @@
1
1
  "use strict";
2
- var __rest = (this && this.__rest) || function (s, e) {
3
- var t = {};
4
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
- t[p] = s[p];
6
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
- t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
2
  Object.defineProperty(exports, "__esModule", { value: true });
14
3
  const schema_1 = require("@sprucelabs/schema");
15
4
  class OrganizationFixture {
@@ -20,14 +9,19 @@ class OrganizationFixture {
20
9
  this.roles = options.roles;
21
10
  }
22
11
  async seedDemoOrganization(values) {
23
- const _a = values !== null && values !== void 0 ? values : {}, { phone } = _a, rest = __rest(_a, ["phone"]);
24
- const allValues = Object.assign({ slug: this.generateOrgSlug(), name: `Organization from fixture - ${new Date().getTime() * Math.random()}`, address: {
12
+ const { phone, ...rest } = values ?? {};
13
+ const allValues = {
14
+ slug: this.generateOrgSlug(),
15
+ name: `Organization from fixture - ${new Date().getTime() * Math.random()}`,
16
+ address: {
25
17
  street1: `${Math.round(Math.random() * 9999)} Main St.`,
26
18
  city: 'Denver',
27
19
  province: 'CO',
28
20
  zip: '80212',
29
21
  country: 'USA',
30
- } }, rest);
22
+ },
23
+ ...rest,
24
+ };
31
25
  const { client } = await this.people.loginAsDemoPerson(phone);
32
26
  const [{ organization }] = await client.emitAndFlattenResponses('create-organization::v2020_12_25', {
33
27
  payload: allValues,
@@ -45,7 +39,7 @@ class OrganizationFixture {
45
39
  return organization;
46
40
  }
47
41
  async updateOrganization(id, values) {
48
- const { phone } = values, payload = __rest(values, ["phone"]);
42
+ const { phone, ...payload } = values;
49
43
  const { client } = await this.people.loginAsDemoPerson(phone);
50
44
  await client.emitAndFlattenResponses('update-organization::v2020_12_25', {
51
45
  target: {
@@ -55,7 +49,6 @@ class OrganizationFixture {
55
49
  });
56
50
  }
57
51
  async getNewestOrganization(phone) {
58
- var _a;
59
52
  const { client } = await this.people.loginAsDemoPerson(phone);
60
53
  const [{ organizations }] = await client.emitAndFlattenResponses('list-organizations::v2020_12_25', {
61
54
  payload: {
@@ -65,7 +58,7 @@ class OrganizationFixture {
65
58
  },
66
59
  },
67
60
  });
68
- return (_a = organizations.pop()) !== null && _a !== void 0 ? _a : null;
61
+ return organizations.pop() ?? null;
69
62
  }
70
63
  generateOrgSlug() {
71
64
  return `my-org-${new Date().getTime()}-${this.orgCounter++}`;
@@ -83,7 +76,9 @@ class OrganizationFixture {
83
76
  });
84
77
  }
85
78
  async isPartOfOrg(options) {
86
- const roles = await this.roles.listRoles(Object.assign({}, options));
79
+ const roles = await this.roles.listRoles({
80
+ ...options,
81
+ });
87
82
  return roles.length > 0;
88
83
  }
89
84
  async removePerson(options) {
@@ -1,15 +1,4 @@
1
1
  "use strict";
2
- var __rest = (this && this.__rest) || function (s, e) {
3
- var t = {};
4
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
- t[p] = s[p];
6
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
- t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
14
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
4
  };
@@ -23,14 +12,16 @@ class PersonFixture {
23
12
  this.connectToApi = options.connectToApi;
24
13
  }
25
14
  async listPeople(options) {
26
- const { organizationId, locationId } = options, rest = __rest(options, ["organizationId", "locationId"]);
15
+ const { organizationId, locationId, ...rest } = options;
27
16
  const { client } = await this.loginAsDemoPerson();
28
17
  const [{ people }] = await client.emitAndFlattenResponses('list-people::v2020_12_25', {
29
18
  target: {
30
19
  organizationId,
31
20
  locationId,
32
21
  },
33
- payload: Object.assign({}, rest),
22
+ payload: {
23
+ ...rest,
24
+ },
34
25
  });
35
26
  return people;
36
27
  }
@@ -39,10 +30,9 @@ class PersonFixture {
39
30
  const [{ person }] = await client.emitAndFlattenResponses('update-person::v2020_12_25', {
40
31
  payload: values,
41
32
  });
42
- return Object.assign(Object.assign({}, person), values);
33
+ return { ...person, ...values };
43
34
  }
44
35
  async loginAsDemoPerson(phone) {
45
- var _a, _b, _c;
46
36
  if (this.lastLoggedIn &&
47
37
  (!phone ||
48
38
  (0, schema_1.formatPhoneNumber)(phone) === this.lastLoggedIn.person.phone)) {
@@ -51,14 +41,14 @@ class PersonFixture {
51
41
  const client = (await this.connectToApi({
52
42
  shouldReUseClient: !phone,
53
43
  }));
54
- if ((_a = client.auth) === null || _a === void 0 ? void 0 : _a.person) {
44
+ if (client.auth?.person) {
55
45
  return {
56
46
  client,
57
47
  person: client.auth.person,
58
48
  token: client.auth.token,
59
49
  };
60
50
  }
61
- let p = phone !== null && phone !== void 0 ? phone : process.env.DEMO_NUMBER;
51
+ let p = phone ?? process.env.DEMO_NUMBER;
62
52
  if (!p || p.length === 0) {
63
53
  throw new schema_1.SchemaError({
64
54
  code: 'MISSING_PARAMETERS',
@@ -68,7 +58,7 @@ class PersonFixture {
68
58
  }
69
59
  const formattedPhone = (0, schema_1.formatPhoneNumber)(p);
70
60
  //@ts-ignore
71
- if (((_c = (_b = client.auth) === null || _b === void 0 ? void 0 : _b.person) === null || _c === void 0 ? void 0 : _c.phone) === formattedPhone) {
61
+ if (client.auth?.person?.phone === formattedPhone) {
72
62
  return {
73
63
  client,
74
64
  person: client.auth.person,
@@ -9,11 +9,11 @@ class RoleFixture {
9
9
  this.getNewestOrgHandler = options.getNewestOrg;
10
10
  }
11
11
  async listRoles(options) {
12
- let { organizationId, locationId, personId, phone, shouldIncludeMetaRoles, } = options !== null && options !== void 0 ? options : {};
12
+ let { organizationId, locationId, personId, phone, shouldIncludeMetaRoles, } = options ?? {};
13
13
  const { client } = await this.personFixture.loginAsDemoPerson(phone);
14
14
  if (!organizationId && !locationId) {
15
15
  const latest = await this.getNewestOrgHandler();
16
- organizationId = latest === null || latest === void 0 ? void 0 : latest.id;
16
+ organizationId = latest?.id;
17
17
  }
18
18
  if (!organizationId && !locationId) {
19
19
  throw new schema_1.SchemaError({
@@ -15,35 +15,45 @@ class SeedFixture {
15
15
  this.people = options.people;
16
16
  }
17
17
  async seedOrganizations(options) {
18
- const { totalOrganizations, phone } = options !== null && options !== void 0 ? options : {};
19
- const orgs = await Promise.all(new Array(totalOrganizations !== null && totalOrganizations !== void 0 ? totalOrganizations : 3)
18
+ const { totalOrganizations, phone } = options ?? {};
19
+ const orgs = await Promise.all(new Array(totalOrganizations ?? 3)
20
20
  .fill(0)
21
21
  .map(() => this.organizations.seedDemoOrganization({ phone })));
22
22
  return orgs;
23
23
  }
24
24
  async seedGuests(options) {
25
- var _a;
26
- await this.seedPeople(Object.assign(Object.assign({}, options), { startingPhone: (_a = SeedFixture.lastPhone) !== null && _a !== void 0 ? _a : '555-999-0000' }));
25
+ await this.seedPeople({
26
+ ...options,
27
+ startingPhone: SeedFixture.lastPhone ?? '555-999-0000',
28
+ });
27
29
  return [];
28
30
  }
29
31
  async seedTeammates(options) {
30
- var _a;
31
- await this.seedPeople(Object.assign(Object.assign({}, options), { startingPhone: (_a = SeedFixture.lastPhone) !== null && _a !== void 0 ? _a : '555-999-1000' }));
32
+ await this.seedPeople({
33
+ ...options,
34
+ startingPhone: SeedFixture.lastPhone ?? '555-999-1000',
35
+ });
32
36
  return [];
33
37
  }
34
38
  async seedGroupManagers(options) {
35
- var _a;
36
- await this.seedPeople(Object.assign(Object.assign({}, options), { startingPhone: (_a = SeedFixture.lastPhone) !== null && _a !== void 0 ? _a : '555-999-2000' }));
39
+ await this.seedPeople({
40
+ ...options,
41
+ startingPhone: SeedFixture.lastPhone ?? '555-999-2000',
42
+ });
37
43
  return [];
38
44
  }
39
45
  async seedManagers(options) {
40
- var _a;
41
- await this.seedPeople(Object.assign(Object.assign({}, options), { startingPhone: (_a = SeedFixture.lastPhone) !== null && _a !== void 0 ? _a : '555-999-3000' }));
46
+ await this.seedPeople({
47
+ ...options,
48
+ startingPhone: SeedFixture.lastPhone ?? '555-999-3000',
49
+ });
42
50
  return [];
43
51
  }
44
52
  async seedOwners(options) {
45
- var _a;
46
- await this.seedPeople(Object.assign(Object.assign({}, options), { startingPhone: (_a = SeedFixture.lastPhone) !== null && _a !== void 0 ? _a : '555-999-4000' }));
53
+ await this.seedPeople({
54
+ ...options,
55
+ startingPhone: SeedFixture.lastPhone ?? '555-999-4000',
56
+ });
47
57
  return [];
48
58
  }
49
59
  async seedAccount(options) {
@@ -56,11 +66,14 @@ class SeedFixture {
56
66
  const locations = await Promise.all(new Array(totalLocations - 1).fill(0).map(() => this.locations.seedDemoLocation({
57
67
  organizationId,
58
68
  })));
59
- const results = await this.seedPeople(Object.assign(Object.assign({}, options), { locationId: location.id, organizationId }));
60
- return Object.assign({ locations: [location, ...locations] }, results);
69
+ const results = await this.seedPeople({
70
+ ...options,
71
+ locationId: location.id,
72
+ organizationId,
73
+ });
74
+ return { locations: [location, ...locations], ...results };
61
75
  }
62
76
  async seedPeople(options) {
63
- var _a;
64
77
  let { totalGroupManagers, totalGuests, totalManagers, totalOwners, totalTeammates, startingPhone, locationId, organizationId, } = options;
65
78
  if (!organizationId) {
66
79
  const org = await this.organizations.getNewestOrganization();
@@ -69,7 +82,7 @@ class SeedFixture {
69
82
  }
70
83
  if (!locationId) {
71
84
  const location = await this.locations.getNewestLocation();
72
- locationId = location === null || location === void 0 ? void 0 : location.id;
85
+ locationId = location?.id;
73
86
  }
74
87
  const results = {
75
88
  guests: [],
@@ -78,11 +91,11 @@ class SeedFixture {
78
91
  groupManagers: [],
79
92
  owners: [],
80
93
  };
81
- let totalToGenerate = (totalGroupManagers !== null && totalGroupManagers !== void 0 ? totalGroupManagers : 0) +
82
- (totalGuests !== null && totalGuests !== void 0 ? totalGuests : 0) +
83
- (totalManagers !== null && totalManagers !== void 0 ? totalManagers : 0) +
84
- (totalOwners !== null && totalOwners !== void 0 ? totalOwners : 0) +
85
- (totalTeammates !== null && totalTeammates !== void 0 ? totalTeammates : 0);
94
+ let totalToGenerate = (totalGroupManagers ?? 0) +
95
+ (totalGuests ?? 0) +
96
+ (totalManagers ?? 0) +
97
+ (totalOwners ?? 0) +
98
+ (totalTeammates ?? 0);
86
99
  if (totalToGenerate > 0) {
87
100
  totalToGenerate++;
88
101
  if (!startingPhone) {
@@ -99,7 +112,7 @@ class SeedFixture {
99
112
  for (const base of bases) {
100
113
  const key = `total${spruce_skill_utils_1.namesUtil.toPascal(base)}s`;
101
114
  //@ts-ignore
102
- const total = (_a = options[key]) !== null && _a !== void 0 ? _a : 0;
115
+ const total = options[key] ?? 0;
103
116
  if (total > 0) {
104
117
  const people = await this.seedPeopleWithRole({
105
118
  total,
@@ -127,7 +140,10 @@ class SeedFixture {
127
140
  const updated = person.firstName
128
141
  ? {}
129
142
  : await this.people.generateRandomName(client);
130
- person = Object.assign(Object.assign({}, person), updated);
143
+ person = {
144
+ ...person,
145
+ ...updated,
146
+ };
131
147
  if (locationId) {
132
148
  await this.locations.addPerson({
133
149
  locationId,