2.0.1 • Published 7 days ago

marjory v2.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
7 days ago

Marjory SDK

This SDK can be used to write Marjory application and use advanced feature of the Marjory platform.

Installation

You can add the SDK to your project using npm:

npm install marjory

Then you can import the SDK in your application:

import Marjory from "marjory";

The SDK will be automatically initialized with the default configuration when your application will run on Marjory platform.

Usage

App Database (with MongoDB)

Each application have a dedicated database. To manipulate it, you have access to several functions.

Collection access

import Marjory from "marjory";

Marjory.DB.collection("<collection_name>");

Get functions

import Marjory from 'marjory'

const resultFind = await Marjory.DB.collection('<collection_name>').find(...)
const resultFindOne = await Marjory.DB.collection('<collection_name>').findOne(...)
const resultCount = await Marjory.DB.collection('<collection_name>').countDocuments(...)

Insert functions

import Marjory from 'marjory'

const resultInsertOne = await Marjory.DB.collection('<collection_name>').insertOne(...)
const resultInsertMany = await Marjory.DB.collection('<collection_name>').insertMany(...)

If you want to insert multiple documents at the same time, you can use the bulkWrite function:

import Marjory from "marjory";

const resultBulkWrite = await Marjory.DB.collection(
  "<collection_name>"
).bulkWrite([
  { insertOne: { document: { a: 1 } } },
  { insertOne: { document: { a: 2 } } },
  { insertOne: { document: { a: 3 } } },
  { updateOne: { filter: { a: 2 }, update: { $set: { a: 5 } } } },
  { deleteOne: { filter: { c: 1 } } },
  { replaceOne: { filter: { c: 3 }, replacement: { c: 4 } } },
]);

Update functions

import Marjory from 'marjory'

const resultUpdateOne = await Marjory.DB.collection('<collection_name>').updateOne(...)
const resultUpdateMany = await Marjory.DB.collection('<collection_name>').updateMany(...)
const resultFindOneAndUpdate = await Marjory.DB.collection('<collection_name>').findOneAndUpdate(...)
const resultFindOneAndReplace = await Marjory.DB.collection('<collection_name>').findOneAndReplace(...)
const resultReplaceOne = await Marjory.DB.collection('<collection_name>').replaceOne(...)

Delete functions

import Marjory from 'marjory'

const resultDeletetOne = await Marjory.DB.collection('<collection_name>').deleteOne(...)
const resultDeleteMany = await Marjory.DB.collection('<collection_name>').deleteMany(...)

Aggregation functions

import Marjory from 'marjory'

const resultAggregate = await Marjory.DB.collection('<collection_name>').aggregate(...)

Access variables

You can retrieve variables declared inside your Marjory.yml or deployment.yml file and configured using marjory configure command.

import Marjory from "marjory";

const variableValue = await Marjory.VARIABLES.getVariable("<variable_name>");

If this variable is related to an OAuth 2 configuration, the OAuth access_token will be automatically refreshed and returned.

Logger

import Marjory from "marjory";

const detailsObject = {}; // For example stack trace object

await Marjory.LOGGER.trace("message", detailsObject); // equivalent to debug in javascript
await Marjory.LOGGER.info("message", detailsObject);
await Marjory.LOGGER.warn("message", detailsObject);
await Marjory.LOGGER.error("message", detailsObject);

Events

In mostly cases during the webhook and scheduled functions, you will generate events. This method can throw event.

import Marjory from "marjory";

const eventPayload = {};
await Marjory.callEventRepository("<event_name>", eventPayload);

HTTP Request (using embedded axios) - DEPRECATED

⚠️ This feature is deprecated. You should rather use your own HTTP client.

import Marjory from 'marjory'

const response = await Marjory.axios({
    method: 'GET | POST | PUT | DELETE',
    url: '',
    baseUrl: '',
    headers: {},
    body: {},
    ...
})

Access context information

⚠️ You should rather use the Access variables feature to access context information.

import Marjory from "marjory";

// Access to the node identifier
const nodeId = Marjory.nodeId;

// Access to the authorization token
// that's allow you to be authenticate at each
// Marjory service (most case : file server)
const authorizationToken = Marjory.authorizationToken;

// Access to the invocation id of the running workflow
const invocationId = Marjory.invocationId;

// Access to the tenant name
// For example : if your tenant url is https://johndoe.marjory.io
// Marjory.realm will return "johndoe"
const tenant = Marjory.realm;

Issues

If you have any issue, please contact us at support@marjory.io

2.0.1

7 days ago

3.1.0

19 days ago

2.0.1-beta.10

2 months ago

3.0.11

2 months ago

3.0.10

3 months ago

3.0.8

3 months ago

3.0.7

3 months ago

3.0.9

3 months ago

3.0.6

3 months ago

3.0.4

3 months ago

3.0.3

3 months ago

3.0.2

3 months ago

3.0.1

3 months ago

3.0.5

3 months ago

3.0.0

3 months ago

2.0.0-beta.9

6 months ago

1.6.3

7 months ago

1.6.2

8 months ago

1.6.1

8 months ago

2.0.0-beta.8

8 months ago

2.0.0-beta.7

8 months ago

2.0.0-beta.6

8 months ago

2.0.0-beta.5

8 months ago

2.0.0-beta.4

8 months ago

2.0.0-beta.3

8 months ago

2.0.0-beta.2

8 months ago

2.0.0-beta.1

8 months ago

1.6.0

10 months ago

1.6.0-beta.1

10 months ago

1.5.0

1 year ago

1.5.0-beta.2

1 year ago

1.5.0-beta.22

1 year ago

1.5.0-beta.21

1 year ago

1.5.0-beta.20

1 year ago

1.5.0-beta.8

1 year ago

1.5.0-beta.7

1 year ago

1.5.0-beta.9

1 year ago

1.5.0-beta.4

1 year ago

1.5.0-beta.3

1 year ago

1.5.0-beta.6

1 year ago

1.5.0-beta.5

1 year ago

1.5.0-beta.19

1 year ago

1.5.0-beta.18

1 year ago

1.5.0-beta.17

1 year ago

1.5.0-beta.16

1 year ago

1.5.0-beta.15

1 year ago

1.5.0-beta.14

1 year ago

1.5.0-beta.13

1 year ago

1.5.0-beta.12

1 year ago

1.5.0-beta.11

1 year ago

1.5.0-beta.10

1 year ago

1.4.2

2 years ago

1.4.1

2 years ago

1.4.0

2 years ago

1.3.6

2 years ago

1.3.5

2 years ago

1.3.4

2 years ago

1.3.3

2 years ago

1.3.2

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.2.12

2 years ago

1.2.10

2 years ago

1.2.11

2 years ago

1.2.0

2 years ago

1.2.8

2 years ago

1.2.7

2 years ago

1.2.6

2 years ago

1.2.5

2 years ago

1.2.4

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.2.9

2 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.1.9

3 years ago

1.1.8

3 years ago

1.1.7

3 years ago

1.1.6

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.12

3 years ago

1.1.11

3 years ago

1.1.10

3 years ago

1.1.16

3 years ago

1.1.15

3 years ago

1.1.14

3 years ago

1.1.13

3 years ago

1.1.18

3 years ago

1.0.16

3 years ago

1.0.15

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.5

3 years ago

1.0.51

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago