Skip to content

Commit 085b9f9

Browse files
committed
chore: update readme
1 parent eaafa15 commit 085b9f9

File tree

1 file changed

+45
-23
lines changed
  • extensions/firestore-record-acknowledgments/lib

1 file changed

+45
-23
lines changed
Lines changed: 45 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,62 @@
1-
# Image Processing API Utilities
1+
# Firestore Record Acknowledgements Utilities
22

3-
This package contains utilities for interacting with the Firebase Image Processing API Extension.
3+
# Utilty Library
4+
5+
To assist with the usage of this Extension, a [utility library](https://www.npmjs.com/package/@invertase/firestore-record-acknowledgements) exists
6+
to help provide a typed API interface for easily constructing operations to send to the API.
47

58
## Installation
69

710
```bash
8-
npm i --save @invertase/image-processing-api
11+
npm i --save @invertase/firestore-record-acknowledgements
912
```
1013

14+
> To use this library, you must also have the [`firebase`](https://www.npmjs.com/package/firebase) package installed and initialized before any usage.
15+
1116
## Usage
1217

13-
### `builder`
18+
The library exports a number of functions to assist sending the correct payloads to the correct extension endpoints, with fully typed responses.
19+
The user should be authenticated via the `firebase/auth` package before using any of the functions.
20+
21+
```ts
22+
import { getNotice, acknowledgeNotice, unacknowledgeNotice, getAcknowledgments } from '@invertase/firestore-record-acknowledgements';
23+
24+
// ...
25+
26+
// Get a notice by ID (and optional version).
27+
const notice = await getNotice({ type: 'banner', version: 2 });
28+
29+
// Acknowledge a notice by ID.
30+
await acknowledgeNotice({ noticeId: '...', metadata: { ... } });
1431

15-
Returns a `ImageProcessingApi` instance which can be used to build an array of operations to be applied to an image via the extension.
32+
// Unacknowledge a notice by ID.
33+
await unacknowledgeNotice({ noticeId: '...', metadata: { ... } });
34+
35+
// Get all acknowledgements for current user.
36+
const acknowledgements = await getAcknowledgments({ includeUnacknowledgments: true });
37+
```
38+
39+
## Custom Functions Instance
40+
41+
If you need to provide a custom functions instance, you can provide an instance to the `functions` argument. This
42+
is useful if you wish to use a secondary app instance or change the region of the functions instance.
1643

1744
```ts
18-
import { builder } from '@invertase/image-processing-api';
19-
20-
const output = builder()
21-
// Input required
22-
.input({
23-
source: 'https://example.com/image.jpg',
24-
})
25-
.flip()
26-
.grayscale()
27-
.rotate({ angle: 90 })
28-
// Output required
29-
.output({
30-
format: 'png',
31-
});
45+
import { initializeApp } from 'firebase/app';
46+
import { getFunctions } from 'firebase/functions';
47+
48+
const app = initializeApp({ ... });
49+
const functions = getFunctions(app, 'europe-west1');
50+
51+
// Use the custom functions instance.
52+
const notice = await getNotice({ functions, type: 'banner' });
3253
```
3354

34-
Once created, the api provides the means to return the operations as JSON, a JSON string or an encoded JSON string suitable for GET requests in your browser.
55+
## Multiple Extension Instances
56+
57+
If you have multiple instances of the extension installed, you can provide the `extensionId` argument to the functions:
3558

3659
```ts
37-
const json = output.toJSON();
38-
const jsonString = output.toJSONString();
39-
const encodedJsonString = output.toEncodedJSONString();
60+
// Makes a request to the uniuque deployed extension.
61+
const notice = await getNotice({ extensionId: '1234', type: 'banner' });
4062
```

0 commit comments

Comments
 (0)