Skip to content

Commit b119f68

Browse files
Up maester client (#66)
1 parent 3b3cdf9 commit b119f68

26 files changed

+731
-478
lines changed

.circleci/circle.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

.circleci/config.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
version: 2.1
2+
jobs:
3+
build:
4+
docker:
5+
- image: circleci/node:16-stretch
6+
steps:
7+
- checkout
8+
- restore_cache:
9+
key: dependency-cache-{{ checksum "package-lock.json" }}
10+
- run:
11+
name: Installing Dependencies
12+
command: npm install
13+
- save_cache:
14+
key: dependency-cache-{{ checksum "package-lock.json" }}
15+
paths:
16+
- ./node_modules
17+
- run:
18+
name: "Running audit"
19+
command: npm audit --production
20+
- run:
21+
name: Running Mocha Tests
22+
command: npm test
23+
24+
workflows:
25+
version: 2
26+
27+
build:
28+
jobs:
29+
- build
30+
31+
nightly:
32+
triggers:
33+
- schedule:
34+
cron: "0 0 * * *"
35+
filters:
36+
branches:
37+
only:
38+
- master
39+
jobs:
40+
- build

.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ELASTICIO_OBJECT_STORAGE_TOKEN=feyJhbGciasfdJ0uhN__D0asdasdq283d283d
2+
ELASTICIO_OBJECT_STORAGE_URI=http://localhost:3002

.github/ISSUE_TEMPLATE/1-bug-report.md

Lines changed: 0 additions & 47 deletions
This file was deleted.

.github/ISSUE_TEMPLATE/2-new-oih-action-or-trigger.md

Lines changed: 0 additions & 30 deletions
This file was deleted.

.github/ISSUE_TEMPLATE/3-migration-to-new-api.md

Lines changed: 0 additions & 23 deletions
This file was deleted.

.github/ISSUE_TEMPLATE/4-other-feature-request.md

Lines changed: 0 additions & 23 deletions
This file was deleted.

.github/ISSUE_TEMPLATE/5-internal-issue.md

Lines changed: 0 additions & 23 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 3.0.0 (July 25, 2022)
2+
* Updated method `uploadAttachment` from `AttachmentProcessor`
3+
* Added method `getMaesterAttachmentUrlById` which return url to Maester attachment
4+
* Updated @elasticio/maester-client to v4.0.0
5+
* Updated Circle.ci config
6+
17
## 2.1.0 (May 06, 2022)
28
* Now method `uploadAttachment` from `AttachmentProcessor` automatically sets the `contentType`
39
* Fixed retrying logic for method `uploadAttachment`

README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,11 @@ Contains functions to transform platform data that contains JSONata expressions
200200
## Attachment Processor
201201
The attachment processor function can be used to store attachments on the platform. It exposes the following functions
202202

203-
- `uploadAttachment(body, contentType)`, which will upload an attachment to the platform `Maester` storage and return the result object.
204-
Where `body` - attachment content, `contentType` - it's corresponding `Content-Type` value.
203+
- `uploadAttachment(getAttachment, retryOptions, contentType)`, which will upload an attachment to the platform `Maester` storage and return the result object.
204+
Where: <br>
205+
`getAttachment` - async function which returns stream <br>
206+
`retryOptions` - (optional): parameters for retrying of upload attachment, if request failed. Parameters are `retriesCount` and `requestTimeout`(ms)
207+
`contentType` - (optional): `Content-Type` of attachment. By default `Content-Type` will be calculated automatically. <br>
205208
- `getAttachment(url, contentType)`, which will retrieve an attachment from `steward` or `maester` storage. To specify the storage - query parameter
206209
`storage_type` must be provided. To get items from `maester` storage - `?storage_type=maester` should added to the `url` argument. By default attachments are retrieved from `steward` storage, so `?storage_type=steward` is not obligated to be added to the `url` argument. `contentType` -
207210
one of [`stream`, `arraybuffer` ]
@@ -211,8 +214,10 @@ Example:
211214
```javascript
212215
const { AttachmentProcessor } = require('@elastic.io/component-commons-library');
213216

214-
const stream = new Stream();
215-
const result = await new AttachmentProcessor().uploadAttachment(body, 'application/octet-stream');
217+
const getAttachAsStream = async () => (
218+
await axios.get('http://sample.pdf', { responseType: 'stream' })
219+
).data;
220+
const result = await new AttachmentProcessor().uploadAttachment(getAttachAsStream, 'application/pdf');
216221

217222
const { objectId } = result.data;
218223
```

0 commit comments

Comments
 (0)