Skip to content

Commit

Permalink
Updated sources
Browse files Browse the repository at this point in the history
  • Loading branch information
product-team committed Nov 28, 2018
1 parent 544a41e commit 846ec33
Show file tree
Hide file tree
Showing 14 changed files with 264 additions and 16 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "groupdocs-viewer-cloud",
"version": "18.7.0",
"version": "18.11.0",
"description": "GroupDocs.Viewer Cloud SDK for Node.js",
"homepage": "https://products.groupdocs.cloud/viewer",
"author": {
Expand All @@ -26,6 +26,7 @@
"clean": "rimraf ./lib && rimraf ./node_modules",
"lint": "npm install --no-save && tslint src/{,**/}*.ts test/{,**/}*.ts -t verbose --project ./tsconfig.json",
"test": "npm install --no-save && mocha -r ts-node/register test/**/*.ts --timeout 60000 --reporter spec",
"test_debug": "npm install --no-save && mocha -r ts-node/register test/**/*.ts --timeout 60000 --reporter spec --nolazy --inspect-brk=9229",
"build:dev": "rimraf ./lib && npm install --no-save && tsc --build ./tsconfig-dev.json",
"build:lib": "rimraf ./lib && npm install --no-save && tsc --build ./tsconfig.json",
"build:package": "npm pack"
Expand Down
96 changes: 95 additions & 1 deletion src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export class AttachmentInfo {
}

/**
* The CAD documents rendering options.
* The CAD documents rendering options. Rendering of CAD file formats is not supported at the moment.
*/
export class CadOptions {

Expand Down Expand Up @@ -392,6 +392,16 @@ export class DocumentInfo {
name: "layers",
baseName: "layers",
type: "Array<string>",
},
{
name: "startDate",
baseName: "startDate",
type: "Date",
},
{
name: "endDate",
baseName: "endDate",
type: "Date",
} ];

/**
Expand Down Expand Up @@ -441,6 +451,16 @@ export class DocumentInfo {
*/
public layers: Array<string>;

/**
* For MS Project documents, The date time from which the project started.
*/
public startDate: Date;

/**
* For MS Project documents, the date time when the project is to be completed.
*/
public endDate: Date;

public constructor(init?: Partial<DocumentInfo>) {

Object.assign(this, init);
Expand Down Expand Up @@ -888,6 +908,39 @@ export class ImageAttachmentPageCollection {
}
}

/**
* The Outlook data files rendering options.
*/
export class OutlookOptions {

/**
* Attribute type map
*/
public static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [
{
name: "maxItemsInFolder",
baseName: "maxItemsInFolder",
type: "number",
} ];

/**
* Returns attribute type map
*/
public static getAttributeTypeMap() {
return OutlookOptions.attributeTypeMap;
}

/**
* The limit of items to render in mailbox folders
*/
public maxItemsInFolder: number;

public constructor(init?: Partial<OutlookOptions>) {

Object.assign(this, init);
}
}

/**
* Page information.
*/
Expand Down Expand Up @@ -1095,6 +1148,16 @@ export class ProjectOptions {
name: "timeUnit",
baseName: "timeUnit",
type: "string",
},
{
name: "startDate",
baseName: "startDate",
type: "Date",
},
{
name: "endDate",
baseName: "endDate",
type: "Date",
} ];

/**
Expand All @@ -1114,6 +1177,16 @@ export class ProjectOptions {
*/
public timeUnit: string;

/**
* The start date of a Gantt Chart View to render.
*/
public startDate: Date;

/**
* The end date of a Gantt Chart View to render.
*/
public endDate: Date;

public constructor(init?: Partial<ProjectOptions>) {

Object.assign(this, init);
Expand Down Expand Up @@ -1203,6 +1276,11 @@ export class RenderOptionsBase {
name: "projectOptions",
baseName: "projectOptions",
type: "ProjectOptions",
},
{
name: "outlookOptions",
baseName: "outlookOptions",
type: "OutlookOptions",
} ];

/**
Expand Down Expand Up @@ -1287,6 +1365,11 @@ export class RenderOptionsBase {
*/
public projectOptions: ProjectOptions;

/**
* The Outlook Data File document (PST/OST) rendering options.
*/
public outlookOptions: OutlookOptions;

public constructor(init?: Partial<RenderOptionsBase>) {

Object.assign(this, init);
Expand Down Expand Up @@ -2107,6 +2190,11 @@ export class HtmlOptions extends RenderOptions {
name: "excludeFonts",
baseName: "excludeFonts",
type: "boolean",
},
{
name: "excludeFontsList",
baseName: "excludeFontsList",
type: "Array<string>",
} ];

/**
Expand Down Expand Up @@ -2146,6 +2234,11 @@ export class HtmlOptions extends RenderOptions {
*/
public excludeFonts: boolean;

/**
* The list of font names, that will be excluded from HTML.
*/
public excludeFontsList: Array<string>;

public constructor(init?: Partial<HtmlOptions>) {
super(init);
Object.assign(this, init);
Expand Down Expand Up @@ -2234,6 +2327,7 @@ const typeMap = {
HtmlAttachmentPageCollection,
HtmlPageCollection,
ImageAttachmentPageCollection,
OutlookOptions,
PageInfo,
PageInfoCollection,
PdfOptions,
Expand Down
2 changes: 1 addition & 1 deletion src/package_version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@
/**
* Package version
*/
export const PackageVersion: string = "18.7.0";
export const PackageVersion: string = "18.11.0";
4 changes: 2 additions & 2 deletions src/serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class Serializer {
}
return transformedData;
} else if (type === "Date") {
return data.toString();
return data.toISOString();
} else {
if (enumsMap[type]) {
return data;
Expand Down Expand Up @@ -104,7 +104,7 @@ export class Serializer {
}
return transformedData;
} else if (type === "Date") {
return new Date(data);
return new Date(Date.parse(data));
} else {
if (enumsMap[type]) {// is Enum
return data;
Expand Down
23 changes: 15 additions & 8 deletions test/api/test_auth_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,34 +25,41 @@
import { expect } from "chai";
import "mocha";

import { Configuration } from "../../src/configuration";
import { ViewerApi } from "../../src/viewer_api";

describe("auth_api", () => {

describe("test_auth_error", () => {
it("should throw when app sid not found", () => {
const settings = require("../test_settings.json");
const appSid = "test";
const appKey = "test";
const viewerApi = ViewerApi.fromKeys(appSid, appKey);
const appKey = "test";

const config = new Configuration(appSid, appKey);
config.apiBaseUrl = settings.ApiBaseUrl;

const viewerApi = ViewerApi.fromConfig(config);

return viewerApi.getSupportedFileFormats()
.catch((error) => {
expect(error.code).equal(400);
expect(error.message).equal("Client 'test' is not registered in the system.");
});
});

it("should throw when app key not found", () => {
const settings = require("../test_settings.json");

const appSid = settings.AppSid;
const appKey = "test";
const viewerApi = ViewerApi.fromKeys(appSid, appKey);
const appKey = "test";

const config = new Configuration(appSid, appKey);
config.apiBaseUrl = settings.ApiBaseUrl;

const viewerApi = ViewerApi.fromConfig(config);

return viewerApi.getSupportedFileFormats()
.catch((error) => {
expect(error.code).equal(400);
expect(error.message).equals("Client '" + settings.AppSid + "' is not registered in the system.");
expect(error.message).equals("Client secret is invalid.");
});
});
});
Expand Down
31 changes: 30 additions & 1 deletion test/api/test_html_document_info_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ import { DocumentInfoOptions,
HtmlGetDocumentInfoFromUrlWithOptionsRequest,
HtmlGetDocumentInfoRequest,
HtmlGetDocumentInfoWithOptionsRequest,
SlidesOptions } from "../../src/model";
SlidesOptions,
ProjectOptions} from "../../src/model";

import * as TestContext from "../test_context";
import { TestFile } from "../test_file";
Expand Down Expand Up @@ -223,4 +224,32 @@ describe("html_document_info_api", () => {
});
});

describe("test_html_get_document_info_with_project_options", () => {
it("should return document information with project options", () => {
const file = TestFile.ProjectMpp;

const projectOptions = new ProjectOptions();
projectOptions.pageSize = "Unknown";
projectOptions.timeUnit = "Months";
projectOptions.startDate = new Date("2008/07/01");
projectOptions.endDate = new Date("2008/07/31");

const documentInfoOptions = new DocumentInfoOptions();
documentInfoOptions.projectOptions = projectOptions;

const request = new HtmlGetDocumentInfoWithOptionsRequest(file.fileName);
request.folder = file.folder;
request.documentInfoOptions = documentInfoOptions;

const viewerApi = TestContext.getViewerApi();
return viewerApi.htmlGetDocumentInfoWithOptions(request)
.then((result) => {
expect(result.pages.length).equal(2);
expect(result.extension).equal(".mpp");
expect(result.fileName).equal(file.fileName);
expect(result.startDate.getTime()).equal(Date.parse("2008/06/01"));
expect(result.endDate.getTime()).equal(Date.parse("2008/09/03"));
});
});
});
});
55 changes: 53 additions & 2 deletions test/api/test_html_document_pages_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ import { HtmlCreatePagesCacheFromContentRequest,
HtmlOptions,
HtmlTransformPagesRequest,
ReorderOptions,
RotateOptions } from "../../src/model";
RotateOptions,
ProjectOptions,
OutlookOptions} from "../../src/model";

import * as TestContext from "../test_context";
import { TestFile } from "../test_file";
Expand Down Expand Up @@ -242,5 +244,54 @@ describe("html_get_document_page_api", () => {
});
});
});


describe("test_html_create_document_pages_cache_w_opts", () => {
it("should create document pages cache with project options", () => {
const file = TestFile.ProjectMpp;

const projectOptions = new ProjectOptions();
projectOptions.timeUnit = "Days";
projectOptions.startDate = new Date("2008/07/01");
projectOptions.endDate = new Date("2008/07/31");

const htmlOptions = new HtmlOptions();
htmlOptions.embedResources = true;
htmlOptions.projectOptions = projectOptions;

const request = new HtmlCreatePagesCacheRequest(file.fileName);
request.folder = file.folder;
request.htmlOptions = htmlOptions;

const viewerApi = TestContext.getViewerApi();
return viewerApi.htmlCreatePagesCache(request)
.then((result) => {
expect(result.pages.length).to.be.equal(1);
expect(result.fileName).to.be.equal(file.fileName);
expect(result.folder).to.be.equal(file.folder);
});
});

it("should create document pages cache with outlook options", () => {
const file = TestFile.OutlookPst;

const outlookOptions = new OutlookOptions();
outlookOptions.maxItemsInFolder = 5;

const htmlOptions = new HtmlOptions();
htmlOptions.embedResources = true;
htmlOptions.outlookOptions = outlookOptions;

const request = new HtmlCreatePagesCacheRequest(file.fileName);
request.folder = file.folder;
request.htmlOptions = htmlOptions;

const viewerApi = TestContext.getViewerApi();
return viewerApi.htmlCreatePagesCache(request)
.then((result) => {
expect(result.pages.length).to.be.greaterThan(0);
expect(result.fileName).to.be.equal(file.fileName);
expect(result.folder).to.be.equal(file.folder);
});
});
});
});
Loading

0 comments on commit 846ec33

Please sign in to comment.