@elastic/ems-client
Advanced tools
Comparing version 7.8.0 to 7.8.1
{ | ||
"name": "@elastic/ems-client", | ||
"version": "7.8.0", | ||
"version": "7.8.1", | ||
"description": "JavaScript client library for the Elastic Maps Service", | ||
@@ -33,3 +33,2 @@ "main": "target/node/index.js", | ||
"devDependencies": { | ||
"node-fetch": "^1.7.3", | ||
"@babel/cli": "^7.6.4", | ||
@@ -40,4 +39,5 @@ "@babel/core": "^7.5.5", | ||
"babel-jest": "^24.9.0", | ||
"jest": "^24.9.0" | ||
"jest": "^24.9.0", | ||
"node-fetch": "^1.7.3" | ||
} | ||
} |
@@ -25,2 +25,3 @@ /* | ||
import { format as formatUrl, parse as parseUrl } from 'url'; | ||
import { toAbsoluteUrl } from './utils'; | ||
@@ -114,3 +115,3 @@ const DEFAULT_EMS_VERSION = '7.8'; | ||
} | ||
if (!fetchFunction || typeof fetchFunction !== 'function') { | ||
@@ -240,3 +241,3 @@ throw('No `fetchFunction` provided. This argument is required.'); | ||
type: 'tms', | ||
manifest: `${this._tileApiUrl}/${this._emsVersion}/manifest`, | ||
manifest: toAbsoluteUrl(this._tileApiUrl,`${this._emsVersion}/manifest`), | ||
}); | ||
@@ -247,3 +248,3 @@ } | ||
type: 'file', | ||
manifest: `${this._fileApiUrl}/${this._emsVersion}/manifest`, | ||
manifest: toAbsoluteUrl(this._fileApiUrl,`${this._emsVersion}/manifest`), | ||
}); | ||
@@ -250,0 +251,0 @@ } |
@@ -18,2 +18,4 @@ "use strict"; | ||
var _utils = require("./utils"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -234,3 +236,3 @@ | ||
type: 'tms', | ||
manifest: `${this._tileApiUrl}/${this._emsVersion}/manifest` | ||
manifest: (0, _utils.toAbsoluteUrl)(this._tileApiUrl, `${this._emsVersion}/manifest`) | ||
}); | ||
@@ -242,3 +244,3 @@ } | ||
type: 'file', | ||
manifest: `${this._fileApiUrl}/${this._emsVersion}/manifest` | ||
manifest: (0, _utils.toAbsoluteUrl)(this._fileApiUrl, `${this._emsVersion}/manifest`) | ||
}); | ||
@@ -245,0 +247,0 @@ } |
@@ -36,2 +36,3 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } | ||
import { format as formatUrl, parse as parseUrl } from 'url'; | ||
import { toAbsoluteUrl } from './utils'; | ||
var DEFAULT_EMS_VERSION = '7.8'; | ||
@@ -353,3 +354,3 @@ | ||
type: 'tms', | ||
manifest: "".concat(_this2._tileApiUrl, "/").concat(_this2._emsVersion, "/manifest") | ||
manifest: toAbsoluteUrl(_this2._tileApiUrl, "".concat(_this2._emsVersion, "/manifest")) | ||
}); | ||
@@ -361,3 +362,3 @@ } | ||
type: 'file', | ||
manifest: "".concat(_this2._fileApiUrl, "/").concat(_this2._emsVersion, "/manifest") | ||
manifest: toAbsoluteUrl(_this2._fileApiUrl, "".concat(_this2._emsVersion, "/manifest")) | ||
}); | ||
@@ -364,0 +365,0 @@ } |
@@ -26,3 +26,32 @@ /* | ||
it('should get api manifests', async () => { | ||
const emsClient = getEMSClient({ | ||
language: 'zz', | ||
tileApiUrl: 'https://tiles.foobar', | ||
fileApiUrl: 'https://files.foobar', | ||
emsVersion: '7.6', | ||
}); | ||
const spy = jest.spyOn(emsClient, 'getManifest'); | ||
await emsClient.getTMSServices(); | ||
await emsClient.getFileLayers(); | ||
expect(spy).toHaveBeenNthCalledWith(1, 'https://tiles.foobar/v7.6/manifest'); | ||
expect(spy).toHaveBeenNthCalledWith(2, 'https://files.foobar/v7.6/manifest'); | ||
}); | ||
it('should handle end slashes in api urls correctly', async () => { | ||
const emsClient = getEMSClient({ | ||
language: 'zz', | ||
tileApiUrl: 'https://tiles.foobar/', | ||
fileApiUrl: 'https://files.foobar/', | ||
emsVersion: '7.6', | ||
}); | ||
const spy = jest.spyOn(emsClient, 'getManifest'); | ||
await emsClient.getTMSServices(); | ||
await emsClient.getFileLayers(); | ||
expect(spy).toHaveBeenNthCalledWith(1, 'https://tiles.foobar/v7.6/manifest'); | ||
expect(spy).toHaveBeenNthCalledWith(2, 'https://files.foobar/v7.6/manifest'); | ||
}); | ||
it('should get the tile service', async () => { | ||
@@ -298,2 +327,1 @@ | ||
}); | ||
import { EMSClient } from '../src'; | ||
import fetch from 'node-fetch'; | ||
// describe('7.6 client - file', () => { | ||
// const emsClient = new EMSClient({ | ||
// appVersion: 'v7.6.0', | ||
// tileApiUrl: 'https://tiles.maps.elastic.co', | ||
// fileApiUrl: 'http://localhost:8000', | ||
// language: 'en', | ||
// }); | ||
describe.skip(() => true) | ||
describe.skip('7.6 client - file', () => { | ||
const emsClient = new EMSClient({ | ||
appVersion: 'v7.7.0', | ||
tileApiUrl: 'http://ems.local:8085/tile', | ||
fileApiUrl: 'http://ems.local:8085/file', | ||
language: 'en', | ||
fetchFunction: fetch, | ||
}); | ||
it('connects', async () => { | ||
const tms = await emsClient.getTMSServices(); | ||
const roadMapService = tms[0]; | ||
const stylesheet = await roadMapService.getVectorStyleSheet(); | ||
debugger; | ||
}); | ||
}); | ||
// it('layer', async() => { | ||
@@ -138,33 +151,33 @@ // const layers = await emsClient.getFileLayers(); | ||
describe('7.6 client - tile', () => { | ||
const emsClient = new EMSClient({ | ||
appVersion: 'v7.6.0', | ||
tileApiUrl: 'https://tiles.maps.elastic.co', | ||
fileApiUrl: 'https://vector-staging.maps.elastic.co', | ||
language: 'en', | ||
emsVersion: 'v7.6', | ||
}); | ||
// describe('7.6 client - tile', () => { | ||
// const emsClient = new EMSClient({ | ||
// appVersion: 'v7.6.0', | ||
// tileApiUrl: 'https://tiles.maps.elastic.co', | ||
// fileApiUrl: 'https://vector-staging.maps.elastic.co', | ||
// language: 'en', | ||
// emsVersion: 'v7.6', | ||
// }); | ||
it('expands url to relative host', async () => { | ||
const services = await emsClient.getTMSServices(); | ||
const service = services[0]; | ||
debugger; | ||
const defaultRaster = await service.getDefaultRasterStyle(); | ||
const urlTemplate = await service.getUrlTemplate(); | ||
const vectorStyleSheet = await service.getVectorStyleSheet(); | ||
const vectorStyleSheetRaw = await service.getVectorStyleSheetRaw(); | ||
const spriteSheetMeta = await service.getSpriteSheetMeta(); | ||
const spriteSheetJsonPath = await service.getSpriteSheetJsonPath(); | ||
const spriteSheetPngPath = await service.getSpriteSheetPngPath(); | ||
const displayName = service.getDisplayName(); | ||
const attributions = service.getAttributions(); | ||
const htmlAttribution = service.getHTMLAttribution(); | ||
const markdownAttribution = service.getMarkdownAttribution(); | ||
const minZoom = await service.getMinZoom(); | ||
const maxZoom = await service.getMaxZoom(); | ||
const id = service.getId(); | ||
const origin = service.getOrigin(); | ||
debugger; | ||
}); | ||
}); | ||
// it('expands url to relative host', async () => { | ||
// const services = await emsClient.getTMSServices(); | ||
// const service = services[0]; | ||
// debugger; | ||
// const defaultRaster = await service.getDefaultRasterStyle(); | ||
// const urlTemplate = await service.getUrlTemplate(); | ||
// const vectorStyleSheet = await service.getVectorStyleSheet(); | ||
// const vectorStyleSheetRaw = await service.getVectorStyleSheetRaw(); | ||
// const spriteSheetMeta = await service.getSpriteSheetMeta(); | ||
// const spriteSheetJsonPath = await service.getSpriteSheetJsonPath(); | ||
// const spriteSheetPngPath = await service.getSpriteSheetPngPath(); | ||
// const displayName = service.getDisplayName(); | ||
// const attributions = service.getAttributions(); | ||
// const htmlAttribution = service.getHTMLAttribution(); | ||
// const markdownAttribution = service.getMarkdownAttribution(); | ||
// const minZoom = await service.getMinZoom(); | ||
// const maxZoom = await service.getMaxZoom(); | ||
// const id = service.getId(); | ||
// const origin = service.getOrigin(); | ||
// debugger; | ||
// }); | ||
// }); | ||
@@ -171,0 +184,0 @@ // describe('7.6 client - tile', () => { |
608342
21307
2