Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Forge Node.js SDK [![Build Status](https://travis-ci.org/Autodesk-Forge/forge-api-nodejs-client.svg?branch=master)](https://travis-ci.org/Autodesk-Forge/forge-api-nodejs-client)

*Forge API*:
[![oAuth2](https://img.shields.io/badge/oAuth2-v1-green.svg)](https://forge.autodesk.com/developer/documentation)
[![oAuth2](https://img.shields.io/badge/oAuth2-v2-green.svg)](https://forge.autodesk.com/developer/documentation)
[![Data-Management](https://img.shields.io/badge/Data%20Management-v1-green.svg)](https://forge.autodesk.com/developer/documentation)
[![OSS](https://img.shields.io/badge/OSS-v2-green.svg)](https://forge.autodesk.com/developer/documentation)
[![Model-Derivative](https://img.shields.io/badge/Model%20Derivative-v2-green.svg)](https://forge.autodesk.com/developer/documentation)
Expand Down Expand Up @@ -52,13 +52,13 @@ To get a 2-legged token run the following code. Note that you need to replace `y

``` JavaScript
var ForgeSDK = require('forge-apis');
var FORGE_CLIENT_ID = '<your-client-id>' , FORGE_CLIENT_SECRET = '<your-client-secret>';
var APS_CLIENT_ID = '<your-client-id>' , APS_CLIENT_SECRET = '<your-client-secret>';

// Initialize the 2-legged OAuth2 client, set specific scopes and optionally set the `autoRefresh` parameter to true
// if you want the token to auto refresh
var autoRefresh = true; // or false

var oAuth2TwoLegged = new ForgeSDK.AuthClientTwoLegged(FORGE_CLIENT_ID, FORGE_CLIENT_SECRET, [
var oAuth2TwoLegged = new ForgeSDK.AuthClientTwoLegged(APS_CLIENT_ID, APS_CLIENT_SECRET, [
'data:read',
'data:write'
], autoRefresh);
Expand All @@ -84,12 +84,12 @@ Note that the redirect URL must match the pattern of the callback URL field of t

``` JavaScript
var ForgeSDK = require('forge-apis');
var FORGE_CLIENT_ID = '<your-client-id>', FORGE_CLIENT_SECRET = '<your-client-secret>', REDIRECT_URL = '<your-redirect-url>';
var APS_CLIENT_ID = '<your-client-id>', APS_CLIENT_SECRET = '<your-client-secret>', REDIRECT_URL = '<your-redirect-url>';

// Initialize the 3-legged OAuth2 client, set specific scopes and optionally set the `autoRefresh` parameter to true
// if you want the token to auto refresh
var autoRefresh = true;
var oAuth2ThreeLegged = new ForgeSDK.AuthClientThreeLegged(FORGE_CLIENT_ID, FORGE_CLIENT_SECRET, REDIRECT_URL, [
var oAuth2ThreeLegged = new ForgeSDK.AuthClientThreeLegged(APS_CLIENT_ID, APS_CLIENT_SECRET, REDIRECT_URL, [
'data:read',
'data:write'
], autoRefresh);
Expand Down Expand Up @@ -192,15 +192,18 @@ Class | Method | HTTP request | Description
*ForgeSdk.BucketsApi* | [**deleteBucket**](docs/BucketsApi.md#deleteBucket) | **DELETE** /oss/v2/buckets/{bucketKey} |
*ForgeSdk.BucketsApi* | [**getBucketDetails**](docs/BucketsApi.md#getBucketDetails) | **GET** /oss/v2/buckets/{bucketKey}/details |
*ForgeSdk.BucketsApi* | [**getBuckets**](docs/BucketsApi.md#getBuckets) | **GET** /oss/v2/buckets |
*ForgeSdk.DerivativesApi* | [**deleteManifest**](docs/DerivativesApi.md#deleteManifest) | **DELETE** /modelderivative/v2/designdata/{urn}/manifest |
*ForgeSdk.DerivativesApi* | [**getDerivativeManifest**](docs/DerivativesApi.md#getDerivativeManifest) | **GET** /modelderivative/v2/designdata/{urn}/manifest/{derivativeUrn} |
*ForgeSdk.DerivativesApi* | [**getFormats**](docs/DerivativesApi.md#getFormats) | **GET** /modelderivative/v2/designdata/formats |
*ForgeSdk.DerivativesApi* | [**translate**](docs/DerivativesApi.md#translate) | **POST** /modelderivative/v2/designdata/job |
*ForgeSdk.DerivativesApi* | [**setReferences**](docs/DerivativesApi.md#setReferences) | **POST** /modelderivative/v2/designdata/{urn}/references |
*ForgeSdk.DerivativesApi* | [**getThumbnail**](docs/DerivativesApi.md#getThumbnail) | **GET** /modelderivative/v2/designdata/{urn}/thumbnail |
*ForgeSdk.DerivativesApi* | [**getManifest**](docs/DerivativesApi.md#getManifest) | **GET** /modelderivative/v2/designdata/{urn}/manifest |
*ForgeSdk.DerivativesApi* | [**deleteManifest**](docs/DerivativesApi.md#deleteManifest) | **DELETE** /modelderivative/v2/designdata/{urn}/manifest |
*ForgeSdk.DerivativesApi* | [**getDerivativeManifest**](docs/DerivativesApi.md#getDerivativeManifest) | **GET** /modelderivative/v2/designdata/{urn}/manifest/{derivativeUrn} |
*ForgeSdk.DerivativesApi* | [**getDerivativeManifestInfo**](docs/DerivativesApi.md#getDerivativeManifestInfo) | **HEAD** /modelderivative/v2/designdata/{urn}/manifest/{derivativeUrn} |
*ForgeSdk.DerivativesApi* | [**getDerivativeDownloadUrl**](docs/DerivativesApi.md#getDerivativeDownloadUrl) | **GET** /modelderivative/v2/designdata/{urn}/manifest/{derivativeUrn}/signedcookies |
*ForgeSdk.DerivativesApi* | [**getMetadata**](docs/DerivativesApi.md#getMetadata) | **GET** /modelderivative/v2/designdata/{urn}/metadata |
*ForgeSdk.DerivativesApi* | [**getModelviewMetadata**](docs/DerivativesApi.md#getModelviewMetadata) | **GET** /modelderivative/v2/designdata/{urn}/metadata/{guid} |
*ForgeSdk.DerivativesApi* | [**getModelviewProperties**](docs/DerivativesApi.md#getModelviewProperties) | **GET** /modelderivative/v2/designdata/{urn}/metadata/{guid}/properties |
*ForgeSdk.DerivativesApi* | [**getThumbnail**](docs/DerivativesApi.md#getThumbnail) | **GET** /modelderivative/v2/designdata/{urn}/thumbnail |
*ForgeSdk.DerivativesApi* | [**translate**](docs/DerivativesApi.md#translate) | **POST** /modelderivative/v2/designdata/job |
*ForgeSdk.FoldersApi* | [**getFolder**](docs/FoldersApi.md#getFolder) | **GET** /data/v1/projects/{project_id}/folders/{folder_id} |
*ForgeSdk.FoldersApi* | [**getFolderContents**](docs/FoldersApi.md#getFolderContents) | **GET** /data/v1/projects/{project_id}/folders/{folder_id}/contents |
*ForgeSdk.FoldersApi* | [**getFolderParent**](docs/FoldersApi.md#getFolderParent) | **GET** /data/v1/projects/{project_id}/folders/{folder_id}/parent |
Expand Down
2 changes: 1 addition & 1 deletion bump-version
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

current_version="0.9.6"
current_version="0.9.7"
new_version=$1
if [ "$new_version" == "" ]; then
[[ "$current_version" =~ ([0-9]+).+([0-9]+).+([0-9]+)$ ]] && new_version="${BASH_REMATCH[1]}.${BASH_REMATCH[2]}.$((${BASH_REMATCH[3]} + 1))"
Expand Down
64 changes: 32 additions & 32 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "forge-apis",
"version": "0.9.6",
"version": "0.9.7",
"description": "The Forge Platform contains an expanding collection of web service components that can be used with Autodesk cloud-based products or your own technologies. Take advantage of Autodesk’s expertise in design and engineering.",
"license": "Apache-2.0",
"main": "src/index.js",
Expand Down Expand Up @@ -42,10 +42,11 @@
"retry-axios": "^3.0.0"
},
"devDependencies": {
"eslint": "^8.42.0",
"expect.js": "^0.3.1",
"mocha": "^9.2.1",
"nock": "^13.2.4",
"nyc": "^15.1.0",
"sinon": "^13.0.1"
}
}
}
2 changes: 1 addition & 1 deletion samples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ $ npm install

Before running the app you need to configure the following parameters from the *samples/dmSample.js* file:

* Replace `FORGE_CLIENT_ID` and `FORGE_CLIENT_SECRET` with the client ID and client secret generated when creating the app.
* Replace `APS_CLIENT_ID` and `APS_CLIENT_SECRET` with the client ID and client secret generated when creating the app.

* Replace `BUCKET_KEY` with a unique name for the bucket.

Expand Down
8 changes: 4 additions & 4 deletions samples/dmSample.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ const _path = require('path');
const ForgeSDK = require('./../src/index');

// TODO - insert your CLIENT_ID and CLIENT_SECRET
const FORGE_CLIENT_ID = process.env.FORGE_CLIENT_ID || 'your forge client id';
const FORGE_CLIENT_SECRET = process.env.FORGE_CLIENT_SECRET || 'your forge client secret';
const APS_CLIENT_ID = process.env.APS_CLIENT_ID || 'your forge client id';
const APS_CLIENT_SECRET = process.env.APS_CLIENT_SECRET || 'your forge client secret';

// TODO - Choose a bucket key - a unique name to assign to a bucket. It must be globally unique across all applications and
// regions, otherwise the call will fail. Possible values: -_.a-z0-9 (between 3-128 characters in
// length). Note that you cannot change a bucket key.
const BUCKET_KEY = 'forge_sample_' + FORGE_CLIENT_ID.toLowerCase();
const BUCKET_KEY = 'forge_sample_' + APS_CLIENT_ID.toLowerCase();

// TODO - Choose a filename - a key for the uploaded object
const FILE_NAME = 'test.nwd';
Expand All @@ -50,7 +50,7 @@ const objectsApi = new ForgeSDK.ObjectsApi(apiClient); // Objects Client

// Initialize the 2-legged oauth2 client
const oAuth2TwoLegged = new ForgeSDK.AuthClientTwoLegged(
FORGE_CLIENT_ID, FORGE_CLIENT_SECRET,
APS_CLIENT_ID, APS_CLIENT_SECRET,
['data:write', 'data:read', 'bucket:read', 'bucket:update', 'bucket:create'], true
);

Expand Down
10 changes: 5 additions & 5 deletions samples/dmSample2-complex.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ const { ApiClient } = require('../src/index');
const ForgeSDK = require('../src/index');

// TODO - insert your CLIENT_ID and CLIENT_SECRET
const FORGE_CLIENT_ID = process.env.FORGE_CLIENT_ID || 'your forge client id';
const FORGE_CLIENT_SECRET = process.env.FORGE_CLIENT_SECRET || 'your forge client secret';
const APS_CLIENT_ID = process.env.APS_CLIENT_ID || 'your forge client id';
const APS_CLIENT_SECRET = process.env.APS_CLIENT_SECRET || 'your forge client secret';

// TODO - Choose a bucket key - a unique name to assign to a bucket. It must be globally unique across all applications and
// regions, otherwise the call will fail. Possible values: -_.a-z0-9 (between 3-128 characters in
// length). Note that you cannot change a bucket key.
const BUCKET_KEY = 'forge_sample_' + FORGE_CLIENT_ID.toLowerCase();
const BUCKET_KEY = 'forge_sample_' + APS_CLIENT_ID.toLowerCase();

// TODO - Choose a filename - a key for the uploaded object
const FILE_NAME0 = 'test.txt';
Expand All @@ -57,7 +57,7 @@ const objectsApi = new ForgeSDK.ObjectsApi(apiClient); // Objects Client

// Initialize the 2-legged oauth2 client
const oAuth2TwoLegged = new ForgeSDK.AuthClientTwoLegged(
FORGE_CLIENT_ID, FORGE_CLIENT_SECRET,
APS_CLIENT_ID, APS_CLIENT_SECRET,
['data:write', 'data:read', 'bucket:read', 'bucket:update', 'bucket:create'], true
);

Expand Down Expand Up @@ -300,7 +300,7 @@ oAuth2TwoLegged.authenticate()

console.log('**** Deleting server files(s)');
await deleteAllServerObjects(BUCKET_KEY, uploadRes);
try { await _fs.unlink(FILE_PATH1 + '.out'); } catch (ex) {}
try { await _fs.unlink(FILE_PATH1 + '.out'); } catch (ex) { }

// Large Files < 5Mb <
console.log('**** Testing Large files');
Expand Down
8 changes: 4 additions & 4 deletions samples/dmSample2.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ const { ApiClient } = require('../src/index');
const ForgeSDK = require('../src/index');

// TODO - insert your CLIENT_ID and CLIENT_SECRET
const FORGE_CLIENT_ID = process.env.FORGE_CLIENT_ID || 'your forge client id';
const FORGE_CLIENT_SECRET = process.env.FORGE_CLIENT_SECRET || 'your forge client secret';
const APS_CLIENT_ID = process.env.APS_CLIENT_ID || 'your forge client id';
const APS_CLIENT_SECRET = process.env.APS_CLIENT_SECRET || 'your forge client secret';

// TODO - Choose a bucket key - a unique name to assign to a bucket. It must be globally unique across all applications and
// regions, otherwise the call will fail. Possible values: -_.a-z0-9 (between 3-128 characters in
// length). Note that you cannot change a bucket key.
const BUCKET_KEY = 'forge_sample_' + FORGE_CLIENT_ID.toLowerCase();
const BUCKET_KEY = 'forge_sample_' + APS_CLIENT_ID.toLowerCase();

// TODO - Choose a filename - a key for the uploaded object
const FILE_NAME = 'test.nwd';
Expand All @@ -52,7 +52,7 @@ const objectsApi = new ForgeSDK.ObjectsApi(apiClient); // Objects Client

// Initialize the 2-legged oauth2 client
const oAuth2TwoLegged = new ForgeSDK.AuthClientTwoLegged(
FORGE_CLIENT_ID, FORGE_CLIENT_SECRET,
APS_CLIENT_ID, APS_CLIENT_SECRET,
['data:write', 'data:read', 'bucket:read', 'bucket:update', 'bucket:create'], true
);

Expand Down
10 changes: 5 additions & 5 deletions samples/mdSample.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ const _path = require('path');
const ForgeSDK = require('../src/index');

// TODO - insert your CLIENT_ID and CLIENT_SECRET
const FORGE_CLIENT_ID = process.env.FORGE_CLIENT_ID || 'your forge client id';
const FORGE_CLIENT_SECRET = process.env.FORGE_CLIENT_SECRET || 'your forge client secret';
const APS_CLIENT_ID = process.env.APS_CLIENT_ID || 'your forge client id';
const APS_CLIENT_SECRET = process.env.APS_CLIENT_SECRET || 'your forge client secret';

// TODO - Choose a bucket key - a unique name to assign to a bucket. It must be globally unique across all applications and
// regions, otherwise the call will fail. Possible values: -_.a-z0-9 (between 3-128 characters in
// length). Note that you cannot change a bucket key.
const BUCKET_KEY = 'forge_sample_' + FORGE_CLIENT_ID.toLowerCase();
const BUCKET_KEY = 'forge_sample_' + APS_CLIENT_ID.toLowerCase();

// TODO - Choose a filename - a key for the uploaded object
const FILE_NAME = 'test.nwd';
Expand All @@ -45,14 +45,14 @@ const bucketsApi = new ForgeSDK.BucketsApi(),
derivativesApi = new ForgeSDK.DerivativesApi(/* undefined, ForgeSDK.JobPayloadDestination.RegionEnum.EMEA */);

// Initialize the 2-legged oauth2 client
const oAuth2TwoLegged = new ForgeSDK.AuthClientTwoLegged(FORGE_CLIENT_ID, FORGE_CLIENT_SECRET,
const oAuth2TwoLegged = new ForgeSDK.AuthClientTwoLegged(APS_CLIENT_ID, APS_CLIENT_SECRET,
['data:write', 'data:read', 'bucket:read', 'bucket:update', 'bucket:create'], true);

/**
* General error handling method
* @param err
*/
function defaultHandleError (err) {
function defaultHandleError(err) {
console.error('\x1b[31m Error:', err, '\x1b[0m');
}

Expand Down
Loading