@contrail/documents 2.4.0-alpha.4805e08 → 2.4.0-alpha.66cee0e

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.
@@ -10,6 +10,7 @@ export declare class DocumentContainerIndex {
10
10
  memberIdsByContainerId: Map<string, string[]>;
11
11
  containerIdsByElementType: Map<string, string[]>;
12
12
  });
13
+ static empty(): DocumentContainerIndex;
13
14
  getContainer(containerId: string): DocumentContainer | null;
14
15
  containersOf(documentElementId: string, elementType: ContainerElementType): DocumentContainer[];
15
16
  containerIdsOf(documentElementId: string, elementType: ContainerElementType): readonly string[];
@@ -6,6 +6,15 @@ class DocumentContainerIndex {
6
6
  constructor(data) {
7
7
  this.data = data;
8
8
  }
9
+ static empty() {
10
+ return new DocumentContainerIndex({
11
+ documentElementsById: new Map(),
12
+ containersById: new Map(),
13
+ containerPathsByDocumentElementId: new Map(),
14
+ memberIdsByContainerId: new Map(),
15
+ containerIdsByElementType: new Map(),
16
+ });
17
+ }
9
18
  getContainer(containerId) {
10
19
  var _a;
11
20
  return (_a = this.data.containersById.get(containerId)) !== null && _a !== void 0 ? _a : null;
@@ -9,6 +9,10 @@ class DocumentContainerService {
9
9
  static buildIndex(documentElements, kinds = container_kind_1.CONTAINER_KINDS) {
10
10
  var _a, _b;
11
11
  const elements = documentElements !== null && documentElements !== void 0 ? documentElements : [];
12
+ const containerElementTypes = new Set(kinds.map((kind) => kind.elementType));
13
+ if (!elements.some((element) => containerElementTypes.has(element === null || element === void 0 ? void 0 : element.type))) {
14
+ return document_container_index_1.DocumentContainerIndex.empty();
15
+ }
12
16
  const documentElementsById = new Map(elements.map((element) => [element.id, element]));
13
17
  const measuredDocumentElements = this.measureDocumentElements(elements, documentElementsById);
14
18
  const containersByElementType = new Map(kinds.map((kind) => [kind.elementType, this.collectContainers(measuredDocumentElements, kind)]));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/documents",
3
- "version": "2.4.0-alpha.4805e08",
3
+ "version": "2.4.0-alpha.66cee0e",
4
4
  "description": "Documents library for contrail platform",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",