5.3.0 • Published 5 years ago

forge-nodejs-sdk v5.3.0

Weekly downloads
18
License
ISC
Repository
github
Last release
5 years ago

Forge Node.JS SDK

Install

npm install forge-nodejs-sdk --save

Usage

// Require sdk main module
const sdk = require("forge-nodejs-sdk");
// Available classes
const ForgeManagementApi = sdk.ForgeManagementApi;
const ForgeNotificationBus = sdk.ForgeNotificationBus;
const DistributionNotificationBus = sdk.DistributionNotificationBus;
const ForgeCommands = sdk.ForgeCommands;
const ForgeDistributionApi = sdk.ForgeDistributionApi;
const ForgeFrontEndApi = sdk.ForgeFrontEndApi;

Consider that most methods returns Es6 Promise, write the correct implementation code to catch errors and handle continuation.

IMPORTANT: If you start receiving notification from ForgeNotificationBus or DistributionNotificationBus it is important to keep just one active connection for your entire application process, because each new connection will create a new service bus subscription.

Compatibility

Version 4.1 of the SDK is compatible only with Forge >= 4.1.0.

How to call a management API

let api = new ForgeManagementApi(config.managementApi);
api.getStories("working")
  .then((stories) => {
    // TODO your code
  });

How to send a command

let api = new ForgeManagementApi(config.managementApi);
let notificationBus = new ForgeNotificationBus(config.serviceBus);
api.autoWaitCommandNotification(notificationBus);

function connect(){
	return notificationBus.startReceiving();
}
function disconnect(){
	return notificationBus.stopReceiving();
}

connect()
.then(() => {
  let cmd = new ForgeCommands.CreateStory({
		translationInfo: {culture:"en-us"}
	});

  return api.post(cmd)
})
.then(disconnect, disconnect);

How to subscribe to distribution notification

let notificationBus = new DistributionNotificationBus(config.serviceBus);

function connect(){
	return notificationBus.startReceiving();
}
function disconnect(){
 	return notificationBus.stopReceiving();
}

connect()
.then(() => {
	notificationBus.on("EntityDistributionNotification", (e) => {
    // TODO your code
	});
});

How to subscribe to forge notification

let notificationBus = new ForgeNotificationBus(config.serviceBus);

function connect(){
	return notificationBus.startReceiving();
}
function disconnect(){
 	return notificationBus.stopReceiving();
}

connect()
.then(() => {
	notificationBus.on("PublishedNotification", (e) => {
    // TODO your code
	});
});

Configuration

Forge node.js SDK expects a configuration defined like this:

{
  "managementApi":{
    "authKey": "f083d945-a644-41f1-9d2f-ff9b7fd5cd01",
    "url": "http://localhost:60191/",
    "version": "v1"
  },
  "serviceBus":{
    "url": "amqp://guest:guest@localhost:5672"
  },
  "distributionApi":{
    "url": "http://localhost:60192/",
    "version": "v2"
  },
  "frontEnd":{
    "url": "http://localhost:54787/",
    "authKey": "00174056-D0E4-4983-9202-114F1339F6C9"
  }
}

Samples

See ./sample/ directory.

How to run a sample

npm install # install dependencies
set FORGE_TARGET=yourtarget
# ensure to have a valid configuration file "config.yourtarget.json"
node ./sample/waitForNotifications.js

By default samples load configuration from config.localhost.json. You can read another configuration file by changing the FORGE_TARGET environment variable. For example:

set FORGE_TARGET=webplu-test

will load the configuration file config.webplu-test.json.

How to publish new version of the SDK

git commit -a -m "message"

npm version major|minor|patch
git push
npm publish
5.3.0

5 years ago

5.2.0

5 years ago

5.1.0-1

5 years ago

5.0.2

5 years ago

5.0.1

5 years ago

5.0.0

5 years ago

4.18.0

5 years ago

4.17.2

5 years ago

4.17.1

5 years ago

4.17.0

5 years ago

4.16.4

6 years ago

4.16.3

6 years ago

4.16.2

6 years ago

4.16.1

6 years ago

4.16.0

6 years ago

4.15.2

6 years ago

4.15.1

6 years ago

4.14.0

6 years ago

4.13.1-0

6 years ago

4.13.0

6 years ago

4.12.2

6 years ago

4.12.1

6 years ago

4.12.0

6 years ago

4.11.0

6 years ago

4.10.3-5

6 years ago

4.10.3-4

6 years ago

4.10.3-3

6 years ago

4.10.3-2

6 years ago

4.10.3-1

6 years ago

4.10.3-0

6 years ago

4.10.2

6 years ago

4.10.1

6 years ago

4.10.0

6 years ago

4.9.6

6 years ago

4.9.5

6 years ago

4.9.4

6 years ago

4.9.3

6 years ago

4.9.2

6 years ago

4.9.1

6 years ago

4.9.0

6 years ago

4.8.4

6 years ago

4.8.3

6 years ago

4.8.2

6 years ago

4.8.1

6 years ago

4.8.0

6 years ago

4.7.2

6 years ago

4.7.1

6 years ago

4.7.0

6 years ago

4.6.0

7 years ago

4.5.1

7 years ago

4.5.0

7 years ago

4.4.0

7 years ago

4.3.13

7 years ago

4.3.12

7 years ago

4.3.11

7 years ago

4.3.10

7 years ago

4.3.9

7 years ago

4.3.8

7 years ago

4.3.7

7 years ago

4.3.6

7 years ago

4.3.5

7 years ago

4.3.4

7 years ago

4.3.3

7 years ago

4.3.2

7 years ago

4.3.1

7 years ago

4.2.4-5

7 years ago

4.2.4-4

7 years ago

4.2.4-3

7 years ago

4.2.4-2

7 years ago

4.2.4-1

7 years ago

4.2.4-0

7 years ago

4.3.0

7 years ago

4.2.2

7 years ago

4.2.2-unstable

7 years ago

4.2.1

7 years ago

4.2.0

7 years ago

4.1.1

7 years ago

4.1.0

7 years ago

4.0.3

7 years ago

4.0.2

7 years ago

4.0.1

7 years ago

4.0.1-0

7 years ago

4.0.0-0

7 years ago

1.7.0

7 years ago

1.6.1

7 years ago

1.6.0

7 years ago

1.5.3

7 years ago

1.5.2

7 years ago

1.5.1

7 years ago

1.5.0

7 years ago

1.4.0

7 years ago

1.3.4

7 years ago

1.3.3

7 years ago

1.3.2

7 years ago

1.3.1

7 years ago

1.3.0

7 years ago

1.2.0

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.0

7 years ago

0.15.0

7 years ago

0.14.0

8 years ago

0.13.0

8 years ago

0.12.0

8 years ago

0.11.0

8 years ago

0.10.0

8 years ago

0.9.0

8 years ago

0.8.0

8 years ago

0.7.0

8 years ago

0.6.0

8 years ago

0.5.0

8 years ago

0.4.0

8 years ago

0.3.0

8 years ago

0.2.0

8 years ago

0.1.0

8 years ago