
Security News
Another Round of TEA Protocol Spam Floods npm, But It’s Not a Worm
Recent coverage mislabels the latest TEA protocol spam as a worm. Here’s what’s actually happening.
@getcircuit/patcher
Advanced tools
@getcircuit/patcherThis package contains the methods necessary for resolving and applying patches to a document or collection.
Note: Currently, this package only implements the browser version of the patcher.
The main export is the createPatcher function. It takes a firestore instance, a patches collection reference and an actor and returns a patcher object.
With a patcher, one can patch documents in multiple ways:
const patcher = createPatcher({
firestore,
patchesCollectionRef: firestore.collection('../../some/collection'),
actor: 'user',
})
// patcher.addDocument(...)
// patcher.modifyDocument(...)
// patcher.moveDocument(...)
// patcher.deleteDocument(...)
// patcher.duplicateDocument(...)
When we talk about adding a document via patches, we're actually talking about registering that a document was added to a collection. This means that patcher.addDocument doesn't create a new document in the database, but rather registers that a document was added by creating an added patch pointing to the document.
const docRef = firestore.collection('some-collection').doc('some-document')
await docRef.set({ title: 'Some title' })
// an `added` patch is created pointing to the newly created document
await patcher.addDocument({ documentRef: docRef })
When we talk about modifying a document via patches, we're actually talking about registering that a document was modified. This means that patcher.modifyDocument doesn't modify a document in the database, but rather registers that a document was modified by creating a modified patch pointing to the document.
Note: if there's already a modified patch pointing to the document, the new patch will be merged with the existing one.
const docRef = firestore.collection('some-collection').doc('some-document')
await docRef.set({ title: 'Some title' })
// a `modified` patch is created pointing to the modified document
await patcher.modifyDocument({
documentRef: docRef,
changes: {
title: 'Some new title',
},
})
// later on...
// the existing `modified` patch is merged with the new one
await patcher.modifyDocument({
documentRef: docRef,
changes: {
description: 'Some description',
},
})
When we talk about deleting a document via patches, we're actually talking about registering that a document was deleted. This means that patcher.deleteDocument doesn't delete a document in the database, but rather registers that a document was deleted by creating a deleted patch pointing to the document.
const docRef = firestore.collection('some-collection').doc('some-document')
await docRef.set({ title: 'Some title' })
// a `deleted` patch is created pointing to the deleted document
await patcher.deleteDocument({ documentRef: docRef })
When we talk about moving a document via patches, we're actually talking about registering that a document was moved from one collection to another. This means that patcher.moveDocument doesn't move a document in the database, but rather registers that a document was moved by creating a moved patch pointing to the document.
const docRef = firestore.collection('some-collection').doc('some-document')
// a `moved` patch is created pointing to the moved document
await patcher.moveDocument({
documentRef: docRef,
destinationCollectionRef: firestore.collection('some-other-collection'),
})
When we talk about duplicating a document via patches, we're actually talking about registering that a document was duplicated. This means that patcher.duplicateDocument doesn't duplicate a document in the database, but rather registers that a document was duplicated by creating a duplicated patch pointing to the document.
Note: the
duplicateDocumentmethod also takes account any existingmodifiedpatches pointing to the document being dulplicated.
const docRef = firestore.collection('some-collection').doc('some-document')
// a `duplicated` patch is created pointing to the duplicated document
await patcher.duplicateDocument({
documentRef: docRef,
destinationCollectionRef: firestore.collection('some-other-collection'),
})
All the patching methods can be batched by using the patcher.inBatch method. The inBatch method takes a callback that receives a single object with all patching methods automatically bound to a batch.
const docRef = firestore.collection('some-collection').doc('some-document')
// `inBatch` will execute all patching methods in a single batch
await patcher.inBatch(({ addDocument, deleteDocument }) => {
for (const ref of docsToAdd) {
await addDocument({ documentRef: ref })
}
for (const ref of docsToDelete) {
await deleteDocument({ documentRef: ref })
}
})
The package exports a signals entrypoint that contains the high-level API for patching documents and collections.
import {
usePatchContext,
providePatchContext,
resolvePatchesFromCollection,
createPatchedDocumentSnap,
createPatchedCollectionDocumentSnaps,
createUserAffectedDocumentIdsByAction,
} from '@getcircuit/patcher/signals'
The main exported module contains the low-level patching utilities to resolve and apply patches.
import {
resolveDocumentPatches,
resolvePatchList,
applyPatchesToCollectionDocuments,
queryPatches,
} from '@getcircuit/patcher'
FAQs
Unknown package
We found that @getcircuit/patcher demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 19 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Recent coverage mislabels the latest TEA protocol spam as a worm. Here’s what’s actually happening.

Security News
PyPI adds Trusted Publishing support for GitLab Self-Managed as adoption reaches 25% of uploads

Research
/Security News
A malicious Chrome extension posing as an Ethereum wallet steals seed phrases by encoding them into Sui transactions, enabling full wallet takeover.