bigbluebutton-html-plugin-sdk 0.0.87 → 0.0.88
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.
- package/README.md +94 -11
- package/dist/cjs/core/api/BbbPluginSdk.js +6 -1
- package/dist/cjs/core/api/BbbPluginSdk.js.map +1 -1
- package/dist/cjs/core/api/types.d.ts +25 -7
- package/dist/cjs/core/enum.d.ts +5 -2
- package/dist/cjs/core/enum.js +3 -1
- package/dist/cjs/core/enum.js.map +1 -1
- package/dist/cjs/core/types.d.ts +2 -1
- package/dist/cjs/data-consumption/domain/shared/custom-query/hooks.d.ts +2 -0
- package/dist/cjs/data-consumption/domain/shared/custom-query/hooks.js +11 -0
- package/dist/cjs/data-consumption/domain/shared/custom-query/hooks.js.map +1 -0
- package/dist/cjs/data-consumption/domain/shared/custom-query/types.d.ts +9 -0
- package/dist/cjs/data-consumption/domain/shared/custom-query/types.js +3 -0
- package/dist/cjs/data-consumption/domain/shared/custom-query/types.js.map +1 -0
- package/dist/cjs/data-consumption/domain/shared/index.d.ts +1 -0
- package/dist/cjs/data-consumption/domain/shared/types.d.ts +3 -0
- package/dist/cjs/data-consumption/domain/shared/types.js +3 -0
- package/dist/cjs/data-consumption/domain/shared/types.js.map +1 -0
- package/dist/cjs/data-consumption/enums.d.ts +2 -1
- package/dist/cjs/data-consumption/enums.js +1 -0
- package/dist/cjs/data-consumption/enums.js.map +1 -1
- package/dist/cjs/data-creation/enums.d.ts +6 -0
- package/dist/cjs/data-creation/enums.js +11 -0
- package/dist/cjs/data-creation/enums.js.map +1 -0
- package/dist/cjs/data-creation/hook.d.ts +2 -0
- package/dist/cjs/data-creation/hook.js +74 -0
- package/dist/cjs/data-creation/hook.js.map +1 -0
- package/dist/cjs/data-creation/types.d.ts +21 -0
- package/dist/cjs/data-creation/types.js +3 -0
- package/dist/cjs/data-creation/types.js.map +1 -0
- package/dist/cjs/data-creation/utils.d.ts +6 -0
- package/dist/cjs/data-creation/utils.js +14 -0
- package/dist/cjs/data-creation/utils.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -132,11 +132,6 @@ Here is as complete `manifest.json` example with all possible configurations:
|
|
|
132
132
|
], // One can enable more data-channels to better organize client communication
|
|
133
133
|
"eventPersistence": {
|
|
134
134
|
"isEnabled": true, // By default it is not enabled
|
|
135
|
-
"maximumPayloadSizeInBytes": 1024,
|
|
136
|
-
"rateLimiting": {
|
|
137
|
-
"messagesAllowedPerSecond": 10,
|
|
138
|
-
"messagesAllowedPerMinute": 20
|
|
139
|
-
}
|
|
140
135
|
},
|
|
141
136
|
"remoteDataSources": [
|
|
142
137
|
{
|
|
@@ -145,12 +140,52 @@ Here is as complete `manifest.json` example with all possible configurations:
|
|
|
145
140
|
"fetchMode": "onMeetingCreate", // Possible values: "onMeetingCreate", "onDemand"
|
|
146
141
|
"permissions": ["moderator", "viewer"]
|
|
147
142
|
}
|
|
143
|
+
],
|
|
144
|
+
"settingsSchema": [
|
|
145
|
+
{
|
|
146
|
+
"name": "myJson",
|
|
147
|
+
"label": "myJson",
|
|
148
|
+
"required": true,
|
|
149
|
+
"defaultValue": {
|
|
150
|
+
"abc": 123
|
|
151
|
+
},
|
|
152
|
+
"type": "json" // Possible values: "int", "float", "string", "boolean", "json"
|
|
153
|
+
}
|
|
148
154
|
]
|
|
149
155
|
}
|
|
150
156
|
```
|
|
151
157
|
|
|
152
158
|
To better understand remote-data-sources, please, refer to [this section](#external-data-resources)
|
|
153
159
|
|
|
160
|
+
**settingsSchema:**
|
|
161
|
+
|
|
162
|
+
The settingsSchema serves two main purposes:
|
|
163
|
+
|
|
164
|
+
1. **Validation:** Ensures that all required settings are provided for a plugin. If any required setting is missing, the plugin will not load.
|
|
165
|
+
2. **Configuration Exposure:** Lists all available settings for the plugin, enabling external systems—such as a Learning Management System (LMS)—to present these settings to a meeting organizer. This allows the organizer to configure the plugin manually before the meeting begins.
|
|
166
|
+
|
|
167
|
+
| **Name** | **Required** | **Description** |
|
|
168
|
+
| -------------- | ------------ | -------------------------------------------------------------------------------------------------------------- |
|
|
169
|
+
| `name` | Yes | The name of the setting as defined in the YAML file |
|
|
170
|
+
| `label` | No | A user-facing label that appears in the integration UI |
|
|
171
|
+
| `required` | Yes | Indicates whether this setting must be provided (`true` or `false`) |
|
|
172
|
+
| `defaultValue` | No | The default value to use if no setting is explicitly defined |
|
|
173
|
+
| `type` | Yes | The expected data type for the setting. Possible values: `"int"`, `"float"`, `"string"`, `"boolean"`, `"json"` |
|
|
174
|
+
|
|
175
|
+
**Example**
|
|
176
|
+
|
|
177
|
+
Given the `settingsSchema` defined in the `manifest.json` seen, the corresponding YAML configuration file (`/etc/bigbluebutton/bbb-html5.yml`) would look like:
|
|
178
|
+
|
|
179
|
+
```yml
|
|
180
|
+
public:
|
|
181
|
+
plugins:
|
|
182
|
+
- name: MyPlugin
|
|
183
|
+
settings:
|
|
184
|
+
myJson:
|
|
185
|
+
abc: my123
|
|
186
|
+
def: 3234
|
|
187
|
+
```
|
|
188
|
+
|
|
154
189
|
## Testing SDK
|
|
155
190
|
|
|
156
191
|
To setup and run the automated tests for the plugin SDK samples, check the [testing doc](/tests/README.md)
|
|
@@ -222,6 +257,59 @@ export interface GraphqlResponseWrapper<TData> {
|
|
|
222
257
|
|
|
223
258
|
So we have the `data`, which is different for each hook, that's why it's a generic, the error, that will be set if, and only if, there is an error, otherwise it is undefined, and loading, which tells the developer if the query is still loading (being fetched) or not.
|
|
224
259
|
|
|
260
|
+
### Realtime Data Creation
|
|
261
|
+
|
|
262
|
+
**`useCustomMutation` Hook**
|
|
263
|
+
|
|
264
|
+
The `useCustomMutation` hook enables you to post data to the backend (Postgres) using existing GraphQL mutations, respecting user permissions.
|
|
265
|
+
|
|
266
|
+
It works similarly to Apollo Client’s `useMutation`, returning a *trigger function* and a *result object* with information about the mutation execution. These will be described in more detail below.
|
|
267
|
+
|
|
268
|
+
One important difference is that the mutation query **must** be provided as a string. This is due to how the SDK communicates with the HTML5 client. As a consequence, you must explicitly define the type of the `variables` argument for the trigger function, as shown in the example below.
|
|
269
|
+
|
|
270
|
+
```typescript
|
|
271
|
+
interface MutationVariablesType {
|
|
272
|
+
reactionEmoji: string;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
const [trigger, result] = pluginApi.useCustomMutation<MutationVariablesType>(`
|
|
276
|
+
mutation SetReactionEmoji($reactionEmoji: String!) {
|
|
277
|
+
userSetReactionEmoji(reactionEmoji: $reactionEmoji)
|
|
278
|
+
}
|
|
279
|
+
`);
|
|
280
|
+
|
|
281
|
+
// Later in the code, you can trigger the mutation:
|
|
282
|
+
trigger({
|
|
283
|
+
variables: {
|
|
284
|
+
reactionEmoji: '👏',
|
|
285
|
+
},
|
|
286
|
+
});
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
Note that the same type (`MutationVariablesType`) passed as the generic parameter to `useCustomMutation` is also the type of the `variables` object in the trigger function.
|
|
290
|
+
|
|
291
|
+
The `result` object returned by the hook contains the following fields:
|
|
292
|
+
|
|
293
|
+
```typescript
|
|
294
|
+
const {
|
|
295
|
+
called,
|
|
296
|
+
data,
|
|
297
|
+
error,
|
|
298
|
+
loading,
|
|
299
|
+
} = result;
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
which follow this interface:
|
|
303
|
+
|
|
304
|
+
```typescript
|
|
305
|
+
interface MutationResultObject {
|
|
306
|
+
called: boolean; // Indicates if the trigger function has been called
|
|
307
|
+
data?: object; // Response data after the mutation is triggered
|
|
308
|
+
error?: object; // Error details from the mutation execution
|
|
309
|
+
loading: boolean; // Whether the mutation is currently loading (triggered or in progress)
|
|
310
|
+
}
|
|
311
|
+
```
|
|
312
|
+
|
|
225
313
|
### Real time data exchange
|
|
226
314
|
|
|
227
315
|
- `useDataChannel` hook: this will allow you to exchange information (Send and receive) amongst different users through the same plugin;
|
|
@@ -451,7 +539,7 @@ This feature is mainly used for security purposes, see [external data section](#
|
|
|
451
539
|
|
|
452
540
|
### Event persistence
|
|
453
541
|
|
|
454
|
-
This feature will allow the developer to save an information (
|
|
542
|
+
This feature will allow the developer to save an information (an event) in the `event.xml` file of the meeting, if it's being recorded.
|
|
455
543
|
|
|
456
544
|
To use it, one first need to add the following lines to their `manifest.json`:
|
|
457
545
|
|
|
@@ -460,11 +548,6 @@ To use it, one first need to add the following lines to their `manifest.json`:
|
|
|
460
548
|
// ...rest of manifest configuration
|
|
461
549
|
"eventPersistence": {
|
|
462
550
|
"isEnabled": true,
|
|
463
|
-
"maximumPayloadSizeInBytes": 1024,
|
|
464
|
-
"rateLimiting": {
|
|
465
|
-
"messagesAllowedPerSecond": 10,
|
|
466
|
-
"messagesAllowedPerMinute": 20
|
|
467
|
-
}
|
|
468
551
|
}
|
|
469
552
|
}
|
|
470
553
|
```
|
|
@@ -30,6 +30,8 @@ var utils_1 = require("../../remote-data/utils");
|
|
|
30
30
|
var hooks_14 = require("../../event-persistence/hooks");
|
|
31
31
|
var useLocaleMessages_1 = __importDefault(require("../auxiliary/plugin-information/locale-messages/useLocaleMessages"));
|
|
32
32
|
var getters_1 = require("../../ui-data/getters/getters");
|
|
33
|
+
var hooks_15 = require("../../data-consumption/domain/shared/custom-query/hooks");
|
|
34
|
+
var hook_2 = require("../../data-creation/hook");
|
|
33
35
|
/**
|
|
34
36
|
* Class responsible for either initialize or get the PluginApi
|
|
35
37
|
*
|
|
@@ -56,6 +58,8 @@ var BbbPluginSdk = /** @class */ (function () {
|
|
|
56
58
|
throw new Error('Initializing pluginApi outside of a react function component. It should be done inside');
|
|
57
59
|
var pluginApi = window.bbb_plugins[uuid];
|
|
58
60
|
pluginApi.useCustomSubscription = (function (query, variablesObjectWrapper) { return (0, hooks_3.useCustomSubscription)(query, variablesObjectWrapper); });
|
|
61
|
+
pluginApi.useCustomQuery = (function (query, variablesObjectWrapper) { return (0, hooks_15.useCustomQuery)(query, variablesObjectWrapper); });
|
|
62
|
+
pluginApi.useCustomMutation = (function (mutation, options) { return (0, hook_2.useCustomMutation)(mutation, options); });
|
|
59
63
|
pluginApi.useCurrentPresentation = (function () { return (0, hooks_2.useCurrentPresentation)(); });
|
|
60
64
|
pluginApi.useLoadedUserList = (function () { return (0, hooks_4.useLoadedUserList)(); });
|
|
61
65
|
pluginApi.useCurrentUser = (function () { return (0, hooks_5.useCurrentUser)(); });
|
|
@@ -81,7 +85,8 @@ var BbbPluginSdk = /** @class */ (function () {
|
|
|
81
85
|
pluginApi.serverCommands = (0, commands_2.serverCommands)(pluginName);
|
|
82
86
|
pluginApi.sendGenericDataForLearningAnalyticsDashboard = function (data) { return (0, hooks_13.sendGenericDataForLearningAnalyticsDashboard)(data, pluginName); };
|
|
83
87
|
pluginApi.getRemoteData = function (dataSourceName) { return (0, utils_1.getRemoteData)(dataSourceName, pluginName); };
|
|
84
|
-
pluginApi
|
|
88
|
+
pluginApi
|
|
89
|
+
.persistEvent = function (eventName, payload) { return (0, hooks_14.persistEventFunctionWrapper)(pluginName, eventName, payload); };
|
|
85
90
|
pluginApi.useLocaleMessages = function (fetchConfigs) { return (0, useLocaleMessages_1.default)({ pluginApi: pluginApi, fetchConfigs: fetchConfigs }); };
|
|
86
91
|
}
|
|
87
92
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BbbPluginSdk.js","sourceRoot":"","sources":["../../../../src/core/api/BbbPluginSdk.ts"],"names":[],"mappings":";;;;;;AAAA,+BAA+B;AAC/B,+BAAkC;AAClC,0EAAsE;AAOtE,kDAA4D;AAO5D,uDAAwD;
|
|
1
|
+
{"version":3,"file":"BbbPluginSdk.js","sourceRoot":"","sources":["../../../../src/core/api/BbbPluginSdk.ts"],"names":[],"mappings":";;;;;;AAAA,+BAA+B;AAC/B,+BAAkC;AAClC,0EAAsE;AAOtE,kDAA4D;AAO5D,uDAAwD;AASxD,kDAAiE;AACjE,gGAEgF;AAChF,wFAEwE;AACxE,oFAA+F;AAC/F,gFAAwF;AACxF,oFAA+F;AAC/F,4DAAoE;AACpE,uDAA0D;AAC1D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AA,wBAAe,GAAE,EAAjB,CAAiB;gBACxC,UAAU,YAAA;gBACV,cAAc,gBAAA;aACf,CAAC;SACH;QAED,OAAO,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;IACH,mBAAC;AAAD,CAAC,AA/ID,IA+IC;AA/IqB,oCAAY"}
|
|
@@ -35,6 +35,8 @@ import { PersistEventFunction } from '../../event-persistence/types';
|
|
|
35
35
|
import { UseLocaleMessagesFunction } from '../auxiliary/plugin-information/locale-messages/types';
|
|
36
36
|
import { UseShouldUnmountPluginFunction } from '../auxiliary/plugin-unmount/types';
|
|
37
37
|
import { GetUiDataFunction } from '../../ui-data/getters/types';
|
|
38
|
+
import { UseCustomQueryFunction } from '../../data-consumption/domain/shared/custom-query/types';
|
|
39
|
+
import { UseCustomMutationFunction } from '../../data-creation/types';
|
|
38
40
|
export type SetPresentationToolbarItems = (presentationToolbarItem: PresentationToolbarInterface[]) => string[];
|
|
39
41
|
export type SetUserListDropdownItems = (userListDropdownItem: UserListDropdownInterface[]) => string[];
|
|
40
42
|
export type SetActionButtonDropdownItems = (actionButtonDropdownInterface: ActionButtonDropdownInterface[]) => string[];
|
|
@@ -110,11 +112,11 @@ export interface PluginApi {
|
|
|
110
112
|
*/
|
|
111
113
|
useUsersBasicInfo?: UseUsersBasicInfoFunction;
|
|
112
114
|
/**
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
115
|
+
* Returns an object containing brief data on the messages already loaded in the chat.
|
|
116
|
+
*
|
|
117
|
+
* @returns `GraphqlResponseWrapper` with the LoadedChatMessages.
|
|
118
|
+
*
|
|
119
|
+
*/
|
|
118
120
|
useLoadedChatMessages?: UseLoadedChatMessagesFunction;
|
|
119
121
|
/**
|
|
120
122
|
* Returns an object containing the settings for the current plugin (with pluginName
|
|
@@ -144,13 +146,29 @@ export interface PluginApi {
|
|
|
144
146
|
*/
|
|
145
147
|
useShouldUnmountPlugin?: UseShouldUnmountPluginFunction;
|
|
146
148
|
/**
|
|
147
|
-
* Returns an object containing the data
|
|
148
|
-
*
|
|
149
|
+
* Returns an object containing the data related to the custom subscription made.
|
|
150
|
+
* This hook is reactive - If the resulting data changes, it updates the hook.
|
|
149
151
|
*
|
|
150
152
|
* @returns `GraphqlResponseWrapper` with the data type specified in the generic type.
|
|
151
153
|
*
|
|
152
154
|
*/
|
|
153
155
|
useCustomSubscription?: UseCustomSubscriptionFunction;
|
|
156
|
+
/**
|
|
157
|
+
* Returns an object containing the data related to the custom subscription made.
|
|
158
|
+
* This hook is not reactive - Once the data is returned, it doesn't update anymore.
|
|
159
|
+
*
|
|
160
|
+
* @returns `GraphqlResponseWrapper` with the data type specified in the generic type.
|
|
161
|
+
*
|
|
162
|
+
*/
|
|
163
|
+
useCustomQuery?: UseCustomQueryFunction;
|
|
164
|
+
/**
|
|
165
|
+
* Gives developer the ability to manipulate data from bbb using custom mutations.
|
|
166
|
+
* It can only use mutations that already exist in bbb.
|
|
167
|
+
*
|
|
168
|
+
* @returns an array with the trigger function and the result of the mutation.
|
|
169
|
+
*
|
|
170
|
+
*/
|
|
171
|
+
useCustomMutation?: UseCustomMutationFunction;
|
|
154
172
|
/**
|
|
155
173
|
* Returns an array with tha data wrapped in the `GraphqlResponseWrapper` in the first
|
|
156
174
|
* position of the array, the push function with which one plugin can inform
|
package/dist/cjs/core/enum.d.ts
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import { DataChannelHooks } from '../data-channel/enums';
|
|
2
2
|
import { DomElementManipulationHooks } from '../dom-element-manipulation/enums';
|
|
3
3
|
import { DataConsumptionHooks } from '../data-consumption/enums';
|
|
4
|
+
import { DataCreationHookEnums } from '../data-creation/enums';
|
|
4
5
|
export declare enum HookEvents {
|
|
5
6
|
BBB_CORE_SENT_NEW_DATA = "BBB_CORE_SENT_NEW_DATA",
|
|
7
|
+
BBB_CORE_UPDATED_STATE = "BBB_CORE_UPDATED_STATE",
|
|
6
8
|
BBB_CORE_UPDATED_MEETING_STATUS = "BBB_CORE_UPDATED_MEETING_STATUS",
|
|
7
9
|
/**
|
|
8
10
|
* PLUGIN_SENT_CHANGES_TO_BBB_CORE is used to:
|
|
9
|
-
* -
|
|
11
|
+
* - Communicate that the subscription has changed for the dom-element-manipulation hook;
|
|
10
12
|
* - Send replace/delete event for useDataChannel;
|
|
13
|
+
* - Trigger the mutation function already created
|
|
11
14
|
*/
|
|
12
15
|
PLUGIN_SENT_CHANGES_TO_BBB_CORE = "PLUGIN_SENT_CHANGES_TO_BBB_CORE",
|
|
13
16
|
PLUGIN_SUBSCRIBED_TO_BBB_CORE = "PLUGIN_SUBSCRIBED_TO_BBB_CORE",
|
|
14
17
|
PLUGIN_UNSUBSCRIBED_FROM_BBB_CORE = "PLUGIN_UNSUBSCRIBED_FROM_BBB_CORE"
|
|
15
18
|
}
|
|
16
19
|
export declare const GENERIC_HOOK_PLUGIN = "GENERIC_HOOK_PLUGIN";
|
|
17
|
-
export type Hooks = DataConsumptionHooks | DataChannelHooks | DomElementManipulationHooks | typeof GENERIC_HOOK_PLUGIN;
|
|
20
|
+
export type Hooks = DataConsumptionHooks | DataChannelHooks | DomElementManipulationHooks | DataCreationHookEnums | typeof GENERIC_HOOK_PLUGIN;
|
package/dist/cjs/core/enum.js
CHANGED
|
@@ -4,11 +4,13 @@ exports.GENERIC_HOOK_PLUGIN = exports.HookEvents = void 0;
|
|
|
4
4
|
var HookEvents;
|
|
5
5
|
(function (HookEvents) {
|
|
6
6
|
HookEvents["BBB_CORE_SENT_NEW_DATA"] = "BBB_CORE_SENT_NEW_DATA";
|
|
7
|
+
HookEvents["BBB_CORE_UPDATED_STATE"] = "BBB_CORE_UPDATED_STATE";
|
|
7
8
|
HookEvents["BBB_CORE_UPDATED_MEETING_STATUS"] = "BBB_CORE_UPDATED_MEETING_STATUS";
|
|
8
9
|
/**
|
|
9
10
|
* PLUGIN_SENT_CHANGES_TO_BBB_CORE is used to:
|
|
10
|
-
* -
|
|
11
|
+
* - Communicate that the subscription has changed for the dom-element-manipulation hook;
|
|
11
12
|
* - Send replace/delete event for useDataChannel;
|
|
13
|
+
* - Trigger the mutation function already created
|
|
12
14
|
*/
|
|
13
15
|
HookEvents["PLUGIN_SENT_CHANGES_TO_BBB_CORE"] = "PLUGIN_SENT_CHANGES_TO_BBB_CORE";
|
|
14
16
|
HookEvents["PLUGIN_SUBSCRIBED_TO_BBB_CORE"] = "PLUGIN_SUBSCRIBED_TO_BBB_CORE";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enum.js","sourceRoot":"","sources":["../../../src/core/enum.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"enum.js","sourceRoot":"","sources":["../../../src/core/enum.ts"],"names":[],"mappings":";;;AAKA,IAAY,UAaX;AAbD,WAAY,UAAU;IACpB,+DAAiD,CAAA;IACjD,+DAAiD,CAAA;IACjD,iFAAmE,CAAA;IACnE;;;;;OAKG;IACH,iFAAmE,CAAA;IACnE,6EAA+D,CAAA;IAC/D,qFAAuE,CAAA;AACzE,CAAC,EAbW,UAAU,0BAAV,UAAU,QAarB;AAEY,QAAA,mBAAmB,GAAG,qBAAqB,CAAC"}
|
package/dist/cjs/core/types.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { CustomSubscriptionArguments } from '../data-consumption/domain/shared/c
|
|
|
3
3
|
import { Hooks } from './enum';
|
|
4
4
|
import { DataChannelArguments } from '../data-channel/types';
|
|
5
5
|
import { DomElementManipulationArguments } from '../dom-element-manipulation/type';
|
|
6
|
+
import { UseCustomMutationArguments } from '../data-creation/types';
|
|
6
7
|
/**
|
|
7
8
|
* Wrapper for the data that comes from the core. With this more complex object
|
|
8
9
|
* it is also possible to know whether the data is still loading, of even if something
|
|
@@ -15,7 +16,7 @@ export interface GraphqlResponseWrapper<TData> {
|
|
|
15
16
|
data?: TData;
|
|
16
17
|
error?: ApolloError;
|
|
17
18
|
}
|
|
18
|
-
export type HookArguments = CustomSubscriptionArguments | DataChannelArguments | DomElementManipulationArguments;
|
|
19
|
+
export type HookArguments = CustomSubscriptionArguments | DataChannelArguments | DomElementManipulationArguments | UseCustomMutationArguments;
|
|
19
20
|
export interface UpdatedEventDetails<T> {
|
|
20
21
|
hook: Hooks;
|
|
21
22
|
hookArguments?: HookArguments;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useCustomQuery = void 0;
|
|
4
|
+
var enums_1 = require("../../../../data-consumption/enums");
|
|
5
|
+
var hookCreator_1 = require("../../../factory/hookCreator");
|
|
6
|
+
var useCustomQuery = function (query, options) { return (0, hookCreator_1.createDataConsumptionHook)(enums_1.DataConsumptionHooks.CUSTOM_QUERY, {
|
|
7
|
+
query: query,
|
|
8
|
+
variables: options === null || options === void 0 ? void 0 : options.variables,
|
|
9
|
+
}); };
|
|
10
|
+
exports.useCustomQuery = useCustomQuery;
|
|
11
|
+
//# sourceMappingURL=hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../../../../../src/data-consumption/domain/shared/custom-query/hooks.ts"],"names":[],"mappings":";;;AAAA,4DAA0E;AAC1E,4DAAyE;AAGlE,IAAM,cAAc,GAA2B,UACpD,KAAa,EACb,OAAgC,IAC7B,OAAA,IAAA,uCAAyB,EAAI,4BAAoB,CAAC,YAAY,EAAE;IACnE,KAAK,OAAA;IACL,SAAS,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS;CACN,CAAC,EAHrB,CAGqB,CAAC;AANd,QAAA,cAAc,kBAMA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { GraphqlResponseWrapper } from '../../../../core';
|
|
2
|
+
export interface CustomQueryArguments {
|
|
3
|
+
query?: string;
|
|
4
|
+
variables?: object;
|
|
5
|
+
}
|
|
6
|
+
export interface CustomQueryHookOptions {
|
|
7
|
+
variables: object;
|
|
8
|
+
}
|
|
9
|
+
export type UseCustomQueryFunction = <T>(query: string, variablesObjectWrapper?: CustomQueryHookOptions) => GraphqlResponseWrapper<T>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/data-consumption/domain/shared/custom-query/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/data-consumption/domain/shared/types.ts"],"names":[],"mappings":""}
|
|
@@ -5,5 +5,6 @@ export declare enum DataConsumptionHooks {
|
|
|
5
5
|
LOADED_CHAT_MESSAGES = "Hooks::UseLoadedChatMessages",
|
|
6
6
|
MEETING = "Hooks::UseMeeting",
|
|
7
7
|
TALKING_INDICATOR = "Hooks::UseTalkingIndicator",
|
|
8
|
-
CUSTOM_SUBSCRIPTION = "Hooks::CustomSubscription"
|
|
8
|
+
CUSTOM_SUBSCRIPTION = "Hooks::CustomSubscription",
|
|
9
|
+
CUSTOM_QUERY = "Hooks::CustomQuery"
|
|
9
10
|
}
|
|
@@ -10,5 +10,6 @@ var DataConsumptionHooks;
|
|
|
10
10
|
DataConsumptionHooks["MEETING"] = "Hooks::UseMeeting";
|
|
11
11
|
DataConsumptionHooks["TALKING_INDICATOR"] = "Hooks::UseTalkingIndicator";
|
|
12
12
|
DataConsumptionHooks["CUSTOM_SUBSCRIPTION"] = "Hooks::CustomSubscription";
|
|
13
|
+
DataConsumptionHooks["CUSTOM_QUERY"] = "Hooks::CustomQuery";
|
|
13
14
|
})(DataConsumptionHooks || (exports.DataConsumptionHooks = DataConsumptionHooks = {}));
|
|
14
15
|
//# sourceMappingURL=enums.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enums.js","sourceRoot":"","sources":["../../../src/data-consumption/enums.ts"],"names":[],"mappings":";;;AAAA,IAAY,
|
|
1
|
+
{"version":3,"file":"enums.js","sourceRoot":"","sources":["../../../src/data-consumption/enums.ts"],"names":[],"mappings":";;;AAAA,IAAY,oBASX;AATD,WAAY,oBAAoB;IAC9B,8EAAsD,CAAA;IACtD,qEAA6C,CAAA;IAC7C,8DAAsC,CAAA;IACtC,6EAAqD,CAAA;IACrD,qDAA6B,CAAA;IAC7B,wEAAgD,CAAA;IAChD,yEAAiD,CAAA;IACjD,2DAAmC,CAAA;AACrC,CAAC,EATW,oBAAoB,oCAApB,oBAAoB,QAS/B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DataCreationHookEnums = void 0;
|
|
4
|
+
var DataCreationHookEnums;
|
|
5
|
+
(function (DataCreationHookEnums) {
|
|
6
|
+
DataCreationHookEnums["CREATE_NEW_CUSTOM_MUTATION"] = "Hooks::CreateNewCustomMutation";
|
|
7
|
+
DataCreationHookEnums["TRIGGER_MUTATION"] = "Hooks::TriggerMutation";
|
|
8
|
+
DataCreationHookEnums["MUTATION_READY"] = "Hooks::MutationReady";
|
|
9
|
+
DataCreationHookEnums["MUTATION_RESULT_SENT"] = "Hooks::MutationResultSent";
|
|
10
|
+
})(DataCreationHookEnums || (exports.DataCreationHookEnums = DataCreationHookEnums = {}));
|
|
11
|
+
//# sourceMappingURL=enums.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enums.js","sourceRoot":"","sources":["../../../src/data-creation/enums.ts"],"names":[],"mappings":";;;AAAA,IAAY,qBAKX;AALD,WAAY,qBAAqB;IAC/B,sFAA6D,CAAA;IAC7D,oEAA2C,CAAA;IAC3C,gEAAuC,CAAA;IACvC,2EAAkD,CAAA;AACpD,CAAC,EALW,qBAAqB,qCAArB,qBAAqB,QAKhC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.useCustomMutation = void 0;
|
|
7
|
+
var react_1 = require("react");
|
|
8
|
+
var enum_1 = require("../core/enum");
|
|
9
|
+
var enums_1 = require("./enums");
|
|
10
|
+
var utils_1 = __importDefault(require("./utils"));
|
|
11
|
+
function useCustomMutation(mutation, options) {
|
|
12
|
+
var _a = (0, react_1.useState)({
|
|
13
|
+
triggerFunction: null,
|
|
14
|
+
result: {
|
|
15
|
+
loading: true,
|
|
16
|
+
called: false,
|
|
17
|
+
},
|
|
18
|
+
}), mutationHookResult = _a[0], setMutationHookResult = _a[1];
|
|
19
|
+
var triggerFunction = (function (data) {
|
|
20
|
+
window.dispatchEvent(new CustomEvent(enum_1.HookEvents.PLUGIN_SENT_CHANGES_TO_BBB_CORE, {
|
|
21
|
+
detail: {
|
|
22
|
+
hook: enums_1.DataCreationHookEnums.TRIGGER_MUTATION,
|
|
23
|
+
hookArguments: {
|
|
24
|
+
mutation: mutation,
|
|
25
|
+
options: options,
|
|
26
|
+
},
|
|
27
|
+
data: data,
|
|
28
|
+
},
|
|
29
|
+
}));
|
|
30
|
+
});
|
|
31
|
+
// This function is responsible for setting the trigger function of the mutation
|
|
32
|
+
var handleMutationReadyEvent = (function (event) {
|
|
33
|
+
(0, utils_1.default)(setMutationHookResult, function (prevMutationResultObject) { return ({
|
|
34
|
+
triggerFunction: triggerFunction,
|
|
35
|
+
result: prevMutationResultObject.result,
|
|
36
|
+
}); }, enums_1.DataCreationHookEnums.MUTATION_READY, event, mutation, options);
|
|
37
|
+
});
|
|
38
|
+
// This function is responsible for setting the result of the mutation;
|
|
39
|
+
var handleMutationResultSentEvent = (function (event) {
|
|
40
|
+
(0, utils_1.default)(setMutationHookResult, function (prevMutationResultObject, dataFromEvent) { return ({
|
|
41
|
+
triggerFunction: prevMutationResultObject.triggerFunction,
|
|
42
|
+
result: dataFromEvent,
|
|
43
|
+
}); }, enums_1.DataCreationHookEnums.MUTATION_RESULT_SENT, event, mutation, options);
|
|
44
|
+
});
|
|
45
|
+
(0, react_1.useEffect)(function () {
|
|
46
|
+
window.dispatchEvent(new CustomEvent(enum_1.HookEvents.PLUGIN_SUBSCRIBED_TO_BBB_CORE, {
|
|
47
|
+
detail: {
|
|
48
|
+
hook: enums_1.DataCreationHookEnums.CREATE_NEW_CUSTOM_MUTATION,
|
|
49
|
+
hookArguments: {
|
|
50
|
+
mutation: mutation,
|
|
51
|
+
options: options,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
}));
|
|
55
|
+
window.addEventListener(enum_1.HookEvents.BBB_CORE_UPDATED_STATE, handleMutationReadyEvent);
|
|
56
|
+
window.addEventListener(enum_1.HookEvents.BBB_CORE_UPDATED_STATE, handleMutationResultSentEvent);
|
|
57
|
+
return function () {
|
|
58
|
+
window.dispatchEvent(new CustomEvent(enum_1.HookEvents.PLUGIN_UNSUBSCRIBED_FROM_BBB_CORE, {
|
|
59
|
+
detail: {
|
|
60
|
+
hook: enums_1.DataCreationHookEnums.CREATE_NEW_CUSTOM_MUTATION,
|
|
61
|
+
hookArguments: {
|
|
62
|
+
mutation: mutation,
|
|
63
|
+
options: options,
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
}));
|
|
67
|
+
window.removeEventListener(enum_1.HookEvents.BBB_CORE_UPDATED_STATE, handleMutationReadyEvent);
|
|
68
|
+
window.removeEventListener(enum_1.HookEvents.BBB_CORE_UPDATED_STATE, handleMutationResultSentEvent);
|
|
69
|
+
};
|
|
70
|
+
}, []);
|
|
71
|
+
return [mutationHookResult.triggerFunction, mutationHookResult.result];
|
|
72
|
+
}
|
|
73
|
+
exports.useCustomMutation = useCustomMutation;
|
|
74
|
+
//# sourceMappingURL=hook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hook.js","sourceRoot":"","sources":["../../../src/data-creation/hook.ts"],"names":[],"mappings":";;;;;;AA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R,CAAC;IACJ,CAAC,CAAkB,CAAC;IAEtB,IAAA,iBAAS,EAAC;QACR,MAAM,CAAC,aAAa,CAClB,IAAI,WAAW,CAAyB,iBAAU,CAAC,6BAA6B,EAAE;YAChF,MAAM,EAAE;gBACN,IAAI,EAAE,6BAAqB,CAAC,0BAA0B;gBACtD,aAAa,EAAE;oBACb,QAAQ,UAAA;oBACR,OAAO,SAAA;iBACR;aACF;SACF,CAAC,CACH,CAAC;QACF,MAAM,CAAC,gBAAgB,CACrB,iBAAU,CAAC,sBAAsB,EACjC,wBAAwB,CACzB,CAAC;QACF,MAAM,CAAC,gBAAgB,CACrB,iBAAU,CAAC,sBAAsB,EACjC,6BAA6B,CAC9B,CAAC;QAEF,OAAO;YACL,MAAM,CAAC,aAAa,CAClB,IAAI,WAAW,CAAyB,iBAAU,CAAC,iCAAiC,EAAE;gBACpF,MAAM,EAAE;oBACN,IAAI,EAAE,6BAAqB,CAAC,0BAA0B;oBACtD,aAAa,EAAE;wBACb,QAAQ,UAAA;wBACR,OAAO,SAAA;qBACR;iBACF;aACF,CAAC,CACH,CAAC;YACF,MAAM,CAAC,mBAAmB,CACxB,iBAAU,CAAC,sBAAsB,EACjC,wBAAwB,CACzB,CAAC;YACF,MAAM,CAAC,mBAAmB,CACxB,iBAAU,CAAC,sBAAsB,EACjC,6BAA6B,CAC9B,CAAC;QACJ,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CAAC,kBAAkB,CAAC,eAAe,EAAE,kBAAkB,CAAC,MAAM,CAAC,CAAC;AACzE,CAAC;AA5GD,8CA4GC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface MutationVariablesWrapper<T> {
|
|
2
|
+
variables: T;
|
|
3
|
+
}
|
|
4
|
+
export type TriggerMutationFunction<T> = (args: MutationVariablesWrapper<T>) => void;
|
|
5
|
+
export type UseCustomMutationReturnType<T> = [TriggerMutationFunction<T> | null, object | null];
|
|
6
|
+
export type UseCustomMutationFunction = <T = any>(mutation: string, options?: object) => UseCustomMutationReturnType<T>;
|
|
7
|
+
export interface UseCustomMutationArguments {
|
|
8
|
+
mutation: string;
|
|
9
|
+
options?: object;
|
|
10
|
+
}
|
|
11
|
+
export interface MutationResultObject {
|
|
12
|
+
called: boolean;
|
|
13
|
+
data?: object;
|
|
14
|
+
error?: object;
|
|
15
|
+
loading: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface MutationHookResultType<T> {
|
|
18
|
+
triggerFunction: TriggerMutationFunction<T> | null;
|
|
19
|
+
result: MutationResultObject | null;
|
|
20
|
+
}
|
|
21
|
+
export type SetterFunctionCallbackType<T, K> = (previousObject: MutationHookResultType<T>, dataFromEvent: K) => MutationHookResultType<T>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/data-creation/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { GraphqlResponseWrapper, HookEventWrapper } from '../core/types';
|
|
3
|
+
import { DataCreationHookEnums } from './enums';
|
|
4
|
+
import { MutationHookResultType, SetterFunctionCallbackType } from './types';
|
|
5
|
+
declare const validateMutationEventFromClient: <T, K>(setMutationResult: React.Dispatch<React.SetStateAction<MutationHookResultType<T>>>, setterFunctionCallback: SetterFunctionCallbackType<T, K>, hook: DataCreationHookEnums, event: HookEventWrapper<GraphqlResponseWrapper<object>>, mutation: string, options?: object) => void;
|
|
6
|
+
export default validateMutationEventFromClient;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var utils_1 = require("../data-consumption/utils");
|
|
4
|
+
var validateMutationEventFromClient = function (setMutationResult, setterFunctionCallback, hook, event, mutation, options) {
|
|
5
|
+
var _a = event.detail, hookReceived = _a.hook, hookArguments = _a.hookArguments, data = _a.data;
|
|
6
|
+
var _b = (hookArguments || { mutation: null, options: null }), mutationReceived = _b.mutation, optionsReceived = _b.options;
|
|
7
|
+
if (hookReceived === hook
|
|
8
|
+
&& ((0, utils_1.makeCustomHookIdentifier)(mutationReceived, optionsReceived)
|
|
9
|
+
=== (0, utils_1.makeCustomHookIdentifier)(mutation, options))) {
|
|
10
|
+
setMutationResult(function (prevObject) { return setterFunctionCallback(prevObject, data); });
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
exports.default = validateMutationEventFromClient;
|
|
14
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/data-creation/utils.ts"],"names":[],"mappings":";;AACA,mDAAqE;AAKrE,IAAM,+BAA+B,GAAG,UACtC,iBAAkF,EAClF,sBAAwD,EACxD,IAA2B,EAC3B,KAAuD,EACvD,QAAgB,EAChB,OAAgB;IAEV,IAAA,KAIF,KAAK,CAAC,MAAgC,EAHlC,YAAY,UAAA,EAClB,aAAa,mBAAA,EACb,IAAI,UACoC,CAAC;IACrC,IAAA,KAGF,CAAC,aAAa,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAA+B,EAF1E,gBAAgB,cAAA,EACjB,eAAe,aAC4D,CAAC;IACvF,IACE,YAAY,KAAK,IAAI;WAClB,CAAC,IAAA,gCAAwB,EAAC,gBAAgB,EAAE,eAAe,CAAC;gBACzD,IAAA,gCAAwB,EAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,EAClD;QACA,iBAAiB,CAAC,UAAC,UAAU,IAAK,OAAA,sBAAsB,CAAC,UAAU,EAAE,IAAI,CAAC,EAAxC,CAAwC,CAAC,CAAC;KAC7E;AACH,CAAC,CAAC;AAEF,kBAAe,+BAA+B,CAAC"}
|