@platform/cell.client
Advanced tools
Comparing version 0.3.65 to 0.3.66
@@ -90,3 +90,3 @@ "use strict"; | ||
var uri = common_1.Uri.toNs(input); | ||
return HttpClientNs_1.HttpClientNs.create({ uri: uri, urls: urls, http: http }); | ||
return HttpClientNs_1.HttpClientNs({ uri: uri, urls: urls, http: http }); | ||
}; | ||
@@ -97,3 +97,3 @@ HttpClient.prototype.cell = function (input) { | ||
var uri = common_1.Uri.cell(input); | ||
return HttpClientCell_1.HttpClientCell.create({ uri: uri, urls: urls, http: http }); | ||
return HttpClientCell_1.HttpClientCell({ uri: uri, urls: urls, http: http }); | ||
}; | ||
@@ -104,3 +104,3 @@ HttpClient.prototype.file = function (input) { | ||
var uri = common_1.Uri.file(input); | ||
return HttpClientFile_1.HttpClientFile.create({ uri: uri, urls: urls, http: http }); | ||
return HttpClientFile_1.HttpClientFile({ uri: uri, urls: urls, http: http }); | ||
}; | ||
@@ -107,0 +107,0 @@ return HttpClient; |
import { t } from '../common'; | ||
declare type IHttpClientCellArgs = { | ||
export declare function HttpClientCell(args: { | ||
uri: t.ICellUri; | ||
urls: t.IUrls; | ||
http: t.IHttp; | ||
}; | ||
export declare class HttpClientCell implements t.IHttpClientCell { | ||
static create(args: IHttpClientCellArgs): t.IHttpClientCell; | ||
private constructor(); | ||
private readonly args; | ||
private _file; | ||
private _files; | ||
readonly uri: t.ICellUri; | ||
readonly url: t.IUrlsCell; | ||
get file(): t.IHttpClientCellFile; | ||
get fs(): t.IHttpClientCellFs; | ||
toString(): string; | ||
exists(): Promise<boolean>; | ||
info(options?: t.IReqQueryCellInfo): Promise<t.IHttpClientResponse<t.IResGetCell>>; | ||
links(): Promise<t.IHttpClientResponse<t.IHttpClientCellLinks>>; | ||
} | ||
export {}; | ||
}): t.IHttpClientCell; |
@@ -9,85 +9,62 @@ "use strict"; | ||
var HttpClientCellLinks_1 = require("./HttpClientCellLinks"); | ||
var HttpClientCell = (function () { | ||
function HttpClientCell(args) { | ||
var urls = args.urls; | ||
this.args = args; | ||
this.uri = args.uri; | ||
this.url = urls.cell(args.uri); | ||
} | ||
HttpClientCell.create = function (args) { | ||
return new HttpClientCell(args); | ||
}; | ||
Object.defineProperty(HttpClientCell.prototype, "file", { | ||
get: function () { | ||
var _a = this.args, urls = _a.urls, http = _a.http; | ||
return this._file || (this._file = HttpClientCellFile_1.HttpClientCellFile.create({ parent: this, urls: urls, http: http })); | ||
function HttpClientCell(args) { | ||
var uri = args.uri, urls = args.urls, http = args.http; | ||
var file; | ||
var fs; | ||
var links; | ||
var api = { | ||
uri: uri, | ||
get url() { | ||
return urls.cell(uri); | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
Object.defineProperty(HttpClientCell.prototype, "fs", { | ||
get: function () { | ||
var _a = this.args, urls = _a.urls, http = _a.http; | ||
return this._files || (this._files = HttpClientCellFs_1.HttpClientCellFs.create({ parent: this, urls: urls, http: http })); | ||
get file() { | ||
if (file) | ||
return file; | ||
return (file = HttpClientCellFile_1.HttpClientCellFile({ parent: parent, urls: urls, http: http })); | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
HttpClientCell.prototype.toString = function () { | ||
return this.uri.toString(); | ||
}; | ||
HttpClientCell.prototype.exists = function () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var res; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4, this.args.http.get(this.url.info.toString())]; | ||
case 1: | ||
res = _a.sent(); | ||
return [2, res.status.toString().startsWith('2')]; | ||
} | ||
get fs() { | ||
if (fs) | ||
return fs; | ||
return (fs = HttpClientCellFs_1.HttpClientCellFs.create({ parent: parent, urls: urls, http: http })); | ||
}, | ||
get links() { | ||
var _this = this; | ||
if (links) | ||
return links; | ||
return (links = HttpClientCellLinks_1.HttpClientCellLinks({ uri: uri, urls: urls, http: http, getInfo: function () { return _this.info(); } })); | ||
}, | ||
exists: function () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var res; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4, http.get(api.url.info.toString())]; | ||
case 1: | ||
res = _a.sent(); | ||
return [2, res.status.toString().startsWith('2')]; | ||
} | ||
}); | ||
}); | ||
}); | ||
}; | ||
HttpClientCell.prototype.info = function (options) { | ||
if (options === void 0) { options = {}; } | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var http, url, res; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
http = this.args.http; | ||
url = this.url.info.query(options).toString(); | ||
return [4, http.get(url)]; | ||
case 1: | ||
res = _a.sent(); | ||
return [2, common_1.util.fromHttpResponse(res).toClientResponse()]; | ||
} | ||
}, | ||
info: function (options) { | ||
if (options === void 0) { options = {}; } | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var url, res; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
url = api.url.info.query(options).toString(); | ||
return [4, http.get(url)]; | ||
case 1: | ||
res = _a.sent(); | ||
return [2, common_1.util.fromHttpResponse(res).toClientResponse()]; | ||
} | ||
}); | ||
}); | ||
}); | ||
}, | ||
toString: function () { return uri.toString(); }, | ||
}; | ||
HttpClientCell.prototype.links = function () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var info, message, http, cell, links, urls, body; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4, this.info()]; | ||
case 1: | ||
info = _a.sent(); | ||
if (info.error) { | ||
message = "Failed to get links for '" + this.uri.toString() + "'. " + info.error.message; | ||
return [2, common_1.util.toError(info.status, info.error.type, message)]; | ||
} | ||
http = this.args.http; | ||
cell = info.body.data; | ||
links = cell.links || {}; | ||
urls = this.args.urls; | ||
body = HttpClientCellLinks_1.HttpClientCellLinks.create({ links: links, urls: urls, http: http }); | ||
return [2, common_1.util.toClientResponse(200, body)]; | ||
} | ||
}); | ||
}); | ||
}; | ||
return HttpClientCell; | ||
}()); | ||
var parent = api; | ||
return api; | ||
} | ||
exports.HttpClientCell = HttpClientCell; |
import { t } from '../common'; | ||
declare type IClientCellFileArgs = { | ||
export declare function HttpClientCellFile(args: { | ||
parent: t.IHttpClientCell; | ||
urls: t.IUrls; | ||
http: t.IHttp; | ||
}; | ||
export declare class HttpClientCellFile implements t.IHttpClientCellFile { | ||
static create(args: IClientCellFileArgs): t.IHttpClientCellFile; | ||
private constructor(); | ||
private readonly args; | ||
name(path: string): t.IHttpClientCellFileByName; | ||
private getCellInfo; | ||
private getCellLinkByFilename; | ||
} | ||
export {}; | ||
}): t.IHttpClientCellFile; |
@@ -6,160 +6,142 @@ "use strict"; | ||
var common_1 = require("../common"); | ||
var HttpClientCellFile = (function () { | ||
function HttpClientCellFile(args) { | ||
this.args = args; | ||
} | ||
HttpClientCellFile.create = function (args) { | ||
return new HttpClientCellFile(args); | ||
}; | ||
HttpClientCellFile.prototype.name = function (path) { | ||
var http = this.args.http; | ||
var self = this; | ||
var parent = this.args.parent; | ||
var file = { | ||
info: function () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var linkRes, link, url, res; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4, self.getCellLinkByFilename(path)]; | ||
case 1: | ||
linkRes = _a.sent(); | ||
if (linkRes.error) { | ||
return [2, linkRes.error]; | ||
} | ||
if (!linkRes.link) { | ||
throw new Error("Link should exist."); | ||
} | ||
link = linkRes.link; | ||
url = self.args.urls.file(link.uri).info; | ||
return [4, http.get(url.toString())]; | ||
case 2: | ||
res = _a.sent(); | ||
return [2, common_1.util.fromHttpResponse(res).toClientResponse()]; | ||
} | ||
function HttpClientCellFile(args) { | ||
var parent = args.parent, urls = args.urls, http = args.http; | ||
var api = { | ||
name: function (path) { | ||
var file = { | ||
info: function () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var linkRes, link, url, res; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4, getCellLinkByFilename(parent, path)]; | ||
case 1: | ||
linkRes = _a.sent(); | ||
if (linkRes.error) { | ||
return [2, linkRes.error]; | ||
} | ||
if (!linkRes.link) { | ||
throw new Error("Link should exist."); | ||
} | ||
link = linkRes.link; | ||
url = urls.file(link.uri).info; | ||
return [4, http.get(url.toString())]; | ||
case 2: | ||
res = _a.sent(); | ||
return [2, common_1.util.fromHttpResponse(res).toClientResponse()]; | ||
} | ||
}); | ||
}); | ||
}); | ||
}, | ||
exists: function () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var info; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4, file.info()]; | ||
case 1: | ||
info = _a.sent(); | ||
return [2, info.ok && info.body.exists]; | ||
} | ||
}, | ||
exists: function () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var info; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4, file.info()]; | ||
case 1: | ||
info = _a.sent(); | ||
return [2, info.ok && info.body.exists]; | ||
} | ||
}); | ||
}); | ||
}); | ||
}, | ||
download: function (options) { | ||
if (options === void 0) { options = {}; } | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var expires, linkRes, link, hash, url, res, mime_1, bodyType, message, httpError, error; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
expires = options.expires; | ||
return [4, self.getCellLinkByFilename(path)]; | ||
case 1: | ||
linkRes = _a.sent(); | ||
if (linkRes.error) { | ||
return [2, linkRes.error]; | ||
} | ||
if (!linkRes.link) { | ||
throw new Error("Link should exist."); | ||
} | ||
link = linkRes.link; | ||
hash = link.query.hash || undefined; | ||
url = parent.url.file | ||
.byFileUri(link.uri.toString(), link.ext) | ||
.query({ hash: hash, expires: expires }) | ||
.toString(); | ||
return [4, http.get(url)]; | ||
case 2: | ||
res = _a.sent(); | ||
if (res.ok) { | ||
mime_1 = (res.headers['content-type'] || '').toString().trim(); | ||
bodyType = toBodyType(mime_1); | ||
return [2, common_1.util.fromHttpResponse(res).toClientResponse({ bodyType: bodyType })]; | ||
} | ||
else { | ||
message = "Failed while downloading file \"" + parent.uri.toString() + "\"."; | ||
httpError = res.contentType.is.json ? res.json : undefined; | ||
if (httpError) { | ||
error = message + " " + httpError.message; | ||
return [2, common_1.util.toError(res.status, httpError.type, error)]; | ||
}, | ||
download: function (options) { | ||
if (options === void 0) { options = {}; } | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var expires, linkRes, link, hash, url, res, mime_1, bodyType, message, httpError, error; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
expires = options.expires; | ||
return [4, getCellLinkByFilename(parent, path)]; | ||
case 1: | ||
linkRes = _a.sent(); | ||
if (linkRes.error) | ||
return [2, linkRes.error]; | ||
if (!linkRes.link) { | ||
throw new Error("Link should exist."); | ||
} | ||
link = linkRes.link; | ||
hash = link.query.hash || undefined; | ||
url = parent.url.file | ||
.byFileUri(link.uri.toString(), link.ext) | ||
.query({ hash: hash, expires: expires }) | ||
.toString(); | ||
return [4, http.get(url)]; | ||
case 2: | ||
res = _a.sent(); | ||
if (res.ok) { | ||
mime_1 = (res.headers['content-type'] || '').toString().trim(); | ||
bodyType = toBodyType(mime_1); | ||
return [2, common_1.util.fromHttpResponse(res).toClientResponse({ bodyType: bodyType })]; | ||
} | ||
else { | ||
return [2, common_1.util.toError(res.status, common_1.ERROR.HTTP.SERVER, message)]; | ||
message = "Failed while downloading file \"" + parent.uri.toString() + "\"."; | ||
httpError = res.contentType.is.json ? res.json : undefined; | ||
if (httpError) { | ||
error = message + " " + httpError.message; | ||
return [2, common_1.util.toError(res.status, httpError.type, error)]; | ||
} | ||
else { | ||
return [2, common_1.util.toError(res.status, common_1.ERROR.HTTP.SERVER, message)]; | ||
} | ||
} | ||
} | ||
return [2]; | ||
} | ||
return [2]; | ||
} | ||
}); | ||
}); | ||
}); | ||
}, | ||
}; | ||
return file; | ||
}, | ||
}; | ||
return file; | ||
}, | ||
}; | ||
HttpClientCellFile.prototype.getCellInfo = function () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var parent, res, message, error, data; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
parent = this.args.parent; | ||
return [4, parent.info()]; | ||
case 1: | ||
res = _a.sent(); | ||
if (!res.body) { | ||
message = "Info about the cell \"" + parent.uri.toString() + "\" not found."; | ||
error = common_1.util.toError(404, common_1.ERROR.HTTP.NOT_FOUND, message); | ||
return [2, { res: res, error: error }]; | ||
} | ||
else { | ||
data = res.body.data; | ||
return [2, { res: res, data: data }]; | ||
} | ||
return [2]; | ||
} | ||
}); | ||
}); | ||
}; | ||
HttpClientCellFile.prototype.getCellLinkByFilename = function (path) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var parent, _a, error, data, link, message, error_1; | ||
return tslib_1.__generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
parent = this.args.parent; | ||
return [4, this.getCellInfo()]; | ||
case 1: | ||
_a = _b.sent(), error = _a.error, data = _a.data; | ||
if (!data || error) { | ||
return [2, { error: error }]; | ||
} | ||
link = common_1.Schema.File.Links.find(data.links).byName(path); | ||
if (!link) { | ||
message = "A link within \"" + parent.uri.toString() + "\" to the filename '" + path + "' does not exist."; | ||
error_1 = common_1.util.toError(404, common_1.ERROR.HTTP.NOT_LINKED, message); | ||
return [2, { error: error_1 }]; | ||
} | ||
return [2, { link: link }]; | ||
} | ||
}); | ||
}); | ||
}; | ||
return HttpClientCellFile; | ||
}()); | ||
return api; | ||
} | ||
exports.HttpClientCellFile = HttpClientCellFile; | ||
function toBodyType(mime) { | ||
if (mime === 'application/json') { | ||
if (mime === 'application/json') | ||
return 'JSON'; | ||
} | ||
if (mime.startsWith('text/')) { | ||
if (mime.startsWith('text/')) | ||
return 'TEXT'; | ||
} | ||
return 'BINARY'; | ||
} | ||
var getCellInfo = function (cell) { return tslib_1.__awaiter(void 0, void 0, void 0, function () { | ||
var res, message, error, data; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4, cell.info()]; | ||
case 1: | ||
res = _a.sent(); | ||
if (!res.body) { | ||
message = "Info about the cell \"" + cell.uri.toString() + "\" not found."; | ||
error = common_1.util.toError(404, common_1.ERROR.HTTP.NOT_FOUND, message); | ||
return [2, { res: res, error: error }]; | ||
} | ||
else { | ||
data = res.body.data; | ||
return [2, { res: res, data: data }]; | ||
} | ||
return [2]; | ||
} | ||
}); | ||
}); }; | ||
var getCellLinkByFilename = function (cell, path) { return tslib_1.__awaiter(void 0, void 0, void 0, function () { | ||
var _a, error, data, link, message, error_1; | ||
return tslib_1.__generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: return [4, getCellInfo(cell)]; | ||
case 1: | ||
_a = _b.sent(), error = _a.error, data = _a.data; | ||
if (!data || error) | ||
return [2, { error: error }]; | ||
link = common_1.Schema.File.Links.find(data.links).byName(path); | ||
if (!link) { | ||
message = "A link within \"" + cell.uri.toString() + "\" to the filename '" + path + "' does not exist."; | ||
error_1 = common_1.util.toError(404, common_1.ERROR.HTTP.NOT_LINKED, message); | ||
return [2, { error: error_1 }]; | ||
} | ||
return [2, { link: link }]; | ||
} | ||
}); | ||
}); }; |
import { t } from '../common'; | ||
declare type IHttpClientCellLinksArgs = { | ||
links: t.ICellData['links']; | ||
export * from './HttpClientCellLinks.info'; | ||
export declare function HttpClientCellLinks(args: { | ||
uri: t.ICellUri; | ||
urls: t.IUrls; | ||
http: t.IHttp; | ||
}; | ||
export declare class HttpClientCellLinks implements t.IHttpClientCellLinks { | ||
static create(args: IHttpClientCellLinksArgs): t.IHttpClientCellLinks; | ||
private constructor(); | ||
private readonly args; | ||
readonly list: t.IHttpClientCellLink[]; | ||
get files(): t.IHttpClientCellLinkFile[]; | ||
toObject(): t.IUriMap | undefined; | ||
private toLink; | ||
} | ||
export {}; | ||
getInfo: () => Promise<t.IHttpClientResponse<t.IResGetCell>>; | ||
}): t.IHttpClientCellLinks; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.HttpClientCellLinks = void 0; | ||
var tslib_1 = require("tslib"); | ||
var common_1 = require("../common"); | ||
var HttpClientFile_1 = require("./HttpClientFile"); | ||
var HttpClientCellLinks = (function () { | ||
function HttpClientCellLinks(args) { | ||
var _this = this; | ||
var _a = args.links, links = _a === void 0 ? {} : _a; | ||
this.args = args; | ||
this.list = Object.keys(links).map(function (key) { return _this.toLink(key, links[key]); }); | ||
} | ||
HttpClientCellLinks.create = function (args) { | ||
return new HttpClientCellLinks(args); | ||
}; | ||
Object.defineProperty(HttpClientCellLinks.prototype, "files", { | ||
get: function () { | ||
return this.list.filter(function (item) { return item.type === 'FILE'; }); | ||
var HttpClientCellLinks_1 = require("./HttpClientCellLinks"); | ||
var HttpClientNs_1 = require("./HttpClientNs"); | ||
tslib_1.__exportStar(require("./HttpClientCellLinks.info"), exports); | ||
function HttpClientCellLinks(args) { | ||
var uri = args.uri, urls = args.urls, http = args.http; | ||
var RefLinks = common_1.Schema.Ref.Links; | ||
var api = { | ||
read: function () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var info, message, cell, links, body; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4, args.getInfo()]; | ||
case 1: | ||
info = _a.sent(); | ||
if (info.error) { | ||
message = "Failed to get links for '" + uri.toString() + "'. " + info.error.message; | ||
return [2, common_1.util.toError(info.status, info.error.type, message)]; | ||
} | ||
cell = info.body.data; | ||
links = cell.links || {}; | ||
body = HttpClientCellLinks_1.HttpClientCellLinksInfo({ links: links, urls: urls, http: http }); | ||
return [2, common_1.util.toClientResponse(200, body)]; | ||
} | ||
}); | ||
}); | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
HttpClientCellLinks.prototype.toObject = function () { | ||
return this.args.links; | ||
write: function (input, options) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var list, links, ns; | ||
var _a; | ||
return tslib_1.__generator(this, function (_b) { | ||
list = Array.isArray(input) ? input : [input]; | ||
links = list | ||
.map(function (link) { return (tslib_1.__assign(tslib_1.__assign({}, link), { key: RefLinks.toKey(link.key) })); }) | ||
.reduce(function (acc, next) { | ||
acc[next.key] = (next.value || '').trim(); | ||
return acc; | ||
}, {}); | ||
ns = HttpClientNs_1.HttpClientNs({ uri: common_1.Uri.ns(uri.ns), urls: urls, http: http }); | ||
return [2, ns.write({ cells: (_a = {}, _a[uri.key] = { links: links }, _a) }, options)]; | ||
}); | ||
}); | ||
}, | ||
delete: function (input, options) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var keys, links; | ||
return tslib_1.__generator(this, function (_a) { | ||
keys = Array.isArray(input) ? input : [input]; | ||
links = keys.map(function (key) { return ({ key: key, value: '' }); }); | ||
return [2, api.write(links, options)]; | ||
}); | ||
}); | ||
}, | ||
}; | ||
HttpClientCellLinks.prototype.toLink = function (key, value) { | ||
var _a = this.args, http = _a.http, urls = _a.urls; | ||
var uri = common_1.Uri.parse(value); | ||
var type = uri.parts.type; | ||
if (type === 'FILE') { | ||
var file_1; | ||
var link = common_1.Schema.File.Links.parseValue(value); | ||
var uri_1 = link.uri; | ||
var hash = link.query.hash || ''; | ||
var _b = common_1.Schema.File.Links.parseKey(key), name_1 = _b.name, dir = _b.dir, path = _b.path; | ||
var res_1 = { | ||
type: 'FILE', | ||
uri: uri_1.toString(), | ||
key: key, | ||
path: path, | ||
dir: dir, | ||
name: name_1, | ||
hash: hash, | ||
get file() { | ||
return file_1 || (file_1 = HttpClientFile_1.HttpClientFile.create({ uri: uri_1, urls: urls, http: http })); | ||
}, | ||
}; | ||
return res_1; | ||
} | ||
var res = { type: 'UNKNOWN', key: key, uri: value }; | ||
return res; | ||
}; | ||
return HttpClientCellLinks; | ||
}()); | ||
return api; | ||
} | ||
exports.HttpClientCellLinks = HttpClientCellLinks; |
import { t } from '../common'; | ||
export declare type IClientFileArgs = { | ||
export declare function HttpClientFile(args: { | ||
uri: t.IFileUri; | ||
urls: t.IUrls; | ||
http: t.IHttp; | ||
}; | ||
export declare class HttpClientFile implements t.IHttpClientFile { | ||
static create(args: IClientFileArgs): t.IHttpClientFile; | ||
private constructor(); | ||
private readonly args; | ||
readonly uri: t.IFileUri; | ||
readonly url: t.IUrlsFile; | ||
toString(): string; | ||
info(): Promise<t.IHttpClientResponse<t.IResGetFile>>; | ||
} | ||
}): t.IHttpClientFile; |
@@ -6,33 +6,28 @@ "use strict"; | ||
var common_1 = require("../common"); | ||
var HttpClientFile = (function () { | ||
function HttpClientFile(args) { | ||
var urls = args.urls; | ||
this.args = args; | ||
this.uri = args.uri; | ||
this.url = urls.file(args.uri); | ||
} | ||
HttpClientFile.create = function (args) { | ||
return new HttpClientFile(args); | ||
}; | ||
HttpClientFile.prototype.toString = function () { | ||
return this.uri.toString(); | ||
}; | ||
HttpClientFile.prototype.info = function () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var http, url, res; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
http = this.args.http; | ||
url = this.url.info; | ||
return [4, http.get(url.toString())]; | ||
case 1: | ||
res = _a.sent(); | ||
return [2, common_1.util.fromHttpResponse(res).toClientResponse()]; | ||
} | ||
function HttpClientFile(args) { | ||
var uri = args.uri, urls = args.urls, http = args.http; | ||
var api = { | ||
uri: uri, | ||
get url() { | ||
return urls.file(uri); | ||
}, | ||
info: function () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var url, res; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
url = api.url.info.toString(); | ||
return [4, http.get(url)]; | ||
case 1: | ||
res = _a.sent(); | ||
return [2, common_1.util.fromHttpResponse(res).toClientResponse()]; | ||
} | ||
}); | ||
}); | ||
}); | ||
}, | ||
toString: function () { return uri.toString(); }, | ||
}; | ||
return HttpClientFile; | ||
}()); | ||
return api; | ||
} | ||
exports.HttpClientFile = HttpClientFile; |
@@ -7,12 +7,6 @@ import { t } from '../common'; | ||
}; | ||
export declare class HttpClientNs implements t.IHttpClientNs { | ||
static create(args: IClientNsArgs): t.IHttpClientNs; | ||
private constructor(); | ||
private readonly args; | ||
readonly uri: t.INsUri; | ||
readonly url: t.IUrlsNs; | ||
toString(): string; | ||
exists(): Promise<boolean>; | ||
read(options?: t.IReqQueryNsInfo): Promise<t.IHttpClientResponse<t.IResGetNs>>; | ||
write(data: t.IReqPostNsBody, options?: t.IReqQueryNsWrite): Promise<t.IHttpClientResponse<t.IResPostNs>>; | ||
} | ||
export declare function HttpClientNs(args: { | ||
uri: t.INsUri; | ||
urls: t.IUrls; | ||
http: t.IHttp; | ||
}): t.IHttpClientNs; |
@@ -6,64 +6,58 @@ "use strict"; | ||
var common_1 = require("../common"); | ||
var HttpClientNs = (function () { | ||
function HttpClientNs(args) { | ||
var urls = args.urls; | ||
this.args = args; | ||
this.uri = args.uri; | ||
this.url = urls.ns(args.uri); | ||
} | ||
HttpClientNs.create = function (args) { | ||
return new HttpClientNs(args); | ||
}; | ||
HttpClientNs.prototype.toString = function () { | ||
return this.uri.toString(); | ||
}; | ||
HttpClientNs.prototype.exists = function () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var res; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4, this.args.http.get(this.url.info.toString())]; | ||
case 1: | ||
res = _a.sent(); | ||
return [2, res.status.toString().startsWith('2')]; | ||
} | ||
function HttpClientNs(args) { | ||
var uri = args.uri, urls = args.urls, http = args.http; | ||
var api = { | ||
uri: uri, | ||
get url() { | ||
return urls.ns(uri); | ||
}, | ||
exists: function () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var res; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4, http.get(api.url.info.toString())]; | ||
case 1: | ||
res = _a.sent(); | ||
return [2, res.status.toString().startsWith('2')]; | ||
} | ||
}); | ||
}); | ||
}); | ||
}; | ||
HttpClientNs.prototype.read = function (options) { | ||
if (options === void 0) { options = {}; } | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var http, url, res; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
http = this.args.http; | ||
url = this.url.info.query(options).toString(); | ||
return [4, http.get(url)]; | ||
case 1: | ||
res = _a.sent(); | ||
return [2, common_1.util.fromHttpResponse(res).toClientResponse()]; | ||
} | ||
}, | ||
read: function (options) { | ||
if (options === void 0) { options = {}; } | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var url, res; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
url = api.url.info.query(options).toString(); | ||
return [4, http.get(url)]; | ||
case 1: | ||
res = _a.sent(); | ||
return [2, common_1.util.fromHttpResponse(res).toClientResponse()]; | ||
} | ||
}); | ||
}); | ||
}); | ||
}; | ||
HttpClientNs.prototype.write = function (data, options) { | ||
if (options === void 0) { options = {}; } | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var http, url, res; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
http = this.args.http; | ||
url = this.url.info.query(options).toString(); | ||
return [4, http.post(url, data)]; | ||
case 1: | ||
res = _a.sent(); | ||
return [2, common_1.util.fromHttpResponse(res).toClientResponse()]; | ||
} | ||
}, | ||
write: function (data, options) { | ||
if (options === void 0) { options = {}; } | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var url, res; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
url = api.url.info.query(options).toString(); | ||
return [4, http.post(url, data)]; | ||
case 1: | ||
res = _a.sent(); | ||
return [2, common_1.util.fromHttpResponse(res).toClientResponse()]; | ||
} | ||
}); | ||
}); | ||
}); | ||
}, | ||
toString: function () { return uri.toString(); }, | ||
}; | ||
return HttpClientNs; | ||
}()); | ||
return api; | ||
} | ||
exports.HttpClientNs = HttpClientNs; |
@@ -6,7 +6,7 @@ "use strict"; | ||
name: '@platform/cell.client', | ||
version: '0.3.65', | ||
version: '0.3.66', | ||
dependencies: { | ||
'@platform/cell.schema': '0.5.75', | ||
'@platform/cell.types': '0.5.72', | ||
'@platform/cell.typesystem': '0.0.194', | ||
'@platform/cell.schema': '0.5.76', | ||
'@platform/cell.types': '0.5.73', | ||
'@platform/cell.typesystem': '0.0.195', | ||
'@platform/http': '0.14.19', | ||
@@ -13,0 +13,0 @@ '@platform/http.types': '0.2.42', |
{ | ||
"name": "@platform/cell.client", | ||
"version": "0.3.65", | ||
"version": "0.3.66", | ||
"description": "A strongly typed HTTP client for operating with a CellOS service end-point.", | ||
@@ -16,5 +16,5 @@ "main": "lib/index", | ||
"dependencies": { | ||
"@platform/cell.schema": "0.5.75", | ||
"@platform/cell.types": "0.5.72", | ||
"@platform/cell.typesystem": "0.0.194", | ||
"@platform/cell.schema": "0.5.76", | ||
"@platform/cell.types": "0.5.73", | ||
"@platform/cell.typesystem": "0.0.195", | ||
"@platform/http": "0.14.19", | ||
@@ -21,0 +21,0 @@ "@platform/http.types": "0.2.42", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
82329
61
1821
+ Added@platform/cell.coord@0.8.258(transitive)
+ Added@platform/cell.schema@0.5.76(transitive)
+ Added@platform/cell.types@0.5.73(transitive)
+ Added@platform/cell.typesystem@0.0.195(transitive)
- Removed@platform/cell.coord@0.8.257(transitive)
- Removed@platform/cell.schema@0.5.75(transitive)
- Removed@platform/cell.types@0.5.72(transitive)
- Removed@platform/cell.typesystem@0.0.194(transitive)
Updated@platform/cell.schema@0.5.76
Updated@platform/cell.types@0.5.73