@matrix-widget-toolkit/api 1.0.1 → 2.0.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 CHANGED
@@ -1,5 +1,7 @@
1
1
  # `@matrix-widget-toolkit/api`
2
2
 
3
+ [![@matrix-widget-toolkit/api](https://img.shields.io/npm/v/@matrix-widget-toolkit/api)](https://www.npmjs.com/package/@matrix-widget-toolkit/api)
4
+
3
5
  This is package that wraps `matrix-widget-api` to provide a more convenient API.
4
6
  For now, the API includes:
5
7
 
@@ -1441,16 +1441,15 @@ var WidgetApiImpl = /** @class */ (function () {
1441
1441
  /** {@inheritDoc WidgetApi.readEventRelations} */
1442
1442
  WidgetApiImpl.prototype.readEventRelations = function (eventId, options) {
1443
1443
  return __awaiter(this, void 0, void 0, function () {
1444
- var _a, original_event, chunk, next_batch;
1444
+ var _a, chunk, next_batch;
1445
1445
  return __generator(this, function (_b) {
1446
1446
  switch (_b.label) {
1447
- case 0: return [4 /*yield*/, this.matrixWidgetApi.readEventRelations(eventId, options === null || options === void 0 ? void 0 : options.roomId, options === null || options === void 0 ? void 0 : options.relationType, options === null || options === void 0 ? void 0 : options.eventType, options === null || options === void 0 ? void 0 : options.limit, options === null || options === void 0 ? void 0 : options.from)];
1447
+ case 0: return [4 /*yield*/, this.matrixWidgetApi.readEventRelations(eventId, options === null || options === void 0 ? void 0 : options.roomId, options === null || options === void 0 ? void 0 : options.relationType, options === null || options === void 0 ? void 0 : options.eventType, options === null || options === void 0 ? void 0 : options.limit, options === null || options === void 0 ? void 0 : options.from, undefined, options === null || options === void 0 ? void 0 : options.direction)];
1448
1448
  case 1:
1449
- _a = _b.sent(), original_event = _a.original_event, chunk = _a.chunk, next_batch = _a.next_batch;
1449
+ _a = _b.sent(), chunk = _a.chunk, next_batch = _a.next_batch;
1450
1450
  return [2 /*return*/, {
1451
- originalEvent: original_event,
1452
1451
  chunk: chunk,
1453
- nextToken: next_batch,
1452
+ nextToken: next_batch !== null && next_batch !== void 0 ? next_batch : undefined,
1454
1453
  }];
1455
1454
  }
1456
1455
  });
@@ -1439,16 +1439,15 @@ var WidgetApiImpl = /** @class */ (function () {
1439
1439
  /** {@inheritDoc WidgetApi.readEventRelations} */
1440
1440
  WidgetApiImpl.prototype.readEventRelations = function (eventId, options) {
1441
1441
  return __awaiter(this, void 0, void 0, function () {
1442
- var _a, original_event, chunk, next_batch;
1442
+ var _a, chunk, next_batch;
1443
1443
  return __generator(this, function (_b) {
1444
1444
  switch (_b.label) {
1445
- case 0: return [4 /*yield*/, this.matrixWidgetApi.readEventRelations(eventId, options === null || options === void 0 ? void 0 : options.roomId, options === null || options === void 0 ? void 0 : options.relationType, options === null || options === void 0 ? void 0 : options.eventType, options === null || options === void 0 ? void 0 : options.limit, options === null || options === void 0 ? void 0 : options.from)];
1445
+ case 0: return [4 /*yield*/, this.matrixWidgetApi.readEventRelations(eventId, options === null || options === void 0 ? void 0 : options.roomId, options === null || options === void 0 ? void 0 : options.relationType, options === null || options === void 0 ? void 0 : options.eventType, options === null || options === void 0 ? void 0 : options.limit, options === null || options === void 0 ? void 0 : options.from, undefined, options === null || options === void 0 ? void 0 : options.direction)];
1446
1446
  case 1:
1447
- _a = _b.sent(), original_event = _a.original_event, chunk = _a.chunk, next_batch = _a.next_batch;
1447
+ _a = _b.sent(), chunk = _a.chunk, next_batch = _a.next_batch;
1448
1448
  return [2 /*return*/, {
1449
- originalEvent: original_event,
1450
1449
  chunk: chunk,
1451
- nextToken: next_batch,
1450
+ nextToken: next_batch !== null && next_batch !== void 0 ? next_batch : undefined,
1452
1451
  }];
1453
1452
  }
1454
1453
  });
package/build/index.d.ts CHANGED
@@ -571,15 +571,14 @@ export declare type WidgetApi = {
571
571
  roomId?: string;
572
572
  }): Promise<RoomEvent<T>>;
573
573
  /**
574
- * Receive an event with a given `eventId` and all events that relate to it by
575
- * means of MSC2674. Both `originalEvent` and `chunk` can include state events
576
- * or room events.
574
+ * Receive all events that relate to a given `eventId` by means of MSC2674.
575
+ * `chunk` can include state events or room events.
577
576
  *
578
577
  * @remarks You can only receive events where the capability to receive it was
579
- * approved. If `originalEvent` is not approved, an exception is thrown.
580
- * If an event in `chunk` is not approve, it is silently skipped. Note
581
- * that the call might return less than `limit` events due to various
582
- * reasons, including missing capabilities or encrypted events.
578
+ * approved. If an event in `chunk` is not approved, it is silently
579
+ * skipped. Note that the call might return less than `limit` events
580
+ * due to various reasons, including missing capabilities or encrypted
581
+ * events.
583
582
  *
584
583
  * @param eventId - The id of the event to receive
585
584
  * @param options - Options for receiving the related events.
@@ -590,6 +589,8 @@ export declare type WidgetApi = {
590
589
  * no further page exists.
591
590
  * Use `relationType` to only return events with that `rel_type`.
592
591
  * Use `eventType` to only return events with that `type`.
592
+ * Use `direction` to change time-order of the chunks
593
+ * (default: 'b').
593
594
  *
594
595
  * @throws if the capability to receive the type of event is missing.
595
596
  */
@@ -599,8 +600,8 @@ export declare type WidgetApi = {
599
600
  from?: string;
600
601
  relationType?: string;
601
602
  eventType?: string;
603
+ direction?: 'f' | 'b';
602
604
  }): Promise<{
603
- originalEvent?: RoomEvent | StateEvent;
604
605
  chunk: Array<RoomEvent | StateEvent>;
605
606
  nextToken?: string;
606
607
  }>;
@@ -791,8 +792,8 @@ export declare class WidgetApiImpl implements WidgetApi {
791
792
  from?: string;
792
793
  relationType?: string;
793
794
  eventType?: string;
795
+ direction?: 'f' | 'b';
794
796
  }): Promise<{
795
- originalEvent?: RoomEvent | StateEvent;
796
797
  chunk: Array<RoomEvent | StateEvent>;
797
798
  nextToken?: string;
798
799
  }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@matrix-widget-toolkit/api",
3
- "version": "1.0.1",
3
+ "version": "2.0.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",
@@ -10,7 +10,7 @@
10
10
  "devDependencies": {
11
11
  "@craco/craco": "^6.4.5",
12
12
  "@types/jest": "^27.5.2",
13
- "@types/node": "^16.11.64",
13
+ "@types/node": "^16.18.11",
14
14
  "@types/qs": "^6.9.7",
15
15
  "typescript": "^4.8.4"
16
16
  },
@@ -29,7 +29,7 @@
29
29
  "dependencies": {
30
30
  "matrix-widget-api": "^1.1.1",
31
31
  "qs": "^6.11.0",
32
- "rxjs": "^7.5.7"
32
+ "rxjs": "^7.8.0"
33
33
  },
34
34
  "repository": {
35
35
  "type": "git",