5.3.0 • Published 6 years ago

forge-nodejs-sdk v5.3.0

Weekly downloads
18
License
ISC
Repository
github
Last release
6 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

6 years ago

5.2.0

6 years ago

5.1.0-1

6 years ago

5.0.2

7 years ago

5.0.1

7 years ago

5.0.0

7 years ago

4.18.0

7 years ago

4.17.2

7 years ago

4.17.1

7 years ago

4.17.0

7 years ago

4.16.4

7 years ago

4.16.3

7 years ago

4.16.2

7 years ago

4.16.1

7 years ago

4.16.0

7 years ago

4.15.2

8 years ago

4.15.1

8 years ago

4.14.0

8 years ago

4.13.1-0

8 years ago

4.13.0

8 years ago

4.12.2

8 years ago

4.12.1

8 years ago

4.12.0

8 years ago

4.11.0

8 years ago

4.10.3-5

8 years ago

4.10.3-4

8 years ago

4.10.3-3

8 years ago

4.10.3-2

8 years ago

4.10.3-1

8 years ago

4.10.3-0

8 years ago

4.10.2

8 years ago

4.10.1

8 years ago

4.10.0

8 years ago

4.9.6

8 years ago

4.9.5

8 years ago

4.9.4

8 years ago

4.9.3

8 years ago

4.9.2

8 years ago

4.9.1

8 years ago

4.9.0

8 years ago

4.8.4

8 years ago

4.8.3

8 years ago

4.8.2

8 years ago

4.8.1

8 years ago

4.8.0

8 years ago

4.7.2

8 years ago

4.7.1

8 years ago

4.7.0

8 years ago

4.6.0

8 years ago

4.5.1

8 years ago

4.5.0

8 years ago

4.4.0

9 years ago

4.3.13

9 years ago

4.3.12

9 years ago

4.3.11

9 years ago

4.3.10

9 years ago

4.3.9

9 years ago

4.3.8

9 years ago

4.3.7

9 years ago

4.3.6

9 years ago

4.3.5

9 years ago

4.3.4

9 years ago

4.3.3

9 years ago

4.3.2

9 years ago

4.3.1

9 years ago

4.2.4-5

9 years ago

4.2.4-4

9 years ago

4.2.4-3

9 years ago

4.2.4-2

9 years ago

4.2.4-1

9 years ago

4.2.4-0

9 years ago

4.3.0

9 years ago

4.2.2

9 years ago

4.2.2-unstable

9 years ago

4.2.1

9 years ago

4.2.0

9 years ago

4.1.1

9 years ago

4.1.0

9 years ago

4.0.3

9 years ago

4.0.2

9 years ago

4.0.1

9 years ago

4.0.1-0

9 years ago

4.0.0-0

9 years ago

1.7.0

9 years ago

1.6.1

9 years ago

1.6.0

9 years ago

1.5.3

9 years ago

1.5.2

9 years ago

1.5.1

9 years ago

1.5.0

9 years ago

1.4.0

9 years ago

1.3.4

9 years ago

1.3.3

9 years ago

1.3.2

9 years ago

1.3.1

9 years ago

1.3.0

9 years ago

1.2.0

9 years ago

1.1.2

9 years ago

1.1.1

9 years ago

1.1.0

9 years ago

1.0.0

9 years ago

0.15.0

9 years ago

0.14.0

9 years ago

0.13.0

9 years ago

0.12.0

9 years ago

0.11.0

9 years ago

0.10.0

9 years ago

0.9.0

9 years ago

0.8.0

10 years ago

0.7.0

10 years ago

0.6.0

10 years ago

0.5.0

10 years ago

0.4.0

10 years ago

0.3.0

10 years ago

0.2.0

10 years ago

0.1.0

10 years ago