Firestore Record Acknowledgements Utilities
To assist with the usage of this Extension, a utility library exists
to help provide a typed API interface for easily constructing operations to send to the API.
Installation
npm i --save @invertase/firestore-record-acknowledgements
To use this library, you must also have the firebase
package installed and initialized before any usage.
Usage
The library exports a number of functions to assist sending the correct payloads to the correct extension endpoints, with fully typed responses.
The user should be authenticated via the firebase/auth
package before using any of the functions.
import { getNotice, acknowledgeNotice, unacknowledgeNotice, getAcknowledgments } from '@invertase/firestore-record-acknowledgements';
const notice = await getNotice({ type: 'banner', version: 2 });
await acknowledgeNotice({ noticeId: '...', metadata: { ... } });
await unacknowledgeNotice({ noticeId: '...', metadata: { ... } });
const acknowledgements = await getAcknowledgments({ includeUnacknowledgments: true });
Custom Functions Instance
If you need to provide a custom functions instance, you can provide an instance to the functions
argument. This
is useful if you wish to use a secondary app instance or change the region of the functions instance.
import { initializeApp } from 'firebase/app';
import { getFunctions } from 'firebase/functions';
const app = initializeApp({ ... });
const functions = getFunctions(app, 'europe-west1');
const notice = await getNotice({ functions, type: 'banner' });
Multiple Extension Instances
If you have multiple instances of the extension installed, you can provide the extensionId
argument to the functions:
const notice = await getNotice({ extensionId: '1234', type: 'banner' });