message: Delta content endpoint.
diff: @@ -4,6 +4,39 @@ import { Provider } from "nconf";
  import * as utils from "../../../utils";
  import { IAlfredTenant } from "../../tenant";
  +export async function getDeltaContents(
  + mongoManager: utils.MongoManager,
  + collectionName: string,
  + tenantId: string,
  + documentId: string,
  + clientId: string,
  + from?: number,
  + to?: number): Promise<any[]> {
  +
  + // Create an optional filter to restrict the delta range
  + const query: any = { clientId, documentId, tenantId };
  + if (from !== undefined || to !== undefined) {
  + query["op.clientSequenceNumber"] = {};
  +
  + if (from !== undefined) {
  + query["op.clientSequenceNumber"].$gt = from;
  + }
  +
  + if (to !== undefined) {
  + query["op.clientSequenceNumber"].$lt = to;
  + }
  + }
  +
  + // Query for the deltas and return a filtered version of just the operations field
  + const db = await mongoManager.getDatabase();
  + const collection = await db.collection<any>(collectionName);
  + const dbDeltas = await collection.find(query, { "op.clientSequenceNumber": 1 });
  +
  + return dbDeltas.map((delta) => {
  + return delta;
  + });
  +}
  +
  export async function getDeltas(
  mongoManager: utils.MongoManager,
  collectionName: string,
  @@ -76,5 +109,32 @@ export function create(config: Provider, mongoManager: utils.MongoManager, appTe
  });
  });
  + /**
  + * Retrieves delta contents for the given document. With an optional from and to range (both exclusive) specified
  + */
  + router.get("/content/:tenantId?/:id/:clientId", (request, response, next) => {
  + const from = stringToSequenceNumber(request.query.from);
  + const to = stringToSequenceNumber(request.query.to);
  + const tenantId = request.params.tenantId || appTenants[0].id;
  +
  + // Query for the deltas and return a filtered version of just the operations field
  + const deltasP = getDeltaContents(
  + mongoManager,
  + "content",
  + tenantId,
  + request.params.id,
  + request.params.clientId,
  + from,
  + to);
  +
  + deltasP.then(
  + (deltas) => {
  + response.status(200).json(deltas);
  + },
  + (error) => {
  + response.status(500).json(error);
  + });
  + });
  +
  return router;
  }
  