import { BaseResourceAPI } from '@cognite/sdk-core'; import { RecordAggregateRequestWithTyping, RecordAggregateRequestWithoutTyping, RecordAggregateResponse, RecordAggregateResults, RecordDelete, RecordFilterRequestWithTyping, RecordFilterRequestWithoutTyping, RecordFilterResponse, RecordItem, RecordSyncRequest, RecordWrite, RecordsSyncCursorAndAsyncIterator, SyncRecordItem } from './types'; export declare class RecordsAPI extends BaseResourceAPI { /** * @hidden */ protected getDateProps(): [string[], string[]]; /** * [Ingest records into a stream](https://developer.cognite.com/api#tag/Records/operation/ingestRecords) * * Ingest records into a stream. * * ```js * await client.records.ingest('my_stream', [ * { * space: 'mySpace', * externalId: 'record1', * sources: [ * { * source: { type: 'container', space: 'mySpace', externalId: 'myContainer' }, * properties: { temperature: 25.5, timestamp: '2025-01-01T00:00:00Z' } * } * ] * } * ]); * ``` */ ingest: (streamExternalId: string, items: RecordWrite[]) => Promise; /** * [Upsert records into a stream](https://developer.cognite.com/api#tag/Records/operation/upsertRecords) * * Create or update records in a mutable stream. If a record with the same * space + externalId already exists, it will be fully replaced (no partial updates). * * **Note:** This endpoint is only available for mutable streams. * * ```js * await client.records.upsert('my_mutable_stream', [ * { * space: 'mySpace', * externalId: 'record1', * sources: [ * { * source: { type: 'container', space: 'mySpace', externalId: 'myContainer' }, * properties: { temperature: 30.0, timestamp: '2025-01-01T00:00:00Z' } * } * ] * } * ]); * ``` */ upsert: (streamExternalId: string, items: RecordWrite[]) => Promise; /** * [Delete records from a stream](https://developer.cognite.com/api#tag/Records/operation/deleteRecords) * * Delete records from a mutable stream. The operation is idempotent - deleting * non-existent records will not cause an error. * * **Note:** This endpoint is only available for mutable streams. * * ```js * await client.records.delete('my_mutable_stream', [ * { space: 'mySpace', externalId: 'record1' }, * { space: 'mySpace', externalId: 'record2' } * ]); * ``` */ delete: (streamExternalId: string, items: RecordDelete[]) => Promise; /** * [Filter records from a stream](https://developer.cognite.com/api#tag/Records/operation/filterRecords) * * Retrieve records from a stream using filters. Pass includeTyping: true to * receive an object with items and typing instead of a bare array. * * ```js * const records = await client.records.filter('my_stream', { * sources: [ * { * source: { type: 'container', space: 'mySpace', externalId: 'myContainer' }, * properties: ['*'] * } * ], * filter: { * equals: { * property: ['mySpace', 'myContainer', 'status'], * value: 'active' * } * }, * limit: 100 * }); * ``` */ filter(streamExternalId: string, request: RecordFilterRequestWithTyping): Promise; filter(streamExternalId: string, request?: RecordFilterRequestWithoutTyping): Promise; /** * [Sync records from a stream](https://developer.cognite.com/api#tag/Records/operation/syncRecords) * * Sync records from a stream using a cursor-based approach. Supports both * auto-pagination and manual pagination. The sync API always returns * nextCursor (for resumption) and hasNext (to indicate whether more * data is immediately available). Auto-pagination uses hasNext to * determine when to stop. * * ```js * const response = await client.records.sync('my_stream', { * initializeCursor: '1d-ago', * sources: [{ source: { type: 'container', space: 'mySpace', externalId: 'myContainer' }, properties: ['*'] }], * }); * console.log(response.items, response.nextCursor, response.hasNext, response.typing); * ``` */ sync: (streamExternalId: string, request: RecordSyncRequest) => RecordsSyncCursorAndAsyncIterator; /** * [Aggregate records from a stream](https://developer.cognite.com/api#tag/Records/operation/aggregateRecords) * * Aggregate data for records from a stream. Pass includeTyping: true to * receive an object with aggregates and typing instead of bare results. * * ```js * const aggregates = await client.records.aggregate('my_stream', { * aggregates: { * total_count: { count: {} }, * by_category: { * uniqueValues: { * property: ['mySpace', 'myContainer', 'category'], * aggregates: { total: { sum: { property: ['mySpace', 'myContainer', 'amount'] } } } * } * } * } * }); * ``` */ aggregate(streamExternalId: string, request: RecordAggregateRequestWithTyping): Promise; aggregate(streamExternalId: string, request: RecordAggregateRequestWithoutTyping): Promise; }