@whereby.com/browser-sdk 2.0.0-alpha → 2.0.0-alpha10

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.
Files changed (73) hide show
  1. package/README.md +39 -2
  2. package/dist/lib.cjs +5868 -0
  3. package/dist/lib.esm.js +5850 -0
  4. package/dist/types.d.ts +308 -0
  5. package/dist/v2-alpha10.js +43 -0
  6. package/package.json +12 -6
  7. package/.eslintrc +0 -23
  8. package/.github/actions/build/action.yml +0 -17
  9. package/.github/workflows/deploy.yml +0 -102
  10. package/.github/workflows/test.yml +0 -24
  11. package/.prettierignore +0 -7
  12. package/.prettierrc +0 -4
  13. package/.storybook/main.cjs +0 -16
  14. package/.storybook/preview.js +0 -9
  15. package/jest.config.js +0 -6
  16. package/rollup.config.js +0 -70
  17. package/src/lib/RoomConnection.ts +0 -516
  18. package/src/lib/RoomParticipant.ts +0 -77
  19. package/src/lib/__tests__/embed.unit.ts +0 -77
  20. package/src/lib/api/ApiClient.ts +0 -111
  21. package/src/lib/api/Credentials.ts +0 -45
  22. package/src/lib/api/HttpClient.ts +0 -95
  23. package/src/lib/api/MultipartHttpClient.ts +0 -53
  24. package/src/lib/api/OrganizationApiClient.ts +0 -64
  25. package/src/lib/api/Response.ts +0 -34
  26. package/src/lib/api/credentialsService/index.ts +0 -159
  27. package/src/lib/api/credentialsService/test/index.spec.ts +0 -181
  28. package/src/lib/api/deviceService/index.ts +0 -42
  29. package/src/lib/api/deviceService/tests/index.spec.ts +0 -74
  30. package/src/lib/api/extractUtils.ts +0 -160
  31. package/src/lib/api/index.ts +0 -8
  32. package/src/lib/api/localStorageWrapper/index.ts +0 -15
  33. package/src/lib/api/models/Account.ts +0 -48
  34. package/src/lib/api/models/Meeting.ts +0 -42
  35. package/src/lib/api/models/Organization.ts +0 -186
  36. package/src/lib/api/models/Room.ts +0 -44
  37. package/src/lib/api/models/account/EmbeddedFreeTierStatus.ts +0 -34
  38. package/src/lib/api/models/tests/Account.spec.ts +0 -128
  39. package/src/lib/api/models/tests/Organization.spec.ts +0 -161
  40. package/src/lib/api/models/tests/Room.spec.ts +0 -74
  41. package/src/lib/api/modules/AbstractStore.ts +0 -18
  42. package/src/lib/api/modules/ChromeStorageStore.ts +0 -44
  43. package/src/lib/api/modules/LocalStorageStore.ts +0 -57
  44. package/src/lib/api/modules/tests/ChromeStorageStore.spec.ts +0 -67
  45. package/src/lib/api/modules/tests/LocalStorageStore.spec.ts +0 -79
  46. package/src/lib/api/modules/tests/__mocks__/storage.ts +0 -24
  47. package/src/lib/api/organizationService/index.ts +0 -284
  48. package/src/lib/api/organizationService/tests/index.spec.ts +0 -781
  49. package/src/lib/api/organizationServiceCache/index.ts +0 -28
  50. package/src/lib/api/organizationServiceCache/tests/index.spec.ts +0 -101
  51. package/src/lib/api/parameterAssertUtils.ts +0 -166
  52. package/src/lib/api/roomService/index.ts +0 -310
  53. package/src/lib/api/roomService/tests/index.spec.ts +0 -668
  54. package/src/lib/api/test/ApiClient.spec.ts +0 -139
  55. package/src/lib/api/test/HttpClient.spec.ts +0 -120
  56. package/src/lib/api/test/MultipartHttpClient.spec.ts +0 -145
  57. package/src/lib/api/test/OrganizationApiClient.spec.ts +0 -132
  58. package/src/lib/api/test/extractUtils.spec.ts +0 -357
  59. package/src/lib/api/test/helpers.ts +0 -41
  60. package/src/lib/api/test/parameterAssertUtils.spec.ts +0 -265
  61. package/src/lib/api/types.ts +0 -6
  62. package/src/lib/embed.ts +0 -172
  63. package/src/lib/index.ts +0 -3
  64. package/src/lib/react/VideoElement.tsx +0 -16
  65. package/src/lib/react/index.ts +0 -3
  66. package/src/lib/react/useLocalMedia.ts +0 -25
  67. package/src/lib/react/useRoomConnection.ts +0 -92
  68. package/src/lib/reducer.ts +0 -142
  69. package/src/stories/custom-ui.stories.tsx +0 -133
  70. package/src/stories/prebuilt-ui.stories.tsx +0 -131
  71. package/src/stories/styles.css +0 -74
  72. package/src/types.d.ts +0 -175
  73. package/tsconfig.json +0 -30
@@ -1,186 +0,0 @@
1
- import { assertInstanceOf, assertString } from "../parameterAssertUtils";
2
- import { Json } from "../Response";
3
-
4
- import Account from "./Account";
5
-
6
- interface OrganizationPermissionAction {
7
- isAllowed: boolean;
8
- isSupported: boolean;
9
- }
10
-
11
- interface FullOrganizationPermissions {
12
- images: {
13
- logoImageUrl: {
14
- set: OrganizationPermissionAction;
15
- reset: OrganizationPermissionAction;
16
- };
17
- roomBackgroundImageUrl: {
18
- set: OrganizationPermissionAction;
19
- reset: OrganizationPermissionAction;
20
- };
21
- roomKnockPageBackgroundImageUrl: {
22
- set: OrganizationPermissionAction;
23
- reset: OrganizationPermissionAction;
24
- };
25
- };
26
- invitations: {
27
- add: OrganizationPermissionAction;
28
- delete: OrganizationPermissionAction;
29
- list: OrganizationPermissionAction;
30
- };
31
- roles: {
32
- set: OrganizationPermissionAction;
33
- remove: OrganizationPermissionAction;
34
- removeSelf: OrganizationPermissionAction;
35
- list: OrganizationPermissionAction;
36
- };
37
- users: {
38
- signUpWithoutInvitation: OrganizationPermissionAction;
39
- };
40
- rooms: {
41
- customize: OrganizationPermissionAction;
42
- customizeSelf: OrganizationPermissionAction;
43
- list: OrganizationPermissionAction;
44
- lock: OrganizationPermissionAction;
45
- unclaim: OrganizationPermissionAction;
46
- unclaimSelf: OrganizationPermissionAction;
47
- };
48
- subscriptions: {
49
- add: OrganizationPermissionAction;
50
- list: OrganizationPermissionAction;
51
- payLatestInvoice: OrganizationPermissionAction;
52
- updatePlan: OrganizationPermissionAction;
53
- };
54
- browserExtension: {
55
- install: OrganizationPermissionAction;
56
- };
57
- }
58
- type OrganizationPermissions = Partial<FullOrganizationPermissions>;
59
-
60
- interface OrganizationLimits {
61
- maxNumberOfInvitationsAndUsers: number | null;
62
- maxNumberOfClaimedRooms: number | null;
63
- maxRoomLimitPerOrganization: number | null;
64
- trialMinutesLimit: number | null;
65
- includedUnits: number | null;
66
- }
67
- interface OrganizationOnboardingSurvey {
68
- name: string;
69
- value: unknown;
70
- }
71
-
72
- export type OrganizationPreferences = Record<string, boolean | string | null | number>;
73
-
74
- export function hasValue(value: unknown): boolean {
75
- return value !== null && value !== undefined;
76
- }
77
-
78
- function createOrganizationLimits(limits: Record<string, unknown> = {}): OrganizationLimits {
79
- return {
80
- maxNumberOfInvitationsAndUsers: hasValue(limits?.maxNumberOfInvitationsAndUsers)
81
- ? Number(limits?.maxNumberOfInvitationsAndUsers)
82
- : null,
83
- maxNumberOfClaimedRooms: hasValue(limits?.maxNumberOfClaimedRooms)
84
- ? Number(limits?.maxNumberOfClaimedRooms)
85
- : null,
86
- maxRoomLimitPerOrganization: hasValue(limits?.maxRoomLimitPerOrganization)
87
- ? Number(limits?.maxRoomLimitPerOrganization)
88
- : null,
89
- trialMinutesLimit: hasValue(limits?.trialMinutesLimit) ? Number(limits?.trialMinutesLimit) : null,
90
- includedUnits: hasValue(limits?.includedUnits) ? Number(limits?.includedUnits) : null,
91
- };
92
- }
93
-
94
- export default class Organization {
95
- static GLOBAL_ORGANIZATION_ID = "1";
96
-
97
- organizationId: string;
98
- organizationName: string;
99
- subdomain: string;
100
- permissions: OrganizationPermissions;
101
- limits: OrganizationLimits;
102
- account: Account | null;
103
- logoImageUrl: string | null = null;
104
- roomBackgroundImageUrl: string | null = null;
105
- roomBackgroundThumbnailUrl: string | null = null;
106
- roomKnockPageBackgroundImageUrl: string | null = null;
107
- roomKnockPageBackgroundThumbnailUrl: string | null = null;
108
- preferences: OrganizationPreferences | null = null;
109
- onboardingSurvey: OrganizationOnboardingSurvey | null = null;
110
- type: string | null = null;
111
-
112
- constructor(properties: {
113
- account: Account | null;
114
- organizationId: string;
115
- organizationName: string;
116
- subdomain: string;
117
- permissions: OrganizationPermissions;
118
- limits: OrganizationLimits;
119
- logoImageUrl: string | null;
120
- roomBackgroundImageUrl: string | null;
121
- roomBackgroundThumbnailUrl: string | null;
122
- roomKnockPageBackgroundImageUrl: string | null;
123
- roomKnockPageBackgroundThumbnailUrl: string | null;
124
- preferences: OrganizationPreferences | null;
125
- onboardingSurvey: OrganizationOnboardingSurvey | null;
126
- type: string | null;
127
- }) {
128
- assertInstanceOf(properties, Object, "properties");
129
- assertString(properties.organizationId, "organizationId");
130
- assertString(properties.organizationName, "organizationName");
131
- assertString(properties.subdomain, "subdomain");
132
- assertInstanceOf(properties.permissions, Object, "permissions");
133
- assertInstanceOf(properties.limits, Object, "limits");
134
-
135
- this.organizationId = properties.organizationId;
136
- this.organizationName = properties.organizationName;
137
- this.subdomain = properties.subdomain;
138
- this.permissions = properties.permissions;
139
- this.limits = properties.limits;
140
- this.account = properties.account ? new Account(properties.account) : null;
141
- this.logoImageUrl = properties.logoImageUrl;
142
- this.roomBackgroundImageUrl = properties.roomBackgroundImageUrl;
143
- this.roomBackgroundThumbnailUrl = properties.roomBackgroundThumbnailUrl;
144
- this.roomKnockPageBackgroundImageUrl = properties.roomKnockPageBackgroundImageUrl;
145
- this.roomKnockPageBackgroundThumbnailUrl = properties.roomKnockPageBackgroundThumbnailUrl;
146
- this.preferences = properties.preferences;
147
- this.onboardingSurvey = properties.onboardingSurvey;
148
- this.type = properties.type;
149
- }
150
-
151
- static fromJson(data: Json): Organization {
152
- const parsedData = assertInstanceOf(data, Object, "data") as Record<string, unknown>;
153
- const preferences = (parsedData?.preferences || {}) as OrganizationPreferences;
154
- const onboardingSurvey = (parsedData?.onboardingSurvey || null) as OrganizationOnboardingSurvey;
155
- const permissions = assertInstanceOf(parsedData.permissions, Object, "permissions") as OrganizationPreferences;
156
-
157
- return new Organization({
158
- organizationId: assertString(parsedData.organizationId, "organizationId"),
159
- organizationName: assertString(parsedData.organizationName, "organizationName"),
160
- subdomain: assertString(parsedData.subdomain, "subdomain"),
161
- permissions,
162
- limits: createOrganizationLimits(
163
- assertInstanceOf(parsedData.limits, Object, "limits") as Record<string, unknown>
164
- ),
165
- account: parsedData.account ? Account.fromJson(parsedData.account as Record<string, unknown>) : null,
166
- logoImageUrl: typeof parsedData.logoImageUrl === "string" ? parsedData.logoImageUrl : null,
167
- roomBackgroundImageUrl:
168
- typeof parsedData.roomBackgroundImageUrl === "string" ? parsedData.roomBackgroundImageUrl : null,
169
- roomBackgroundThumbnailUrl:
170
- typeof parsedData.roomBackgroundThumbnailUrl === "string"
171
- ? parsedData.roomBackgroundThumbnailUrl
172
- : null,
173
- roomKnockPageBackgroundImageUrl:
174
- typeof parsedData.roomKnockPageBackgroundImageUrl === "string"
175
- ? parsedData.roomKnockPageBackgroundImageUrl
176
- : null,
177
- roomKnockPageBackgroundThumbnailUrl:
178
- typeof parsedData.roomKnockPageBackgroundThumbnailUrl === "string"
179
- ? parsedData.roomKnockPageBackgroundThumbnailUrl
180
- : null,
181
- preferences,
182
- onboardingSurvey,
183
- type: typeof parsedData.type === "string" ? parsedData.type : null,
184
- });
185
- }
186
- }
@@ -1,44 +0,0 @@
1
- // @ts-nocheck
2
- import assert from "assert";
3
-
4
- export default class Room {
5
- constructor(properties = {}) {
6
- assert.ok(properties instanceof Object, "properties<object> must be empty or an object");
7
-
8
- this.isClaimed = false;
9
- this.isBanned = false;
10
- this.isLocked = false;
11
- this.knockPage = {
12
- backgroundImageUrl: null,
13
- backgroundThumbnailUrl: null,
14
- };
15
- this.logoUrl = null;
16
- this.backgroundImageUrl = null;
17
- this.backgroundThumbnailUrl = null;
18
- this.type = null;
19
- this.legacyRoomType = null;
20
- this.mode = null;
21
- this.product = null;
22
- this.roomName = null;
23
- this.theme = null;
24
- this.preferences = {};
25
- this.protectedPreferences = {};
26
- this.publicProfile = null;
27
-
28
- // Only allow existing property names to be modified
29
- const validProperties = {};
30
- Object.getOwnPropertyNames(properties).forEach((prop) => {
31
- if (Object.getOwnPropertyNames(this).indexOf(prop) !== -1) {
32
- validProperties[prop] = properties[prop];
33
- }
34
- });
35
- if (properties.ownerId !== undefined) {
36
- this.ownerId = properties.ownerId;
37
- }
38
- if (properties.meeting !== undefined) {
39
- this.meeting = properties.meeting;
40
- }
41
-
42
- Object.assign(this, validProperties);
43
- }
44
- }
@@ -1,34 +0,0 @@
1
- import { assertBoolean, assertNumber, assertString } from "../../parameterAssertUtils";
2
-
3
- export default class EmbeddedFreeTierStatus {
4
- isExhausted: boolean;
5
- renewsAt: Date;
6
- totalMinutesLimit: number;
7
- totalMinutesUsed: number;
8
-
9
- constructor({
10
- isExhausted,
11
- renewsAt,
12
- totalMinutesLimit,
13
- totalMinutesUsed,
14
- }: {
15
- isExhausted: boolean;
16
- renewsAt: Date;
17
- totalMinutesLimit: number;
18
- totalMinutesUsed: number;
19
- }) {
20
- this.isExhausted = isExhausted;
21
- this.renewsAt = renewsAt;
22
- this.totalMinutesLimit = totalMinutesLimit;
23
- this.totalMinutesUsed = totalMinutesUsed;
24
- }
25
-
26
- static fromJson(data: Record<string, unknown>): EmbeddedFreeTierStatus {
27
- return new EmbeddedFreeTierStatus({
28
- isExhausted: assertBoolean(data.isExhausted, "isExhausted"),
29
- renewsAt: new Date(assertString(data.renewsAt, "renewsAt")),
30
- totalMinutesLimit: assertNumber(data.totalMinutesLimit, "totalMinutesLimit"),
31
- totalMinutesUsed: assertNumber(data.totalMinutesUsed, "totalMinutesUsed"),
32
- });
33
- }
34
- }
@@ -1,128 +0,0 @@
1
- import Account from "../Account";
2
- import EmbeddedFreeTierStatus from "../account/EmbeddedFreeTierStatus";
3
-
4
- describe("Account", () => {
5
- describe("fromJson", () => {
6
- describe("when embeddedFreeTierStatus is provided", () => {
7
- it("should return an instance of Account with the right values", () => {
8
- const basePlanId = "some-base-plan-id";
9
- const isDeactivated = false;
10
- const isOnTrial = true;
11
- const onTrialUntil = "09-02-2022";
12
- const trialStatus = "some-status";
13
- const embeddedFreeTierStatus = {
14
- isExhausted: false,
15
- renewsAt: "23-02-2022",
16
- totalMinutesLimit: 1000,
17
- totalMinutesUsed: 700,
18
- };
19
- const embeddedFreeTierStatusFromJson = EmbeddedFreeTierStatus.fromJson(embeddedFreeTierStatus);
20
- const expectedAccount = new Account({
21
- basePlanId,
22
- isDeactivated,
23
- isOnTrial,
24
- onTrialUntil: new Date(onTrialUntil),
25
- trialStatus,
26
- embeddedFreeTierStatus: embeddedFreeTierStatusFromJson,
27
- });
28
-
29
- const result = Account.fromJson({
30
- basePlanId,
31
- isDeactivated,
32
- isOnTrial,
33
- onTrialUntil,
34
- trialStatus,
35
- embeddedFreeTierStatus,
36
- });
37
-
38
- expect(result).toBeInstanceOf(Account);
39
- expect(result.basePlanId).toEqual(expectedAccount.basePlanId);
40
- expect(result.isDeactivated).toEqual(expectedAccount.isDeactivated);
41
- expect(result.isOnTrial).toEqual(expectedAccount.isOnTrial);
42
- expect(result.onTrialUntil).toEqual(expectedAccount.onTrialUntil);
43
- expect(result.trialStatus).toEqual(expectedAccount.trialStatus);
44
- expect(JSON.stringify(result.embeddedFreeTierStatus)).toEqual(
45
- JSON.stringify(embeddedFreeTierStatusFromJson)
46
- );
47
- });
48
- });
49
-
50
- describe("when embeddedFreeTierStatus is not provided", () => {
51
- it("should return an instance of Account with embeddedFreeTierStatus as null", () => {
52
- const basePlanId = "some-base-plan-id";
53
- const isDeactivated = false;
54
- const isOnTrial = true;
55
- const onTrialUntil = "09-02-2022";
56
- const trialStatus = "some-status";
57
- const expectedAccount = new Account({
58
- basePlanId,
59
- isDeactivated,
60
- isOnTrial,
61
- onTrialUntil: new Date(onTrialUntil),
62
- trialStatus,
63
- embeddedFreeTierStatus: null,
64
- });
65
-
66
- const result = Account.fromJson({
67
- basePlanId,
68
- isDeactivated,
69
- isOnTrial,
70
- onTrialUntil,
71
- trialStatus,
72
- });
73
-
74
- // @ts-ignore
75
- expect(result).toBeInstanceOf(Account);
76
- expect(result.basePlanId).toEqual(expectedAccount.basePlanId);
77
- expect(result.isDeactivated).toEqual(expectedAccount.isDeactivated);
78
- expect(result.isOnTrial).toEqual(expectedAccount.isOnTrial);
79
- expect(result.onTrialUntil).toEqual(expectedAccount.onTrialUntil);
80
- expect(result.trialStatus).toEqual(expectedAccount.trialStatus);
81
- expect(result.embeddedFreeTierStatus).toEqual(null);
82
- });
83
- });
84
-
85
- describe("when basePlanId is not provided", () => {
86
- it("should return an Account with basePlanId set to null", () => {
87
- const isDeactivated = false;
88
- const isOnTrial = true;
89
- const onTrialUntil = "09-02-2022";
90
- const trialStatus = "some-status";
91
- const embeddedFreeTierStatus = {
92
- isExhausted: false,
93
- renewsAt: "23-02-2022",
94
- totalMinutesLimit: 1000,
95
- totalMinutesUsed: 700,
96
- };
97
- const embeddedFreeTierStatusFromJson = EmbeddedFreeTierStatus.fromJson(embeddedFreeTierStatus);
98
- const expectedAccount = new Account({
99
- basePlanId: null,
100
- isDeactivated,
101
- isOnTrial,
102
- onTrialUntil: new Date(onTrialUntil),
103
- trialStatus,
104
- embeddedFreeTierStatus: embeddedFreeTierStatusFromJson,
105
- });
106
-
107
- const result = Account.fromJson({
108
- embeddedFreeTierStatus,
109
- isDeactivated,
110
- isOnTrial,
111
- onTrialUntil,
112
- trialStatus,
113
- });
114
-
115
- // @ts-ignore
116
- expect(result).toBeInstanceOf(Account);
117
- expect(result.basePlanId).toEqual(expectedAccount.basePlanId);
118
- expect(result.isDeactivated).toEqual(expectedAccount.isDeactivated);
119
- expect(result.isOnTrial).toEqual(expectedAccount.isOnTrial);
120
- expect(result.onTrialUntil).toEqual(expectedAccount.onTrialUntil);
121
- expect(result.trialStatus).toEqual(expectedAccount.trialStatus);
122
- expect(JSON.stringify(result.embeddedFreeTierStatus)).toEqual(
123
- JSON.stringify(embeddedFreeTierStatusFromJson)
124
- );
125
- });
126
- });
127
- });
128
- });
@@ -1,161 +0,0 @@
1
- import Organization, { hasValue } from "../Organization";
2
- import Account from "../Account";
3
-
4
- const defaultOrganization = {};
5
-
6
- describe("Organization", () => {
7
- const organizationId = "12";
8
- const organizationName = "some-name";
9
- const subdomain = "someOrganization";
10
- const account = null;
11
- const limits = {
12
- maxNumberOfClaimedRooms: null,
13
- maxNumberOfInvitationsAndUsers: null,
14
- maxRoomLimitPerOrganization: null,
15
- trialMinutesLimit: null,
16
- includedUnits: null,
17
- };
18
- const logoImageUrl = "some-logoImageUrl";
19
- const roomBackgroundImageUrl = "some-roomBackgroundImageUrl";
20
- const roomBackgroundThumbnailUrl = "some-roomBackgroundThumbnailUrl";
21
- const roomKnockPageBackgroundImageUrl = "some-roomKnockPageBackgroundImageUrl";
22
- const roomKnockPageBackgroundThumbnailUrl = "some-roomKnockPageBackgroundThumbnailUrl";
23
- const preferences = {};
24
- const onboardingSurvey = null;
25
- const type = "public";
26
-
27
- describe("constructor", () => {
28
- it("should return a correctly extended organization object", () => {
29
- const permissions = {
30
- cloudRecording: {
31
- setConfig: { isAllowed: true, isSupported: true },
32
- },
33
- images: {
34
- logoImageUrl: {
35
- set: { isAllowed: true, isSupported: true },
36
- reset: { isAllowed: true, isSupported: true },
37
- },
38
- roomBackgroundImageUrl: {
39
- set: { isAllowed: true, isSupported: true },
40
- reset: { isAllowed: true, isSupported: true },
41
- },
42
- roomKnockPageBackgroundImageUrl: {
43
- set: { isAllowed: true, isSupported: true },
44
- reset: { isAllowed: true, isSupported: true },
45
- },
46
- },
47
- invitations: {
48
- add: { isAllowed: true, isSupported: true },
49
- delete: { isAllowed: true, isSupported: true },
50
- list: { isAllowed: true, isSupported: true },
51
- },
52
- roles: {
53
- set: { isAllowed: true, isSupported: true },
54
- remove: { isAllowed: true, isSupported: true },
55
- removeSelf: { isAllowed: true, isSupported: true },
56
- list: { isAllowed: true, isSupported: true },
57
- },
58
- users: {
59
- signUpWithoutInvitation: { isAllowed: true, isSupported: true },
60
- },
61
- };
62
- const properties = {
63
- organizationId,
64
- organizationName,
65
- subdomain,
66
- account,
67
- permissions,
68
- limits,
69
- logoImageUrl,
70
- roomBackgroundImageUrl,
71
- roomBackgroundThumbnailUrl,
72
- roomKnockPageBackgroundImageUrl,
73
- roomKnockPageBackgroundThumbnailUrl,
74
- preferences,
75
- onboardingSurvey,
76
- type,
77
- };
78
- const organization = new Organization(properties);
79
- const expectedObj = Object.assign({}, defaultOrganization, properties);
80
-
81
- expect(organization).toEqual(expectedObj);
82
- });
83
-
84
- it(
85
- "should instantiate an Account object if account information is provided",
86
- () => {
87
- const permissions = {
88
- rooms: {
89
- changeTypeToPersonal: { isAllowed: true, isSupported: true },
90
- changeTypeToPersonalXl: { isAllowed: true, isSupported: true },
91
- customize: { isAllowed: true, isSupported: true },
92
- customizeSelf: { isAllowed: true, isSupported: true },
93
- list: { isAllowed: true, isSupported: true },
94
- lock: { isAllowed: true, isSupported: true },
95
- unclaim: { isAllowed: true, isSupported: true },
96
- unclaimSelf: { isAllowed: true, isSupported: true },
97
- },
98
- subscriptions: {
99
- add: { isAllowed: true, isSupported: true },
100
- list: { isAllowed: true, isSupported: true },
101
- payLatestInvoice: { isAllowed: true, isSupported: true },
102
- updatePlan: { isAllowed: true, isSupported: true },
103
- },
104
- browserExtension: {
105
- install: { isAllowed: true, isSupported: true },
106
- },
107
- };
108
- const properties = {
109
- account: {
110
- basePlanId: "some-base-plan-id",
111
- isDeactivated: false,
112
- onTrialUntil: null,
113
- isOnTrial: false,
114
- trialStatus: "some-status",
115
- embeddedFreeTierStatus: null,
116
- },
117
- organizationId,
118
- organizationName,
119
- subdomain,
120
- permissions,
121
- limits,
122
- logoImageUrl,
123
- roomBackgroundImageUrl,
124
- roomBackgroundThumbnailUrl,
125
- roomKnockPageBackgroundImageUrl,
126
- roomKnockPageBackgroundThumbnailUrl,
127
- preferences,
128
- onboardingSurvey,
129
- type,
130
- };
131
- const organization = new Organization(properties);
132
-
133
- expect(organization.account).toBeInstanceOf(Account);
134
- }
135
- );
136
- });
137
-
138
- describe("GLOBAL_ORGANIZATION_ID", () => {
139
- it("should be 1", () => {
140
- expect(Organization.GLOBAL_ORGANIZATION_ID).toBe("1");
141
- });
142
- });
143
-
144
- describe("hasValue", () => {
145
- it("should return true when value is 0", () => {
146
- expect(hasValue(0)).toBe(true);
147
- });
148
-
149
- it(`should return true when value is "0"`, () => {
150
- expect(hasValue("0")).toBe(true);
151
- });
152
-
153
- it("should return false when value is undefined", () => {
154
- expect(hasValue(undefined)).toBe(false);
155
- });
156
-
157
- it("should return false when value is null", () => {
158
- expect(hasValue(null)).toBe(false);
159
- });
160
- });
161
- });
@@ -1,74 +0,0 @@
1
- // @ts-nocheck
2
- import Meeting from "../Meeting";
3
- import Room from "../Room";
4
-
5
- const defaultRoom = {
6
- isClaimed: false,
7
- isBanned: false,
8
- isLocked: false,
9
- knockPage: {
10
- backgroundImageUrl: null,
11
- backgroundThumbnailUrl: null,
12
- },
13
- logoUrl: null,
14
- backgroundImageUrl: null,
15
- backgroundThumbnailUrl: null,
16
- type: null,
17
- legacyRoomType: null,
18
- mode: null,
19
- product: null,
20
- roomName: null,
21
- theme: null,
22
- preferences: {},
23
- protectedPreferences: {},
24
- publicProfile: null,
25
- };
26
-
27
- describe("Room", () => {
28
- it("should return the default room if no room is passed in", () => {
29
- const room = new Room();
30
-
31
- expect(room).toEqual(defaultRoom);
32
- });
33
-
34
- it("should return a correctly extended room object", () => {
35
- const extendedObj = {
36
- isClaimed: true,
37
- roomName: "/some-room-name",
38
- };
39
- const room = new Room(extendedObj);
40
- const expectedObj = Object.assign({}, defaultRoom, extendedObj);
41
-
42
- expect(room).toEqual(expectedObj);
43
- });
44
-
45
- it(
46
- "should return a correctly extended room object without the invalid property",
47
- () => {
48
- const room = new Room({
49
- isClaimed: true,
50
- someProperty: "someValue",
51
- });
52
- const expectedObj = Object.assign({}, defaultRoom, { isClaimed: true });
53
-
54
- expect(room).toEqual(expectedObj);
55
- }
56
- );
57
-
58
- it(
59
- "should return the room with the meeting if the meeting is passed in",
60
- () => {
61
- const meeting = new Meeting({
62
- meetingId: "123",
63
- startDate: new Date(),
64
- endDate: new Date(),
65
- roomName: "/some-room-name",
66
- roomUrl: "some-room-url",
67
- });
68
-
69
- const room = new Room({ meeting });
70
-
71
- expect(room).toEqual({ ...defaultRoom, meeting });
72
- }
73
- );
74
- });
@@ -1,18 +0,0 @@
1
- /*
2
- * Abstract class which all credential stores needs to inherit to
3
- * be usable with CredentialsService
4
- */
5
-
6
- import { Json } from "../Response";
7
-
8
- export default interface AbstractStore {
9
- /*
10
- * Get value
11
- */
12
- loadOrDefault(defaultValue: Json): Promise<Json>;
13
-
14
- /*
15
- * Set value
16
- */
17
- save(value: Json): Promise<void>;
18
- }
@@ -1,44 +0,0 @@
1
- /**
2
- * Utility to handle storing data in chrome.storage
3
- */
4
- import { Json } from "../Response";
5
- import AbstractStore from "./AbstractStore";
6
-
7
- export default class ChromeStorageStore implements AbstractStore {
8
- _key: string;
9
- _chromeStorage: chrome.storage.StorageArea;
10
-
11
- constructor(key: string, chromeStorage: chrome.storage.StorageArea) {
12
- this._key = key;
13
- this._chromeStorage = chromeStorage;
14
- }
15
-
16
- /**
17
- * Returns the stored value for this store, or a default if not available.
18
- *
19
- * @param {(Object|Array.|string|number)} [defaultValue] - Value returned if the object can't be retrieved.
20
- * @return {?(Object|Array.|string|number)} Value stored, or defaultValue if not available.
21
- */
22
- loadOrDefault(defaultValue: Json): Promise<Json> {
23
- return new Promise((resolve) => {
24
- this._chromeStorage.get(this._key, (result) => {
25
- const unknownResult: Record<string, Json> = result;
26
- resolve(unknownResult[this._key] || defaultValue);
27
- });
28
- });
29
- }
30
-
31
- /**
32
- * Change the value stored for this key.
33
- *
34
- * @param {(Object|Array.|string|number)} [value] - New value, will replace any previously stored.
35
- * @return {Promise<void>}
36
- */
37
- save(value: Json): Promise<void> {
38
- return new Promise((resolve) => {
39
- this._chromeStorage.set({ [this._key]: value }, () => {
40
- resolve();
41
- });
42
- });
43
- }
44
- }