@elastic.io/maester-client
Advanced tools
Comparing version 1.1.0 to 1.2.0-beta
{ | ||
"name": "@elastic.io/maester-client", | ||
"version": "1.1.0", | ||
"version": "1.2.0-beta", | ||
"description": "The official object-storage client for sailor-nodejs.", | ||
@@ -40,2 +40,3 @@ "main": "dist/src/index.js", | ||
"chai": "4.2.0", | ||
"dotenv": "8.2.0", | ||
"eslint": "6.8.0", | ||
@@ -42,0 +43,0 @@ "eslint-config-standard-with-typescript": "15.0.1", |
@@ -0,0 +0,0 @@ import { AxiosInstance } from 'axios'; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ import BucketRepository from './bucket'; |
@@ -0,0 +0,0 @@ "use strict"; |
export * from './client'; | ||
export * from './bucket'; | ||
export * from './object'; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -5,2 +5,3 @@ /// <reference types="node" /> | ||
export declare const USER_META_HEADER_PREFIX = "x-meta-"; | ||
export declare const USER_QUERY_HEADER_PREFIX = "x-query-"; | ||
export declare const DEFAULT_CONTENT_TYPE = "application/octet-stream"; | ||
@@ -17,7 +18,9 @@ export declare type PlainOrArray<T> = T | T[]; | ||
export declare function headersToMeta(headers: Record<string, string>): ObjectMetadata; | ||
export declare function headersToQuery(headers: Record<string, string>): ObjectMetadata; | ||
export declare class GetObjectResponse { | ||
readonly contentType: string; | ||
readonly contentLength: number; | ||
readonly metadata: ObjectMetadata; | ||
readonly data: object | string | Buffer | Readable; | ||
readonly contentType?: string; | ||
readonly contentLength?: number; | ||
readonly metadata?: ObjectMetadata; | ||
readonly queriableFields?: QueriableField; | ||
constructor(res: AxiosResponse); | ||
@@ -58,4 +61,4 @@ } | ||
readonly contentType: string; | ||
readonly contentLength: number; | ||
readonly md5: string; | ||
readonly contentLength?: number; | ||
readonly md5?: string; | ||
readonly createdAt: Date | null; | ||
@@ -62,0 +65,0 @@ readonly metadata: ObjectMetadata; |
@@ -9,2 +9,3 @@ "use strict"; | ||
exports.USER_META_HEADER_PREFIX = 'x-meta-'; | ||
exports.USER_QUERY_HEADER_PREFIX = 'x-query-'; | ||
exports.DEFAULT_CONTENT_TYPE = 'application/octet-stream'; | ||
@@ -33,10 +34,30 @@ function isObjectData(data) { | ||
exports.headersToMeta = headersToMeta; | ||
function headersToQuery(headers) { | ||
const meta = {}; | ||
for (const [key, value] of Object.entries(headers)) { | ||
if (key.indexOf(exports.USER_QUERY_HEADER_PREFIX) === 0) { | ||
meta[key.substr(exports.USER_QUERY_HEADER_PREFIX.length)] = value; | ||
} | ||
} | ||
return meta; | ||
} | ||
exports.headersToQuery = headersToQuery; | ||
class GetObjectResponse { | ||
constructor(res) { | ||
var _a, _b; | ||
const { headers, data } = res; | ||
this.contentType = (_a = headers['content-type']) !== null && _a !== void 0 ? _a : ''; | ||
this.contentLength = parseInt((_b = headers['content-length']) !== null && _b !== void 0 ? _b : 0); | ||
this.metadata = headersToMeta(headers); | ||
this.data = data; | ||
if (headers['content-type']) { | ||
this.contentType = headers['content-type']; | ||
} | ||
if (headers['content-length']) { | ||
this.contentLength = parseInt(headers['content-length']); | ||
} | ||
const metadata = headersToMeta(headers); | ||
if (Object.keys(metadata).length !== 0) { | ||
this.metadata = metadata; | ||
} | ||
const queriableFields = headersToQuery(headers); | ||
if (Object.keys(queriableFields).length !== 0) { | ||
this.queriableFields = queriableFields; | ||
} | ||
} | ||
@@ -50,4 +71,8 @@ } | ||
this.contentType = contentType !== null && contentType !== void 0 ? contentType : ''; | ||
this.contentLength = contentLength !== null && contentLength !== void 0 ? contentLength : 0; | ||
this.md5 = md5 !== null && md5 !== void 0 ? md5 : ''; | ||
if (contentLength) { | ||
this.contentLength = contentLength; | ||
} | ||
if (md5) { | ||
this.md5 = md5; | ||
} | ||
this.createdAt = createdAt ? new Date(createdAt) : null; | ||
@@ -54,0 +79,0 @@ this.metadata = metadata !== null && metadata !== void 0 ? metadata : {}; |
{ | ||
"name": "@elastic.io/maester-client", | ||
"version": "1.1.0", | ||
"version": "1.2.0-beta", | ||
"description": "The official object-storage client for sailor-nodejs.", | ||
@@ -40,2 +40,3 @@ "main": "dist/src/index.js", | ||
"chai": "4.2.0", | ||
"dotenv": "8.2.0", | ||
"eslint": "6.8.0", | ||
@@ -42,0 +43,0 @@ "eslint-config-standard-with-typescript": "15.0.1", |
@@ -9,3 +9,3 @@ # Maester Client | ||
``` | ||
const Client = require('@elasticio/maester-client'); | ||
const { Client } = require('@elastic.io/maester-client'); | ||
@@ -15,3 +15,3 @@ const client = new Client('http://maester.local:3002', 'my-token'); | ||
### Buckets API | ||
### Buckets API (deprecated) | ||
@@ -18,0 +18,0 @@ Get bucket: |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
44576
21
921
1