json-crdt-server
Version:
JSON CRDT server and syncing local-first browser client
25 lines (24 loc) • 868 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.view = void 0;
const schema_1 = require("../schema");
const view = ({ t, services }) => (r) => {
const Request = t.Object(t.prop('id', schema_1.BlockIdRef).options({
title: 'Block ID',
description: 'The ID of the block to retrieve.',
}));
const Response = t.Object(t.prop('view', t.any));
const Func = t.Function(Request, Response).options({
title: 'Read View',
intro: 'Retrieves the latest view of a block.',
description: 'This method retrieves the latest materialized view of a block by ID.',
});
return r.prop('block.view', Func, async ({ id }) => {
const view = await services.blocks.view(id);
const response = {
view,
};
return response;
});
};
exports.view = view;
;