@cognite/reveal 4.28.1 → 4.28.2

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.
@@ -0,0 +1,36 @@
1
+ /*!
2
+ * Copyright 2025 Cognite AS
3
+ */
4
+ import { CogniteClient } from '@cognite/sdk';
5
+ import { DataModelsSdk } from '../../../../DataModelsSdk';
6
+ import type { Historical360ImageSet } from '../../../../types';
7
+ import type { DMDataSourceType } from '../../../../DataSourceType';
8
+ import { DMInstanceKey, DMInstanceRef } from '../../../../../../utilities';
9
+ import { BatchLoader } from '../../../../utilities/BatchLoader';
10
+ /**
11
+ * Coordinates batched loading of multiple 360 image collections.
12
+ * Instead of loading each collection individually (1000 queries for 1000 collections),
13
+ * it batches them into groups and makes far fewer queries (e.g., 20 queries for 1000 collections).
14
+ * This allows collections with any number of images, not just ~200 per collection (10,000 / 50 batch size).
15
+ */
16
+ export declare class Cdf360CdmBatchCollectionLoader extends BatchLoader<DMInstanceRef, Historical360ImageSet<DMDataSourceType>[]> {
17
+ private readonly _dmsSdk;
18
+ private readonly _cogniteSdk;
19
+ constructor(dmsSdk: DataModelsSdk, cogniteSdk: CogniteClient);
20
+ getCollectionDescriptors(identifier: DMInstanceRef): Promise<Historical360ImageSet<DMDataSourceType>[]>;
21
+ protected fetchBatch(identifiers: DMInstanceRef[]): Promise<Map<DMInstanceKey, Historical360ImageSet<DMDataSourceType>[]>>;
22
+ protected getKeyForIdentifier(identifier: DMInstanceRef): DMInstanceKey;
23
+ protected getDefaultResult(_identifier: DMInstanceRef): Historical360ImageSet<DMDataSourceType>[];
24
+ private fetchAllPages;
25
+ private groupResultsByCollection;
26
+ private getFileDescriptorsForBatch;
27
+ private getFileDescriptorsForImages;
28
+ private createHistoricalImageSets;
29
+ private getHistorical360ImageSet;
30
+ private getImageRevision;
31
+ private getFaceDescriptors;
32
+ private getRevisionTransform;
33
+ private getCdmFiles;
34
+ private stringifyValue;
35
+ private toNumber;
36
+ }
@@ -7,12 +7,7 @@ import { Image360DataModelIdentifier } from '../system-space/Cdf360DataModelsDes
7
7
  import { DMDataSourceType } from '../../../../DataSourceType';
8
8
  export declare class Cdf360CdmDescriptorProvider implements Image360DescriptorProvider<DMDataSourceType> {
9
9
  private readonly _dmsSdk;
10
- private readonly _cogniteSdk;
10
+ private readonly _batchLoader;
11
11
  constructor(sdk: CogniteClient);
12
12
  get360ImageDescriptors(collectionIdentifier: Image360DataModelIdentifier, _: boolean): Promise<Historical360ImageSet<DMDataSourceType>[]>;
13
- private queryCollection;
14
- private getFileDescriptors;
15
- private getHistorical360ImageSet;
16
- private getImageRevision;
17
- private getRevisionTransform;
18
13
  }
@@ -0,0 +1,95 @@
1
+ /*!
2
+ * Copyright 2025 Cognite AS
3
+ */
4
+ import { DMInstanceRef } from '../../../../../../utilities';
5
+ declare function createCollectionsQuery(instanceReferences: DMInstanceRef[]): {
6
+ with: {
7
+ image_collections: {
8
+ nodes: {
9
+ filter: {
10
+ instanceReferences: DMInstanceRef[];
11
+ };
12
+ };
13
+ limit: number;
14
+ };
15
+ images: {
16
+ nodes: {
17
+ from: string;
18
+ through: {
19
+ view: {
20
+ readonly externalId: "Cognite360Image";
21
+ readonly space: "cdf_cdm";
22
+ readonly version: "v1";
23
+ readonly type: "view";
24
+ };
25
+ identifier: string;
26
+ };
27
+ };
28
+ limit: number;
29
+ };
30
+ stations: {
31
+ nodes: {
32
+ from: string;
33
+ through: {
34
+ view: {
35
+ readonly externalId: "Cognite360Image";
36
+ readonly space: "cdf_cdm";
37
+ readonly version: "v1";
38
+ readonly type: "view";
39
+ };
40
+ identifier: string;
41
+ };
42
+ direction: "outwards";
43
+ };
44
+ limit: number;
45
+ };
46
+ };
47
+ select: {
48
+ image_collections: {
49
+ sources: {
50
+ source: {
51
+ readonly externalId: "Cognite360ImageCollection";
52
+ readonly space: "cdf_cdm";
53
+ readonly version: "v1";
54
+ readonly type: "view";
55
+ };
56
+ properties: string[];
57
+ }[];
58
+ };
59
+ images: {
60
+ sources: {
61
+ source: {
62
+ readonly externalId: "Cognite360Image";
63
+ readonly space: "cdf_cdm";
64
+ readonly version: "v1";
65
+ readonly type: "view";
66
+ };
67
+ properties: ["translationX", "translationY", "translationZ", "eulerRotationX", "eulerRotationY", "eulerRotationZ", "scaleX", "scaleY", "scaleZ", "front", "back", "left", "right", "top", "bottom", "collection360", "station360", "takenAt"];
68
+ }[];
69
+ };
70
+ stations: {
71
+ sources: {
72
+ source: {
73
+ readonly externalId: "Cognite360ImageStation";
74
+ readonly space: "cdf_cdm";
75
+ readonly version: "v1";
76
+ readonly type: "view";
77
+ };
78
+ properties: string[];
79
+ }[];
80
+ };
81
+ };
82
+ };
83
+ export type CdfImage360CollectionDmQuery = ReturnType<typeof createCollectionsQuery>;
84
+ /**
85
+ * Creates a DMS query to fetch multiple 360 image collections in a single request.
86
+ * This is much more efficient than making individual queries per collection.
87
+ *
88
+ * @param collectionRefs - Array of collection identifiers to fetch
89
+ * @returns DMS query that fetches all collections and their images in one request
90
+ */
91
+ export declare function get360CdmCollectionsQuery(collectionRefs: Array<{
92
+ externalId: string;
93
+ space: string;
94
+ }>): CdfImage360CollectionDmQuery;
95
+ export {};
@@ -0,0 +1,66 @@
1
+ /*!
2
+ * Copyright 2025 Cognite AS
3
+ */
4
+ /**
5
+ * Generic batch loader for accumulating and processing requests in batches.
6
+ * This prevents overwhelming APIs with thousands of individual requests by grouping them.
7
+ *
8
+ * Example use cases:
9
+ * - Batching DMS queries for multiple 360 image collections
10
+ * - Batching CDF Events/Files API calls for event-based 360 images
11
+ * - Batching point cloud data fetching
12
+ *
13
+ * @template TIdentifier - Type of the identifier used to request data (e.g., DMInstanceRef, string)
14
+ * @template TResult - Type of the result returned for each identifier
15
+ */
16
+ export declare abstract class BatchLoader<TIdentifier, TResult> {
17
+ private readonly _batchSize;
18
+ private readonly _batchDelayMs;
19
+ private readonly _pendingBatch;
20
+ private _batchTimer;
21
+ private _isProcessing;
22
+ /**
23
+ * @param _batchSize - Maximum number of identifiers to process in a single batch
24
+ * @param _batchDelayMs - Delay in milliseconds to wait for more requests before executing batch
25
+ */
26
+ constructor(_batchSize: number, _batchDelayMs: number);
27
+ /**
28
+ * Load data for the given identifier. Requests are automatically batched.
29
+ *
30
+ * @param identifier - The identifier to load data for
31
+ * @returns Promise that resolves with the result for this identifier
32
+ */
33
+ load(identifier: TIdentifier): Promise<TResult>;
34
+ /**
35
+ * Try to execute a batch. If already processing, this will be a no-op.
36
+ * The next batch will be picked up when the current one finishes.
37
+ */
38
+ private tryExecuteBatch;
39
+ /**
40
+ * Execute a batch of requests.
41
+ */
42
+ private executeBatch;
43
+ /**
44
+ * Fetch data for a batch of identifiers. This is where the actual API calls happen.
45
+ *
46
+ * @param identifiers - Array of identifiers to fetch data for
47
+ * @returns Map of key to result, where key is generated by getKeyForIdentifier
48
+ */
49
+ protected abstract fetchBatch(identifiers: TIdentifier[]): Promise<Map<string, TResult>>;
50
+ /**
51
+ * Convert an identifier to a string key for mapping results.
52
+ * This key is used to match requests with their results.
53
+ *
54
+ * @param identifier - The identifier to convert
55
+ * @returns String key uniquely identifying this identifier
56
+ */
57
+ protected abstract getKeyForIdentifier(identifier: TIdentifier): string;
58
+ /**
59
+ * Get the default result when an identifier is not found in the batch results.
60
+ * This is called when fetchBatch doesn't return a result for a given identifier.
61
+ *
62
+ * @param identifier - The identifier that wasn't found
63
+ * @returns Default result to return
64
+ */
65
+ protected abstract getDefaultResult(identifier: TIdentifier): TResult;
66
+ }
@@ -0,0 +1,15 @@
1
+ /*!
2
+ * Copyright 2025 Cognite AS
3
+ */
4
+ /**
5
+ * Determines if DMS query pagination should continue and returns the cursor.
6
+ * Pagination continues only when the result set reached the limit, indicating more data may exist.
7
+ *
8
+ * @param results - The array of results from the current page
9
+ * @param nextCursor - The cursor object from the DMS response
10
+ * @param cursorKey - The key to extract from the cursor object (e.g., 'images', 'nodes')
11
+ * @param limit - The limit used in the query
12
+ * @returns The cursor string if pagination should continue, undefined otherwise
13
+ *
14
+ */
15
+ export declare function getDmsPaginationCursor(results: unknown[] | undefined, nextCursor: Record<string, string> | undefined, cursorKey: string, limit: number): string | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cognite/reveal",
3
- "version": "4.28.1",
3
+ "version": "4.28.2",
4
4
  "description": "WebGL based 3D viewer for CAD and point clouds processed in Cognite Data Fusion.",
5
5
  "homepage": "https://github.com/cognitedata/reveal/tree/master/viewer",
6
6
  "repository": {
@@ -1,103 +0,0 @@
1
- /*!
2
- * Copyright 2023 Cognite AS
3
- */
4
- declare const Image360CollectionQuery: {
5
- readonly with: {
6
- readonly image_collection: {
7
- readonly nodes: {
8
- readonly filter: {
9
- readonly and: readonly [{
10
- readonly equals: {
11
- readonly property: readonly ["node", "externalId"];
12
- readonly value: {
13
- readonly parameter: "collectionExternalId";
14
- };
15
- };
16
- }, {
17
- readonly equals: {
18
- readonly property: readonly ["node", "space"];
19
- readonly value: {
20
- readonly parameter: "collectionSpace";
21
- };
22
- };
23
- }];
24
- };
25
- };
26
- readonly limit: 1;
27
- };
28
- readonly images: {
29
- readonly nodes: {
30
- readonly from: "image_collection";
31
- readonly through: {
32
- readonly view: {
33
- readonly type: "view";
34
- readonly space: "cdf_cdm";
35
- readonly externalId: "Cognite360Image";
36
- readonly version: "v1";
37
- };
38
- readonly identifier: "collection360";
39
- };
40
- };
41
- readonly limit: 10000;
42
- };
43
- readonly stations: {
44
- readonly nodes: {
45
- readonly from: "images";
46
- readonly through: {
47
- readonly view: {
48
- readonly type: "view";
49
- readonly space: "cdf_cdm";
50
- readonly externalId: "Cognite360Image";
51
- readonly version: "v1";
52
- };
53
- readonly identifier: "station360";
54
- };
55
- readonly direction: "outwards";
56
- };
57
- readonly limit: 10000;
58
- };
59
- };
60
- readonly select: {
61
- readonly image_collection: {
62
- readonly sources: readonly [{
63
- readonly source: {
64
- readonly type: "view";
65
- readonly space: "cdf_cdm";
66
- readonly externalId: "Cognite360ImageCollection";
67
- readonly version: "v1";
68
- };
69
- readonly properties: readonly ["name"];
70
- }];
71
- };
72
- readonly images: {
73
- readonly sources: readonly [{
74
- readonly source: {
75
- readonly type: "view";
76
- readonly space: "cdf_cdm";
77
- readonly externalId: "Cognite360Image";
78
- readonly version: "v1";
79
- };
80
- readonly properties: readonly ["translationX", "translationY", "translationZ", "eulerRotationX", "eulerRotationY", "eulerRotationZ", "scaleX", "scaleY", "scaleZ", "front", "back", "left", "right", "top", "bottom", "collection360", "station360", "takenAt"];
81
- }];
82
- };
83
- readonly stations: {
84
- readonly sources: readonly [{
85
- readonly source: {
86
- readonly type: "view";
87
- readonly space: "cdf_cdm";
88
- readonly externalId: "Cognite360ImageStation";
89
- readonly version: "v1";
90
- };
91
- readonly properties: readonly ["name"];
92
- }];
93
- };
94
- };
95
- };
96
- export type Cdf360FdmQuery = typeof Image360CollectionQuery;
97
- export declare function get360CollectionQuery(externalId: string, space: string): Cdf360FdmQuery & {
98
- parameters: {
99
- collectionExternalId: string;
100
- collectionSpace: string;
101
- };
102
- };
103
- export {};