// Copyright Abridged, Inc. 2022,2024. All Rights Reserved. // Node module: @collabland/aws // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT import { getResourceName, isMain, pMap, ResourceType, stringify, } from '@collabland/common'; import {DynamoDbServiceClient} from '../index.js'; async function main() { const service = new DynamoDbServiceClient(); const streams = await service.listStreams( getResourceName(ResourceType.DynamoDBTable), ); console.log(streams); const streamArn = streams[0].StreamArn!; const result = await service.getStreamShards(streamArn, 10); await pMap(result.shards, async shard => { const iterator = await service.getSharedIterator( streamArn, shard.ShardId!, 'TRIM_HORIZON', ); if (iterator == null) return; const records = await service.getStreamRecords(iterator, 100); console.log(stringify(records)); }); } if (isMain(import.meta.url)) { await main(); }