@matrix-widget-toolkit/api 4.1.1 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- package/build/cjs/api/WidgetApiImpl.d.cts +16 -1
- package/build/cjs/api/types.d.cts +40 -1
- package/build/cjs/index.cjs +51 -4
- package/build/esm/api/WidgetApiImpl.d.ts +16 -1
- package/build/esm/api/types.d.ts +40 -1
- package/build/esm/index.js +51 -4
- package/build/index.d.ts +55 -0
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -148,3 +148,12 @@ It returns a promise that resolves with the result of the modal.
|
|
|
148
148
|
Inside the modal widget, you can use `observeModalButtons()` to listen to clicks on the bottom buttons of the modal.
|
|
149
149
|
You can use `setModalButtonEnabled()` to disable buttons from within the widget.
|
|
150
150
|
Once you are done, you can call `closeModal()` to close the modal and pass the results back to the main widget.
|
|
151
|
+
|
|
152
|
+
### Delayed events
|
|
153
|
+
|
|
154
|
+
You can send and update delayed events (MSC4140). The configuration for delayed events on the homeserver
|
|
155
|
+
needs to be applied, for example:
|
|
156
|
+
|
|
157
|
+
```
|
|
158
|
+
max_event_delay_duration: 24h
|
|
159
|
+
```
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Capability, IDownloadFileActionFromWidgetResponseData, IGetMediaConfigActionFromWidgetResponseData, IModalWidgetCreateData, IModalWidgetOpenRequestDataButton, IModalWidgetReturnData, IOpenIDCredentials, ISendEventFromWidgetResponseData, IUploadFileActionFromWidgetResponseData, IWidgetApiRequestData, WidgetApi as MatrixWidgetApi, ModalButtonID, Symbols, WidgetEventCapability } from 'matrix-widget-api';
|
|
1
|
+
import { Capability, IDownloadFileActionFromWidgetResponseData, IGetMediaConfigActionFromWidgetResponseData, IModalWidgetCreateData, IModalWidgetOpenRequestDataButton, IModalWidgetReturnData, IOpenIDCredentials, ISendEventFromWidgetResponseData, IUploadFileActionFromWidgetResponseData, IWidgetApiRequestData, WidgetApi as MatrixWidgetApi, ModalButtonID, Symbols, UpdateDelayedEventAction, WidgetEventCapability } from 'matrix-widget-api';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
3
|
import { RoomEvent, StateEvent, ToDeviceMessageEvent, TurnServer, WidgetApi, WidgetConfig, WidgetParameters } from './types';
|
|
4
4
|
/**
|
|
@@ -108,6 +108,13 @@ export declare class WidgetApiImpl implements WidgetApi {
|
|
|
108
108
|
roomId?: string;
|
|
109
109
|
stateKey?: string;
|
|
110
110
|
}): Promise<ISendEventFromWidgetResponseData>;
|
|
111
|
+
/** {@inheritDoc WidgetApi.sendDelayedStateEvent} */
|
|
112
|
+
sendDelayedStateEvent<T>(eventType: string, content: T, delay: number, { roomId, stateKey }?: {
|
|
113
|
+
roomId?: string;
|
|
114
|
+
stateKey?: string;
|
|
115
|
+
}): Promise<{
|
|
116
|
+
delay_id: string;
|
|
117
|
+
}>;
|
|
111
118
|
/** {@inheritDoc WidgetApi.receiveRoomEvents} */
|
|
112
119
|
receiveRoomEvents<T>(eventType: string, { messageType, roomIds, }?: {
|
|
113
120
|
messageType?: string;
|
|
@@ -122,6 +129,14 @@ export declare class WidgetApiImpl implements WidgetApi {
|
|
|
122
129
|
sendRoomEvent<T>(eventType: string, content: T, { roomId }?: {
|
|
123
130
|
roomId?: string;
|
|
124
131
|
}): Promise<RoomEvent<T>>;
|
|
132
|
+
/** {@inheritDoc WidgetApi.sendDelayedRoomEvent} */
|
|
133
|
+
sendDelayedRoomEvent<T>(eventType: string, content: T, delay: number, { roomId }?: {
|
|
134
|
+
roomId?: string;
|
|
135
|
+
}): Promise<{
|
|
136
|
+
delay_id: string;
|
|
137
|
+
}>;
|
|
138
|
+
/** {@inheritDoc WidgetApi.updateDelayedEvent} */
|
|
139
|
+
updateDelayedEvent(delayId: string, action: UpdateDelayedEventAction): Promise<void>;
|
|
125
140
|
/** {@inheritDoc WidgetApi.readEventRelations} */
|
|
126
141
|
readEventRelations(eventId: string, options?: {
|
|
127
142
|
roomId?: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Capability, IDownloadFileActionFromWidgetResponseData, IGetMediaConfigActionFromWidgetResponseData, IModalWidgetCreateData, IModalWidgetOpenRequestDataButton, IModalWidgetReturnData, IOpenIDCredentials, IRoomEvent, ISendEventFromWidgetResponseData, IUploadFileActionFromWidgetResponseData, IWidget, IWidgetApiRequest, IWidgetApiRequestData, ModalButtonID, Symbols, WidgetEventCapability } from 'matrix-widget-api';
|
|
1
|
+
import { Capability, IDownloadFileActionFromWidgetResponseData, IGetMediaConfigActionFromWidgetResponseData, IModalWidgetCreateData, IModalWidgetOpenRequestDataButton, IModalWidgetReturnData, IOpenIDCredentials, IRoomEvent, ISendEventFromWidgetResponseData, IUploadFileActionFromWidgetResponseData, IWidget, IWidgetApiRequest, IWidgetApiRequestData, ModalButtonID, Symbols, UpdateDelayedEventAction, WidgetEventCapability } from 'matrix-widget-api';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
3
|
/**
|
|
4
4
|
* Enumeration of widget parameters that can be checked if they are available upon registration.
|
|
@@ -265,6 +265,23 @@ export type WidgetApi = {
|
|
|
265
265
|
roomId?: string;
|
|
266
266
|
stateKey?: string;
|
|
267
267
|
}): Promise<ISendEventFromWidgetResponseData>;
|
|
268
|
+
/**
|
|
269
|
+
* Send a delayed state event with a given type to the current room.
|
|
270
|
+
* @param eventType - The type of the event to send.
|
|
271
|
+
* @param content - The content of the event.
|
|
272
|
+
* @param delay - The delay of the event in milliseconds.
|
|
273
|
+
* @param options - Options for sending the state event.
|
|
274
|
+
* Use `roomId` to send the state event to another room.
|
|
275
|
+
* Use `stateKey` to send a state event with a custom state
|
|
276
|
+
* key.
|
|
277
|
+
* @returns The result data of delayed event with delay_id.
|
|
278
|
+
*/
|
|
279
|
+
sendDelayedStateEvent<T>(eventType: string, content: T, delay: number, options?: {
|
|
280
|
+
roomId?: string;
|
|
281
|
+
stateKey?: string;
|
|
282
|
+
}): Promise<{
|
|
283
|
+
delay_id: string;
|
|
284
|
+
}>;
|
|
268
285
|
/**
|
|
269
286
|
* Receive all room events of a given type from the current room.
|
|
270
287
|
*
|
|
@@ -318,6 +335,28 @@ export type WidgetApi = {
|
|
|
318
335
|
sendRoomEvent<T>(eventType: string, content: T, options?: {
|
|
319
336
|
roomId?: string;
|
|
320
337
|
}): Promise<RoomEvent<T>>;
|
|
338
|
+
/**
|
|
339
|
+
* Send a delayed room event with a given type to the current room.
|
|
340
|
+
* @param eventType - The type of the event to send.
|
|
341
|
+
* @param content - The content of the event.
|
|
342
|
+
* @param delay - The delay of the event in milliseconds.
|
|
343
|
+
* @param options - Options for sending the state event.
|
|
344
|
+
* Use `roomId` to send the state event to another room.
|
|
345
|
+
* Use `stateKey` to send a state event with a custom state
|
|
346
|
+
* key.
|
|
347
|
+
* @returns The result data of delayed event with delay_id.
|
|
348
|
+
*/
|
|
349
|
+
sendDelayedRoomEvent<T>(eventType: string, content: T, delay: number, options?: {
|
|
350
|
+
roomId?: string;
|
|
351
|
+
}): Promise<{
|
|
352
|
+
delay_id: string;
|
|
353
|
+
}>;
|
|
354
|
+
/**
|
|
355
|
+
* Update a delayed event by delay id
|
|
356
|
+
* @param delayId - The delay id of the event
|
|
357
|
+
* @param action - The action to update
|
|
358
|
+
*/
|
|
359
|
+
updateDelayedEvent(delayId: string, action: UpdateDelayedEventAction): Promise<void>;
|
|
321
360
|
/**
|
|
322
361
|
* Receive all events that relate to a given `eventId` by means of MSC2674.
|
|
323
362
|
* `chunk` can include state events or room events.
|
package/build/cjs/index.cjs
CHANGED
|
@@ -181,13 +181,11 @@ var eventSchemaProps = {
|
|
|
181
181
|
// Do roughly check against the format
|
|
182
182
|
// https://spec.matrix.org/v1.13/appendices/#common-identifier-format
|
|
183
183
|
sender: Joi__default.default.string().pattern(new RegExp('^@[^\\s:]*:\\S*$')).required(),
|
|
184
|
-
event_id: Joi__default.default.string().pattern(new RegExp('^\\$.*')).required(),
|
|
185
184
|
room_id: Joi__default.default.string().pattern(new RegExp('^![^:]*:\\S*')).required(),
|
|
186
|
-
origin_server_ts: Joi__default.default.date().timestamp('javascript').required(),
|
|
187
185
|
content: Joi__default.default.object().required(),
|
|
188
186
|
};
|
|
189
|
-
var roomEventSchema = Joi__default.default.object(__assign$2({}, eventSchemaProps)).unknown();
|
|
190
|
-
var stateEventSchema = Joi__default.default.object(__assign$2(__assign$2({}, eventSchemaProps), { state_key: Joi__default.default.string().allow('').required() })).unknown();
|
|
187
|
+
var roomEventSchema = Joi__default.default.object(__assign$2(__assign$2({}, eventSchemaProps), { event_id: Joi__default.default.string().pattern(new RegExp('^\\$.*')).required(), origin_server_ts: Joi__default.default.date().timestamp('javascript').required() })).unknown();
|
|
188
|
+
var stateEventSchema = Joi__default.default.object(__assign$2(__assign$2({}, eventSchemaProps), { event_id: Joi__default.default.string().pattern(new RegExp('^\\$.*')), origin_server_ts: Joi__default.default.date().timestamp('javascript'), state_key: Joi__default.default.string().allow('').required() })).unknown();
|
|
191
189
|
var toDeviceMessageSchema = Joi__default.default.object({
|
|
192
190
|
type: Joi__default.default.string().required(),
|
|
193
191
|
sender: Joi__default.default.string().required(),
|
|
@@ -1531,6 +1529,24 @@ var WidgetApiImpl = /** @class */ (function () {
|
|
|
1531
1529
|
var _b = _a === void 0 ? {} : _a, roomId = _b.roomId, _c = _b.stateKey, stateKey = _c === void 0 ? '' : _c;
|
|
1532
1530
|
return this.matrixWidgetApi.sendStateEvent(eventType, stateKey, content, roomId);
|
|
1533
1531
|
};
|
|
1532
|
+
/** {@inheritDoc WidgetApi.sendDelayedStateEvent} */
|
|
1533
|
+
WidgetApiImpl.prototype.sendDelayedStateEvent = function (eventType_1, content_1, delay_1) {
|
|
1534
|
+
return __awaiter(this, arguments, void 0, function (eventType, content, delay, _a) {
|
|
1535
|
+
var delay_id;
|
|
1536
|
+
var _b = _a === void 0 ? {} : _a, roomId = _b.roomId, _c = _b.stateKey, stateKey = _c === void 0 ? '' : _c;
|
|
1537
|
+
return __generator(this, function (_d) {
|
|
1538
|
+
switch (_d.label) {
|
|
1539
|
+
case 0: return [4 /*yield*/, this.matrixWidgetApi.sendStateEvent(eventType, stateKey, content, roomId, delay)];
|
|
1540
|
+
case 1:
|
|
1541
|
+
delay_id = (_d.sent()).delay_id;
|
|
1542
|
+
if (!delay_id) {
|
|
1543
|
+
throw new Error('Delayed event must have a delay_id');
|
|
1544
|
+
}
|
|
1545
|
+
return [2 /*return*/, { delay_id: delay_id }];
|
|
1546
|
+
}
|
|
1547
|
+
});
|
|
1548
|
+
});
|
|
1549
|
+
};
|
|
1534
1550
|
/** {@inheritDoc WidgetApi.receiveRoomEvents} */
|
|
1535
1551
|
WidgetApiImpl.prototype.receiveRoomEvents = function (eventType_1) {
|
|
1536
1552
|
return __awaiter(this, arguments, void 0, function (eventType, _a) {
|
|
@@ -1599,6 +1615,37 @@ var WidgetApiImpl = /** @class */ (function () {
|
|
|
1599
1615
|
});
|
|
1600
1616
|
});
|
|
1601
1617
|
};
|
|
1618
|
+
/** {@inheritDoc WidgetApi.sendDelayedRoomEvent} */
|
|
1619
|
+
WidgetApiImpl.prototype.sendDelayedRoomEvent = function (eventType_1, content_1, delay_1) {
|
|
1620
|
+
return __awaiter(this, arguments, void 0, function (eventType, content, delay, _a) {
|
|
1621
|
+
var delay_id;
|
|
1622
|
+
var _b = _a === void 0 ? {} : _a, roomId = _b.roomId;
|
|
1623
|
+
return __generator(this, function (_c) {
|
|
1624
|
+
switch (_c.label) {
|
|
1625
|
+
case 0: return [4 /*yield*/, this.matrixWidgetApi.sendRoomEvent(eventType, content, roomId, delay)];
|
|
1626
|
+
case 1:
|
|
1627
|
+
delay_id = (_c.sent()).delay_id;
|
|
1628
|
+
if (!delay_id) {
|
|
1629
|
+
throw new Error('Delayed event must have a delay_id');
|
|
1630
|
+
}
|
|
1631
|
+
return [2 /*return*/, { delay_id: delay_id }];
|
|
1632
|
+
}
|
|
1633
|
+
});
|
|
1634
|
+
});
|
|
1635
|
+
};
|
|
1636
|
+
/** {@inheritDoc WidgetApi.updateDelayedEvent} */
|
|
1637
|
+
WidgetApiImpl.prototype.updateDelayedEvent = function (delayId, action) {
|
|
1638
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1639
|
+
return __generator(this, function (_a) {
|
|
1640
|
+
switch (_a.label) {
|
|
1641
|
+
case 0: return [4 /*yield*/, this.matrixWidgetApi.updateDelayedEvent(delayId, action)];
|
|
1642
|
+
case 1:
|
|
1643
|
+
_a.sent();
|
|
1644
|
+
return [2 /*return*/];
|
|
1645
|
+
}
|
|
1646
|
+
});
|
|
1647
|
+
});
|
|
1648
|
+
};
|
|
1602
1649
|
/** {@inheritDoc WidgetApi.readEventRelations} */
|
|
1603
1650
|
WidgetApiImpl.prototype.readEventRelations = function (eventId, options) {
|
|
1604
1651
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Capability, IDownloadFileActionFromWidgetResponseData, IGetMediaConfigActionFromWidgetResponseData, IModalWidgetCreateData, IModalWidgetOpenRequestDataButton, IModalWidgetReturnData, IOpenIDCredentials, ISendEventFromWidgetResponseData, IUploadFileActionFromWidgetResponseData, IWidgetApiRequestData, WidgetApi as MatrixWidgetApi, ModalButtonID, Symbols, WidgetEventCapability } from 'matrix-widget-api';
|
|
1
|
+
import { Capability, IDownloadFileActionFromWidgetResponseData, IGetMediaConfigActionFromWidgetResponseData, IModalWidgetCreateData, IModalWidgetOpenRequestDataButton, IModalWidgetReturnData, IOpenIDCredentials, ISendEventFromWidgetResponseData, IUploadFileActionFromWidgetResponseData, IWidgetApiRequestData, WidgetApi as MatrixWidgetApi, ModalButtonID, Symbols, UpdateDelayedEventAction, WidgetEventCapability } from 'matrix-widget-api';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
3
|
import { RoomEvent, StateEvent, ToDeviceMessageEvent, TurnServer, WidgetApi, WidgetConfig, WidgetParameters } from './types';
|
|
4
4
|
/**
|
|
@@ -108,6 +108,13 @@ export declare class WidgetApiImpl implements WidgetApi {
|
|
|
108
108
|
roomId?: string;
|
|
109
109
|
stateKey?: string;
|
|
110
110
|
}): Promise<ISendEventFromWidgetResponseData>;
|
|
111
|
+
/** {@inheritDoc WidgetApi.sendDelayedStateEvent} */
|
|
112
|
+
sendDelayedStateEvent<T>(eventType: string, content: T, delay: number, { roomId, stateKey }?: {
|
|
113
|
+
roomId?: string;
|
|
114
|
+
stateKey?: string;
|
|
115
|
+
}): Promise<{
|
|
116
|
+
delay_id: string;
|
|
117
|
+
}>;
|
|
111
118
|
/** {@inheritDoc WidgetApi.receiveRoomEvents} */
|
|
112
119
|
receiveRoomEvents<T>(eventType: string, { messageType, roomIds, }?: {
|
|
113
120
|
messageType?: string;
|
|
@@ -122,6 +129,14 @@ export declare class WidgetApiImpl implements WidgetApi {
|
|
|
122
129
|
sendRoomEvent<T>(eventType: string, content: T, { roomId }?: {
|
|
123
130
|
roomId?: string;
|
|
124
131
|
}): Promise<RoomEvent<T>>;
|
|
132
|
+
/** {@inheritDoc WidgetApi.sendDelayedRoomEvent} */
|
|
133
|
+
sendDelayedRoomEvent<T>(eventType: string, content: T, delay: number, { roomId }?: {
|
|
134
|
+
roomId?: string;
|
|
135
|
+
}): Promise<{
|
|
136
|
+
delay_id: string;
|
|
137
|
+
}>;
|
|
138
|
+
/** {@inheritDoc WidgetApi.updateDelayedEvent} */
|
|
139
|
+
updateDelayedEvent(delayId: string, action: UpdateDelayedEventAction): Promise<void>;
|
|
125
140
|
/** {@inheritDoc WidgetApi.readEventRelations} */
|
|
126
141
|
readEventRelations(eventId: string, options?: {
|
|
127
142
|
roomId?: string;
|
package/build/esm/api/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Capability, IDownloadFileActionFromWidgetResponseData, IGetMediaConfigActionFromWidgetResponseData, IModalWidgetCreateData, IModalWidgetOpenRequestDataButton, IModalWidgetReturnData, IOpenIDCredentials, IRoomEvent, ISendEventFromWidgetResponseData, IUploadFileActionFromWidgetResponseData, IWidget, IWidgetApiRequest, IWidgetApiRequestData, ModalButtonID, Symbols, WidgetEventCapability } from 'matrix-widget-api';
|
|
1
|
+
import { Capability, IDownloadFileActionFromWidgetResponseData, IGetMediaConfigActionFromWidgetResponseData, IModalWidgetCreateData, IModalWidgetOpenRequestDataButton, IModalWidgetReturnData, IOpenIDCredentials, IRoomEvent, ISendEventFromWidgetResponseData, IUploadFileActionFromWidgetResponseData, IWidget, IWidgetApiRequest, IWidgetApiRequestData, ModalButtonID, Symbols, UpdateDelayedEventAction, WidgetEventCapability } from 'matrix-widget-api';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
3
|
/**
|
|
4
4
|
* Enumeration of widget parameters that can be checked if they are available upon registration.
|
|
@@ -265,6 +265,23 @@ export type WidgetApi = {
|
|
|
265
265
|
roomId?: string;
|
|
266
266
|
stateKey?: string;
|
|
267
267
|
}): Promise<ISendEventFromWidgetResponseData>;
|
|
268
|
+
/**
|
|
269
|
+
* Send a delayed state event with a given type to the current room.
|
|
270
|
+
* @param eventType - The type of the event to send.
|
|
271
|
+
* @param content - The content of the event.
|
|
272
|
+
* @param delay - The delay of the event in milliseconds.
|
|
273
|
+
* @param options - Options for sending the state event.
|
|
274
|
+
* Use `roomId` to send the state event to another room.
|
|
275
|
+
* Use `stateKey` to send a state event with a custom state
|
|
276
|
+
* key.
|
|
277
|
+
* @returns The result data of delayed event with delay_id.
|
|
278
|
+
*/
|
|
279
|
+
sendDelayedStateEvent<T>(eventType: string, content: T, delay: number, options?: {
|
|
280
|
+
roomId?: string;
|
|
281
|
+
stateKey?: string;
|
|
282
|
+
}): Promise<{
|
|
283
|
+
delay_id: string;
|
|
284
|
+
}>;
|
|
268
285
|
/**
|
|
269
286
|
* Receive all room events of a given type from the current room.
|
|
270
287
|
*
|
|
@@ -318,6 +335,28 @@ export type WidgetApi = {
|
|
|
318
335
|
sendRoomEvent<T>(eventType: string, content: T, options?: {
|
|
319
336
|
roomId?: string;
|
|
320
337
|
}): Promise<RoomEvent<T>>;
|
|
338
|
+
/**
|
|
339
|
+
* Send a delayed room event with a given type to the current room.
|
|
340
|
+
* @param eventType - The type of the event to send.
|
|
341
|
+
* @param content - The content of the event.
|
|
342
|
+
* @param delay - The delay of the event in milliseconds.
|
|
343
|
+
* @param options - Options for sending the state event.
|
|
344
|
+
* Use `roomId` to send the state event to another room.
|
|
345
|
+
* Use `stateKey` to send a state event with a custom state
|
|
346
|
+
* key.
|
|
347
|
+
* @returns The result data of delayed event with delay_id.
|
|
348
|
+
*/
|
|
349
|
+
sendDelayedRoomEvent<T>(eventType: string, content: T, delay: number, options?: {
|
|
350
|
+
roomId?: string;
|
|
351
|
+
}): Promise<{
|
|
352
|
+
delay_id: string;
|
|
353
|
+
}>;
|
|
354
|
+
/**
|
|
355
|
+
* Update a delayed event by delay id
|
|
356
|
+
* @param delayId - The delay id of the event
|
|
357
|
+
* @param action - The action to update
|
|
358
|
+
*/
|
|
359
|
+
updateDelayedEvent(delayId: string, action: UpdateDelayedEventAction): Promise<void>;
|
|
321
360
|
/**
|
|
322
361
|
* Receive all events that relate to a given `eventId` by means of MSC2674.
|
|
323
362
|
* `chunk` can include state events or room events.
|
package/build/esm/index.js
CHANGED
|
@@ -175,13 +175,11 @@ var eventSchemaProps = {
|
|
|
175
175
|
// Do roughly check against the format
|
|
176
176
|
// https://spec.matrix.org/v1.13/appendices/#common-identifier-format
|
|
177
177
|
sender: Joi.string().pattern(new RegExp('^@[^\\s:]*:\\S*$')).required(),
|
|
178
|
-
event_id: Joi.string().pattern(new RegExp('^\\$.*')).required(),
|
|
179
178
|
room_id: Joi.string().pattern(new RegExp('^![^:]*:\\S*')).required(),
|
|
180
|
-
origin_server_ts: Joi.date().timestamp('javascript').required(),
|
|
181
179
|
content: Joi.object().required(),
|
|
182
180
|
};
|
|
183
|
-
var roomEventSchema = Joi.object(__assign$2({}, eventSchemaProps)).unknown();
|
|
184
|
-
var stateEventSchema = Joi.object(__assign$2(__assign$2({}, eventSchemaProps), { state_key: Joi.string().allow('').required() })).unknown();
|
|
181
|
+
var roomEventSchema = Joi.object(__assign$2(__assign$2({}, eventSchemaProps), { event_id: Joi.string().pattern(new RegExp('^\\$.*')).required(), origin_server_ts: Joi.date().timestamp('javascript').required() })).unknown();
|
|
182
|
+
var stateEventSchema = Joi.object(__assign$2(__assign$2({}, eventSchemaProps), { event_id: Joi.string().pattern(new RegExp('^\\$.*')), origin_server_ts: Joi.date().timestamp('javascript'), state_key: Joi.string().allow('').required() })).unknown();
|
|
185
183
|
var toDeviceMessageSchema = Joi.object({
|
|
186
184
|
type: Joi.string().required(),
|
|
187
185
|
sender: Joi.string().required(),
|
|
@@ -1525,6 +1523,24 @@ var WidgetApiImpl = /** @class */ (function () {
|
|
|
1525
1523
|
var _b = _a === void 0 ? {} : _a, roomId = _b.roomId, _c = _b.stateKey, stateKey = _c === void 0 ? '' : _c;
|
|
1526
1524
|
return this.matrixWidgetApi.sendStateEvent(eventType, stateKey, content, roomId);
|
|
1527
1525
|
};
|
|
1526
|
+
/** {@inheritDoc WidgetApi.sendDelayedStateEvent} */
|
|
1527
|
+
WidgetApiImpl.prototype.sendDelayedStateEvent = function (eventType_1, content_1, delay_1) {
|
|
1528
|
+
return __awaiter(this, arguments, void 0, function (eventType, content, delay, _a) {
|
|
1529
|
+
var delay_id;
|
|
1530
|
+
var _b = _a === void 0 ? {} : _a, roomId = _b.roomId, _c = _b.stateKey, stateKey = _c === void 0 ? '' : _c;
|
|
1531
|
+
return __generator(this, function (_d) {
|
|
1532
|
+
switch (_d.label) {
|
|
1533
|
+
case 0: return [4 /*yield*/, this.matrixWidgetApi.sendStateEvent(eventType, stateKey, content, roomId, delay)];
|
|
1534
|
+
case 1:
|
|
1535
|
+
delay_id = (_d.sent()).delay_id;
|
|
1536
|
+
if (!delay_id) {
|
|
1537
|
+
throw new Error('Delayed event must have a delay_id');
|
|
1538
|
+
}
|
|
1539
|
+
return [2 /*return*/, { delay_id: delay_id }];
|
|
1540
|
+
}
|
|
1541
|
+
});
|
|
1542
|
+
});
|
|
1543
|
+
};
|
|
1528
1544
|
/** {@inheritDoc WidgetApi.receiveRoomEvents} */
|
|
1529
1545
|
WidgetApiImpl.prototype.receiveRoomEvents = function (eventType_1) {
|
|
1530
1546
|
return __awaiter(this, arguments, void 0, function (eventType, _a) {
|
|
@@ -1593,6 +1609,37 @@ var WidgetApiImpl = /** @class */ (function () {
|
|
|
1593
1609
|
});
|
|
1594
1610
|
});
|
|
1595
1611
|
};
|
|
1612
|
+
/** {@inheritDoc WidgetApi.sendDelayedRoomEvent} */
|
|
1613
|
+
WidgetApiImpl.prototype.sendDelayedRoomEvent = function (eventType_1, content_1, delay_1) {
|
|
1614
|
+
return __awaiter(this, arguments, void 0, function (eventType, content, delay, _a) {
|
|
1615
|
+
var delay_id;
|
|
1616
|
+
var _b = _a === void 0 ? {} : _a, roomId = _b.roomId;
|
|
1617
|
+
return __generator(this, function (_c) {
|
|
1618
|
+
switch (_c.label) {
|
|
1619
|
+
case 0: return [4 /*yield*/, this.matrixWidgetApi.sendRoomEvent(eventType, content, roomId, delay)];
|
|
1620
|
+
case 1:
|
|
1621
|
+
delay_id = (_c.sent()).delay_id;
|
|
1622
|
+
if (!delay_id) {
|
|
1623
|
+
throw new Error('Delayed event must have a delay_id');
|
|
1624
|
+
}
|
|
1625
|
+
return [2 /*return*/, { delay_id: delay_id }];
|
|
1626
|
+
}
|
|
1627
|
+
});
|
|
1628
|
+
});
|
|
1629
|
+
};
|
|
1630
|
+
/** {@inheritDoc WidgetApi.updateDelayedEvent} */
|
|
1631
|
+
WidgetApiImpl.prototype.updateDelayedEvent = function (delayId, action) {
|
|
1632
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1633
|
+
return __generator(this, function (_a) {
|
|
1634
|
+
switch (_a.label) {
|
|
1635
|
+
case 0: return [4 /*yield*/, this.matrixWidgetApi.updateDelayedEvent(delayId, action)];
|
|
1636
|
+
case 1:
|
|
1637
|
+
_a.sent();
|
|
1638
|
+
return [2 /*return*/];
|
|
1639
|
+
}
|
|
1640
|
+
});
|
|
1641
|
+
});
|
|
1642
|
+
};
|
|
1596
1643
|
/** {@inheritDoc WidgetApi.readEventRelations} */
|
|
1597
1644
|
WidgetApiImpl.prototype.readEventRelations = function (eventId, options) {
|
|
1598
1645
|
return __awaiter(this, void 0, void 0, function () {
|
package/build/index.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ import { IWidgetApiRequestData } from 'matrix-widget-api';
|
|
|
19
19
|
import { ModalButtonID } from 'matrix-widget-api';
|
|
20
20
|
import { Observable } from 'rxjs';
|
|
21
21
|
import { Symbols } from 'matrix-widget-api';
|
|
22
|
+
import { UpdateDelayedEventAction } from 'matrix-widget-api';
|
|
22
23
|
import { WidgetApi as WidgetApi_2 } from 'matrix-widget-api';
|
|
23
24
|
import { WidgetEventCapability } from 'matrix-widget-api';
|
|
24
25
|
|
|
@@ -582,6 +583,23 @@ export declare type WidgetApi = {
|
|
|
582
583
|
roomId?: string;
|
|
583
584
|
stateKey?: string;
|
|
584
585
|
}): Promise<ISendEventFromWidgetResponseData>;
|
|
586
|
+
/**
|
|
587
|
+
* Send a delayed state event with a given type to the current room.
|
|
588
|
+
* @param eventType - The type of the event to send.
|
|
589
|
+
* @param content - The content of the event.
|
|
590
|
+
* @param delay - The delay of the event in milliseconds.
|
|
591
|
+
* @param options - Options for sending the state event.
|
|
592
|
+
* Use `roomId` to send the state event to another room.
|
|
593
|
+
* Use `stateKey` to send a state event with a custom state
|
|
594
|
+
* key.
|
|
595
|
+
* @returns The result data of delayed event with delay_id.
|
|
596
|
+
*/
|
|
597
|
+
sendDelayedStateEvent<T>(eventType: string, content: T, delay: number, options?: {
|
|
598
|
+
roomId?: string;
|
|
599
|
+
stateKey?: string;
|
|
600
|
+
}): Promise<{
|
|
601
|
+
delay_id: string;
|
|
602
|
+
}>;
|
|
585
603
|
/**
|
|
586
604
|
* Receive all room events of a given type from the current room.
|
|
587
605
|
*
|
|
@@ -635,6 +653,28 @@ export declare type WidgetApi = {
|
|
|
635
653
|
sendRoomEvent<T>(eventType: string, content: T, options?: {
|
|
636
654
|
roomId?: string;
|
|
637
655
|
}): Promise<RoomEvent<T>>;
|
|
656
|
+
/**
|
|
657
|
+
* Send a delayed room event with a given type to the current room.
|
|
658
|
+
* @param eventType - The type of the event to send.
|
|
659
|
+
* @param content - The content of the event.
|
|
660
|
+
* @param delay - The delay of the event in milliseconds.
|
|
661
|
+
* @param options - Options for sending the state event.
|
|
662
|
+
* Use `roomId` to send the state event to another room.
|
|
663
|
+
* Use `stateKey` to send a state event with a custom state
|
|
664
|
+
* key.
|
|
665
|
+
* @returns The result data of delayed event with delay_id.
|
|
666
|
+
*/
|
|
667
|
+
sendDelayedRoomEvent<T>(eventType: string, content: T, delay: number, options?: {
|
|
668
|
+
roomId?: string;
|
|
669
|
+
}): Promise<{
|
|
670
|
+
delay_id: string;
|
|
671
|
+
}>;
|
|
672
|
+
/**
|
|
673
|
+
* Update a delayed event by delay id
|
|
674
|
+
* @param delayId - The delay id of the event
|
|
675
|
+
* @param action - The action to update
|
|
676
|
+
*/
|
|
677
|
+
updateDelayedEvent(delayId: string, action: UpdateDelayedEventAction): Promise<void>;
|
|
638
678
|
/**
|
|
639
679
|
* Receive all events that relate to a given `eventId` by means of MSC2674.
|
|
640
680
|
* `chunk` can include state events or room events.
|
|
@@ -898,6 +938,13 @@ export declare class WidgetApiImpl implements WidgetApi {
|
|
|
898
938
|
roomId?: string;
|
|
899
939
|
stateKey?: string;
|
|
900
940
|
}): Promise<ISendEventFromWidgetResponseData>;
|
|
941
|
+
/** {@inheritDoc WidgetApi.sendDelayedStateEvent} */
|
|
942
|
+
sendDelayedStateEvent<T>(eventType: string, content: T, delay: number, { roomId, stateKey }?: {
|
|
943
|
+
roomId?: string;
|
|
944
|
+
stateKey?: string;
|
|
945
|
+
}): Promise<{
|
|
946
|
+
delay_id: string;
|
|
947
|
+
}>;
|
|
901
948
|
/** {@inheritDoc WidgetApi.receiveRoomEvents} */
|
|
902
949
|
receiveRoomEvents<T>(eventType: string, { messageType, roomIds, }?: {
|
|
903
950
|
messageType?: string;
|
|
@@ -912,6 +959,14 @@ export declare class WidgetApiImpl implements WidgetApi {
|
|
|
912
959
|
sendRoomEvent<T>(eventType: string, content: T, { roomId }?: {
|
|
913
960
|
roomId?: string;
|
|
914
961
|
}): Promise<RoomEvent<T>>;
|
|
962
|
+
/** {@inheritDoc WidgetApi.sendDelayedRoomEvent} */
|
|
963
|
+
sendDelayedRoomEvent<T>(eventType: string, content: T, delay: number, { roomId }?: {
|
|
964
|
+
roomId?: string;
|
|
965
|
+
}): Promise<{
|
|
966
|
+
delay_id: string;
|
|
967
|
+
}>;
|
|
968
|
+
/** {@inheritDoc WidgetApi.updateDelayedEvent} */
|
|
969
|
+
updateDelayedEvent(delayId: string, action: UpdateDelayedEventAction): Promise<void>;
|
|
915
970
|
/** {@inheritDoc WidgetApi.readEventRelations} */
|
|
916
971
|
readEventRelations(eventId: string, options?: {
|
|
917
972
|
roomId?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@matrix-widget-toolkit/api",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"description": "A simplified layer on top of matrix-widget-api to use build widgets.",
|
|
5
5
|
"author": "Nordeck IT + Consulting GmbH",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -22,13 +22,13 @@
|
|
|
22
22
|
},
|
|
23
23
|
"type": "module",
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@rollup/plugin-commonjs": "28.0.
|
|
26
|
-
"@types/node": "22.
|
|
27
|
-
"@types/qs": "6.
|
|
28
|
-
"@vitest/coverage-v8": "3.
|
|
29
|
-
"typescript": "5.
|
|
30
|
-
"vite": "6.
|
|
31
|
-
"vitest": "3.
|
|
25
|
+
"@rollup/plugin-commonjs": "28.0.3",
|
|
26
|
+
"@types/node": "22.15.30",
|
|
27
|
+
"@types/qs": "6.14.0",
|
|
28
|
+
"@vitest/coverage-v8": "3.2.2",
|
|
29
|
+
"typescript": "5.8.3",
|
|
30
|
+
"vite": "6.3.5",
|
|
31
|
+
"vitest": "3.2.2"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
34
|
"build": "tsc && rollup --config ../../rollup.config.mjs",
|