import {
  batchGetWithRetry,
  dispatchListMode
} from "./chunk-V6AO5T57.mjs";
import {
  SHARD_COUNT,
  getDynamoControlService
} from "./chunk-EUIP2U5F.mjs";

// src/data/operations/control/membership/membership-list-operation.ts
var SK = "CURRENT";
async function listMembershipsOperation(params) {
  const { context, tableName, mode = "full" } = params;
  const tenantId = context.tenantId;
  const service = getDynamoControlService(tableName);
  const shardResults = await Promise.all(
    Array.from(
      { length: SHARD_COUNT },
      (_, shard) => service.entities.membership.query.gsi1({ tenantId, gsi1Shard: String(shard) }).go()
    )
  );
  return dispatchListMode(mode, shardResults, {
    hydrate: (orderedIds) => batchGetWithRetry(
      service.entities.membership,
      orderedIds.map((id) => ({ tenantId, id, sk: SK }))
    ),
    getId: (item) => item.id,
    buildEntry: (id, item) => ({
      id,
      resource: {
        resourceType: "Membership",
        id,
        ...JSON.parse(item.resource)
      }
    }),
    buildSummaryEntry: (id, parsed) => ({
      id,
      resource: { resourceType: "Membership", id, ...parsed }
    })
  });
}

export {
  listMembershipsOperation
};
//# sourceMappingURL=chunk-RGE4WDND.mjs.map