@manuscripts/manuscripts-sync
v1.1.4
Published
Sync function for Couchbase Sync Gateway
Readme
manuscripts-sync
This repository provides a Dockerfile for a copy of Couchbase Sync Gateway configured for Manuscripts backend purposes, as well as an NPM published package which is baked into the Sync Gateway configuration.
- The copy of Sync Gateway used a minor fork that allows for session cookies for multiple domains.
- It is built with a Manuscripts specific sync function that includes Manuscripts specific access control rules and a 0-dependency JSON schema validator for the Manuscripts JSON schema.
Module usage
import { Project } from '@manuscripts/manuscripts-sync'
const p: Project = {
_id: 'MPProject:id',
owners: ['User_Foo'],
writers: [],
viewers: [],
objectType: 'MPProject',
}const { syncFn } = require('@manuscripts/manuscripts-sync')
console.log(syncFn)Building the Sync Gateway configuration file
To build the Sync Gateway configuration file at ./docker/sync_gateway/sync-gateway-config.json with the values present in .env, do the following:
env $(cat .env | xargs) npx gulpThe environment variables in .env are defaults, and none of them at least at the time of writing are treated as build arguments in the Dockerfiles present in this repo.
Dockerfiles
This repository contains a CI build configuration which keeps the following two GitLab Docker registry published images up to date:
- registry.gitlab.com/mpapp-private/manuscripts-sync/sync_gateway
- registry.gitlab.com/mpapp-private/manuscripts-sync/couchbase
Both of these images are tagged with the value of the "version" field present in the package.json.
The images are published to the registry upon tagging commits (or with manual CD pipeline "prepare_images_manual" button pressing action).
Building Sync Gateway for local development
To develop manuscripts-api against a locally built manuscripts-sync flavoured Sync Gateway, do the following:
- Create a GitLab account if you don't already have one.
docker login registry.gitlab.comwith your GitLab credentials.IMAGE_NAME=your-sg-image-name ./docker/build-image.sh.- Follow the local development steps for manuscripts-frontend, except before launching the services, modify
docker-compose.ymlto set the image name so that it matches the$IMAGE_NAMEyou used above.
sync_gateway:
image: your-sg-image-name
…If you want to make local changes to manuscripts-sync JavaScript code (such as manuscripts-sync-fn.js) or manuscripts-json-schema, pass COPY_LOCAL_PACKAGES=true to the ./docker/build-image.sh script, like so:
COPY_LOCAL_PACKAGES=true IMAGE_NAME=your-sg-image-name ./docker/build-image.shLocal changes to manuscripts-json-schema
To build the image with steps described above with a locally changed manuscripts-json-schema, use npm link and a local copy of manuscripts-json-schema, for example if your working copy of the schema repository is next to your manuscripts-sync repository on your disk, do the following to link it:
npm link ../manuscripts-json-schema/The build-image.sh script will deal with an npm linked copy of manuscripts-json-schema similarly to one that is referenced and fetched by NPM via the package.json reference, allowing you to work with unpublished versions of the schema.
Creating a release
To create a release, do the following:
- Decide to make a release: is the correct schema version referenced? are tests in good order? have you tested compatibility with manuscripts-api?
- Update version in package.json, commit and push it.
- Create a new tag, and enter a brief description and release notes.
- Watch as the CI tasks for NPM package and Docker image publishing complete.
- Celebrate 🎉
Channels contents and description
The following are data bucket channels:
{userID}-projects=>- contains:
MPProjectwith one of owners/writers/viewers = {userID}.
- description:
- contains any project in which the user with {userID} is a collaborator.
- access granted to the user with id = {userID}.
- contains:
{userID}-libraries=>- contains:
MPLibrarywith one of owners/writers/viewers = {userID}.
- description:
- contains any library in which the user with {userID} is a collaborator.
- access granted to the user with id = {userID}.
- contains:
{userID}-library-collections=>- contains:
MPLibraryCollectionwith one of owners/writers/viewers = {userID}.
- description:
- contains any library collection in which the user with {userID} is a collaborator.
- access granted to the user with id = {userID}.
- contains:
{containerID}-read=>- contains:
MPProjectwith _id = {containerID}.MPLibrarywith _id = {containerID}.MPLibraryCollectionwith _id = {containerID}.MPContainerInvitationswith containerID = {containerID}.- any other objects with containerID = {containerID}.
- description:
- contains all the objects related to a container with id {containerID}, including the container itself.
- access granted to any container collaborator.
- contains:
{containerID}-readwrite=>- contains:
MPProjectwith _id = {containerID}.MPLibrarywith _id = {containerID}.MPLibraryCollectionwith _id = {containerID}.MPContainerInvitationswith containerID = {containerID}.- any other objects with containerID = {containerID}.
- description:
- contains all the objects related to a container with id {containerID}, including the container itself.
- access granted to any container owners and writers.
- contains:
{userID}-read=>- contains:
MPUserProfilewith userID = {userID}.
- description:
- contains the profile of the user with {userID}.
- access granted to the user with id = {userID}.
- contains:
{userID}-readwrite=>- contains:
MPUserProfilewith userID = {userID}.
- description:
- contains the profile of the user with {userID}.
- access granted to the user with id = {userID}.
- contains:
{userID}=>- contains:
MPCollaborationwith invitingUserID = {userID} orUser_+ invitedUserEmail = {userID}.MPInvitationwith invitingUserID = {userID} orUser_+ invitedUserEmail = {userID}.MPContainerInvitationwith invitingUserID = {userID} orUser_+ invitedUserEmail = {userID}.
- description:
- contains all collaborations, invitations and container invitations which are send by the user or to the user.
- access granted to the user with id = {userID}.
- contains:
{containerID}-owner=>- contains:
MPContainerRequestwith containerID = {containerID}.
- description:
- contains all the objects which are only accessible to the owner of a container with {containerID}.
- access granted to any container owners.
- contains:
{preferenceID}withoutMPPreferences:prefix =>- contains:
MPPreferencewith _id ={preferenceID}
- description: ?
- contains:
{userID}-citation-alerts=>- contains:
MPMutedCitationAlertwith userID = {userID}.MPCitationAlertwith userID = {userID}.
- description:
- contains all citation alert objects.
- access granted to the user with id = {userID}.
- contains:
{containerID}-bibitems=>- contains:
MPBibliographyItemwith containerID = {containerID}.
- description:
- contains all the bibliography items for the container with containerID = {containerID}.
- access granted to any container collaborator.
- contains:
{keywordID}-read=>- contains:
MPBibliographyItemwith one of keywordIDs = {keywordID}.
- description: ?
- contains:
{keywordID}-readwrite=>- contains:
MPBibliographyItemwith one of keywordIDs = {keywordID}.
- description: ?
- contains:
{userID}-templates=>- contains:
MPProjectwith one of owners/writers/viewers = {userID} and templateContainer = true.
- description:
- contains projects that contain published MPManuscriptTemplate objects.
- access granted to the user with id = {userID}.
- contains:
The following are derived data bucket channels:
{userID}-collaborators=>- contains:
MPUserCollaboratorwith userID = {userID}.
- description:
- contains all user collaborators for the user with userID = {userID}.
- access granted to user with id = {userID}.
- contains:
{userID}-project-mementos=>- contains:
MPProjectMementowith userID = {userID}.
- description:
- contains all project mementos for the user with userID = {userID}.
- access granted to user with id = {userID}.
- contains:
{containerID}-summaries=>- contains:
MPProjectSummarywith containerID = {containerID}.MPLibrarySummarywith containerID = {containerID}.MPLibraryCollectionSummarywith containerID = {containerID}.
- description:
- contains a container summary with containerID = {containerID}.
- access granted to any container collaborator.
- contains:
