@mongodb-js/dl-center
Advanced tools
Comparing version 1.0.1 to 1.1.1
@@ -5,8 +5,3 @@ export interface DownloadCenterConfig { | ||
version: string; | ||
platform: { | ||
arch: string; | ||
os: string; | ||
name: string; | ||
download_link: string; | ||
}[]; | ||
platform: (PlatformWithDownloadLink | PlatformWithPackages)[]; | ||
}[]; | ||
@@ -20,1 +15,20 @@ manual_link: string; | ||
} | ||
export interface PlatformWithDownloadLink { | ||
arch: string; | ||
os: string; | ||
name: string; | ||
download_link: string; | ||
} | ||
export interface PlatformWithPackages { | ||
arch: string; | ||
os: string; | ||
packages: Package; | ||
} | ||
export interface Package { | ||
links: Link[]; | ||
} | ||
export interface Link { | ||
download_link: string; | ||
name: string; | ||
} | ||
//# sourceMappingURL=download-center-config.d.ts.map |
"use strict"; | ||
/* eslint-disable */ | ||
/* AUTO-GENERATED DO NOT EDIT. */ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//# sourceMappingURL=download-center-config.js.map |
@@ -19,7 +19,3 @@ { | ||
"type": "object", | ||
"required": [ | ||
"_id", | ||
"version", | ||
"platform" | ||
], | ||
"required": ["_id", "version", "platform"], | ||
"properties": { | ||
@@ -36,30 +32,7 @@ "_id": { | ||
"type": "array", | ||
"additionalItems": false, | ||
"items": { | ||
"type": "object", | ||
"required": [ | ||
"arch", | ||
"os", | ||
"name", | ||
"download_link" | ||
], | ||
"properties": { | ||
"arch": { | ||
"type": "string", | ||
"pattern": ".+" | ||
}, | ||
"os": { | ||
"type": "string", | ||
"pattern": ".+" | ||
}, | ||
"name": { | ||
"type": "string", | ||
"pattern": ".+" | ||
}, | ||
"download_link": { | ||
"type": "string", | ||
"pattern": ".+" | ||
} | ||
}, | ||
"additionalProperties": false | ||
"oneOf": [ | ||
{ "$ref": "#/definitions/PlatformWithDownloadLink" }, | ||
{ "$ref": "#/definitions/PlatformWithPackages" } | ||
] | ||
} | ||
@@ -90,3 +63,46 @@ } | ||
}, | ||
"additionalProperties": false | ||
"additionalProperties": false, | ||
"definitions": { | ||
"PlatformWithDownloadLink": { | ||
"type": "object", | ||
"properties": { | ||
"arch": { "type": "string" }, | ||
"os": { "type": "string" }, | ||
"name": { "type": "string" }, | ||
"download_link": { "type": "string" } | ||
}, | ||
"required": ["arch", "os", "name", "download_link"], | ||
"additionalProperties": false | ||
}, | ||
"PlatformWithPackages": { | ||
"type": "object", | ||
"properties": { | ||
"arch": { "type": "string" }, | ||
"os": { "type": "string" }, | ||
"packages": { "$ref": "#/definitions/Package" } | ||
}, | ||
"required": ["arch", "os", "packages"], | ||
"additionalProperties": false | ||
}, | ||
"Package": { | ||
"type": "object", | ||
"properties": { | ||
"links": { | ||
"type": "array", | ||
"items": { "$ref": "#/definitions/Link" } | ||
} | ||
}, | ||
"required": ["links"], | ||
"additionalProperties": false | ||
}, | ||
"Link": { | ||
"type": "object", | ||
"properties": { | ||
"download_link": { "type": "string" }, | ||
"name": { "type": "string" } | ||
}, | ||
"required": ["name", "download_link"], | ||
"additionalProperties": false | ||
} | ||
} | ||
} |
@@ -1,89 +0,23 @@ | ||
import { Body as Content } from 'aws-sdk/clients/s3'; | ||
import { DownloadCenterConfig } from './download-center-config'; | ||
export declare type S3BucketConfig = { | ||
/** | ||
* The bucket name. | ||
*/ | ||
import type { Body as Content } from 'aws-sdk/clients/s3'; | ||
import type { DownloadCenterConfig } from './download-center-config'; | ||
export type S3BucketConfig = { | ||
bucket: string; | ||
/** | ||
* The AWS access key id. | ||
*/ | ||
accessKeyId: string; | ||
/** | ||
* The AWS secret access key. | ||
*/ | ||
secretAccessKey: string; | ||
/** | ||
* S3 service endpoint. Set this to connect to a local test server. | ||
*/ | ||
endpoint?: string; | ||
/** | ||
* Whether to force path style URLs for S3 objects.. | ||
* | ||
* The default is false. Set this to `true` | ||
* to connect to a local test server using an arbitrary endpoint. | ||
*/ | ||
s3ForcePathStyle?: boolean; | ||
/** | ||
* Whether or not TLS should be enabled. | ||
* | ||
* The default is `true`. Set this to `false` | ||
* to connect to a local test server. | ||
*/ | ||
sslEnabled?: boolean; | ||
}; | ||
export declare type UploadAssetOptions = { | ||
export type UploadAssetOptions = { | ||
contentType?: string; | ||
}; | ||
declare type DownloadCenterConfigPlatform = { | ||
[key: string]: any; | ||
download_link: string; | ||
}; | ||
declare type ProbeResponse = { | ||
type ProbeResponse = { | ||
ok: boolean; | ||
status: number; | ||
}; | ||
/** | ||
* Vaidates a download center configuration object against a json schema. | ||
* Throws an error if the configuration is invalid. | ||
* | ||
* @static | ||
* @param {DownloadCenterConfig} config - | ||
* the download center product configuration document. | ||
* @memberof DownloadCenter | ||
*/ | ||
export declare function probePlatformDownloadLink({ download_link, }: { | ||
download_link: string; | ||
}): Promise<ProbeResponse>; | ||
export declare function validateConfigSchema(config: DownloadCenterConfig): void; | ||
/** | ||
* Validates all the asset links referenced in a configuration object. | ||
* Makes an HEAD http call for each asset link and throws an error in case | ||
* an asset is not reacheable. | ||
* | ||
* @static | ||
* @param {DownloadCenterConfig} config - | ||
* the download center product configuration document. | ||
* @return {Promise<void>} | ||
* @memberof DownloadCenter | ||
*/ | ||
export declare function validateDownloadLinks(config: DownloadCenterConfig): Promise<void>; | ||
/** | ||
* Probes the download_link for a configuration platform. | ||
* Returns the response of the probe. | ||
* | ||
* @static | ||
* @param {DownloadCenterConfigPlatform} platform | ||
* @return {Promise<ProbeResponse>} | ||
* @memberof DownloadCenter | ||
*/ | ||
export declare function probePlatformDownloadLink(platform: DownloadCenterConfigPlatform): Promise<ProbeResponse>; | ||
/** | ||
* Validates a download center config object. | ||
* Throws an error if the object has an incorrect format or if any of the | ||
* assets link is not reachable. | ||
* | ||
* @static | ||
* @param {DownloadCenterConfig} config - | ||
* the download center product configuration document. | ||
* @return {Promise<void>} | ||
* @memberof DownloadCenter | ||
*/ | ||
export declare function validateConfig(config: DownloadCenterConfig): Promise<void>; | ||
@@ -95,58 +29,8 @@ export declare class DownloadCenter { | ||
constructor(bucketConfig: S3BucketConfig); | ||
/** | ||
* Downloads an asset from the download center. This is equivalent to a | ||
* get object from the download center s3 bucket. | ||
* | ||
* @param {string} s3ObjectKey - | ||
* the s3 object key of the asset that has to be downloaded, | ||
* ie. `my-project/asset.zip`. | ||
* @return {(Promise<Content | undefined>)} | ||
* @memberof DownloadCenter | ||
*/ | ||
downloadAsset(s3ObjectKey: string): Promise<Content | undefined>; | ||
/** | ||
* Uploads an asset to the download center. This is equivalent to an | ||
* upload to the download center s3 bucket. | ||
* | ||
* @param {string} s3ObjectKey - | ||
* the s3 object key of the asset that has to be uploaded, | ||
* ie. `my-project/asset.zip`. | ||
* @param {Content} content - | ||
* a string, Buffer, Uint8Array, Blob or Readable containing the data of | ||
* the asset to be uploaded. | ||
* @param {UploadAssetOptions} [options={}] - | ||
* metadata for the upload. | ||
* @param {string} [options.contentType=undefined] - | ||
* an optional content type of the asset. If not specified | ||
* will be detected by s3. | ||
* @return {Promise<void>} | ||
* @memberof DownloadCenter | ||
*/ | ||
uploadAsset(s3ObjectKey: string, content: Content, options?: UploadAssetOptions): Promise<void>; | ||
/** | ||
* Downloads a product configuration from the download center bucket. | ||
* | ||
* @param {string} s3ObjectKey - | ||
* the s3 object key of the configuration that has to be downloaded, | ||
* ie. `products/compass.json`. | ||
* @return {(Promise<DownloadCenterConfig | undefined>)} - | ||
* the download center product configuration document. | ||
* @memberof DownloadCenter | ||
*/ | ||
downloadConfig(s3ObjectKey: string): Promise<DownloadCenterConfig | undefined>; | ||
/** | ||
* Validates and uploads a product configuration document | ||
* to the download center s3 bucket. | ||
* | ||
* @param {string} s3ObjectKey - | ||
* the s3 object key of the configuration that has to be uploaded, | ||
* ie. `products/compass.json`. | ||
* @param {DownloadCenterConfig} config - | ||
* the download center product configuration document. | ||
* | ||
* @return {Promise<void>} | ||
* @memberof DownloadCenter | ||
*/ | ||
uploadConfig(s3ObjectKey: string, config: DownloadCenterConfig): Promise<void>; | ||
} | ||
export {}; | ||
//# sourceMappingURL=download-center.d.ts.map |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -42,127 +6,63 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DownloadCenter = exports.validateConfig = exports.probePlatformDownloadLink = exports.validateDownloadLinks = exports.validateConfigSchema = void 0; | ||
var util_1 = __importDefault(require("util")); | ||
var node_fetch_1 = __importDefault(require("node-fetch")); | ||
var ajv_1 = __importDefault(require("ajv")); | ||
var s3_1 = __importDefault(require("aws-sdk/clients/s3")); | ||
var download_center_config_schema_json_1 = __importDefault(require("./download-center-config.schema.json")); | ||
var CONFIG_JSON_SCHEMA = Object.freeze(download_center_config_schema_json_1.default); | ||
var ACL_PUBLIC_READ = 'public-read'; | ||
/** | ||
* Vaidates a download center configuration object against a json schema. | ||
* Throws an error if the configuration is invalid. | ||
* | ||
* @static | ||
* @param {DownloadCenterConfig} config - | ||
* the download center product configuration document. | ||
* @memberof DownloadCenter | ||
*/ | ||
exports.DownloadCenter = exports.validateConfig = exports.validateDownloadLinks = exports.validateConfigSchema = exports.probePlatformDownloadLink = void 0; | ||
const util_1 = __importDefault(require("util")); | ||
const node_fetch_1 = __importDefault(require("node-fetch")); | ||
const ajv_1 = __importDefault(require("ajv")); | ||
const s3_1 = __importDefault(require("aws-sdk/clients/s3")); | ||
const download_center_config_schema_json_1 = __importDefault(require("./download-center-config.schema.json")); | ||
const CONFIG_JSON_SCHEMA = Object.freeze(download_center_config_schema_json_1.default); | ||
const ACL_PUBLIC_READ = 'public-read'; | ||
async function probePlatformDownloadLink({ download_link, }) { | ||
return await (0, node_fetch_1.default)(download_link, { method: 'HEAD' }); | ||
} | ||
exports.probePlatformDownloadLink = probePlatformDownloadLink; | ||
function validateConfigSchema(config) { | ||
var ajv = new ajv_1.default(); | ||
var validate = ajv.compile(CONFIG_JSON_SCHEMA); | ||
var valid = validate(config); | ||
const ajv = new ajv_1.default(); | ||
const validate = ajv.compile(CONFIG_JSON_SCHEMA); | ||
const valid = validate(config); | ||
if (!valid) { | ||
throw new Error("Invalid configuration: " + ajv.errorsText(validate.errors)); | ||
throw new Error(`Invalid configuration: ${ajv.errorsText(validate.errors)}`); | ||
} | ||
} | ||
exports.validateConfigSchema = validateConfigSchema; | ||
/** | ||
* Validates all the asset links referenced in a configuration object. | ||
* Makes an HEAD http call for each asset link and throws an error in case | ||
* an asset is not reacheable. | ||
* | ||
* @static | ||
* @param {DownloadCenterConfig} config - | ||
* the download center product configuration document. | ||
* @return {Promise<void>} | ||
* @memberof DownloadCenter | ||
*/ | ||
function validateDownloadLinks(config) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var errors, platforms, _i, _a, version, _b, _c, platform, probes, errorMsg; | ||
return __generator(this, function (_d) { | ||
switch (_d.label) { | ||
case 0: | ||
errors = {}; | ||
platforms = []; | ||
for (_i = 0, _a = config.versions; _i < _a.length; _i++) { | ||
version = _a[_i]; | ||
for (_b = 0, _c = version.platform; _b < _c.length; _b++) { | ||
platform = _c[_b]; | ||
platforms.push(platform); | ||
} | ||
} | ||
probes = platforms.map(function (platform) { | ||
return probePlatformDownloadLink(platform) | ||
.then(function (probe) { | ||
if (!probe.ok) { | ||
errors[platform.download_link] = probe.status; | ||
} | ||
}); | ||
}); | ||
return [4 /*yield*/, Promise.all(probes)]; | ||
case 1: | ||
_d.sent(); | ||
if (Object.keys(errors).length) { | ||
errorMsg = Object.entries(errors).map(function (_a) { | ||
var url = _a[0], status = _a[1]; | ||
return "- " + url + " -> " + status; | ||
}).sort().join('\n'); | ||
throw new Error("Download center urls broken:\n" + errorMsg); | ||
} | ||
return [2 /*return*/]; | ||
async function validateDownloadLinks(config) { | ||
const errors = {}; | ||
const links = []; | ||
for (const version of config.versions) { | ||
for (const platform of version.platform) { | ||
if ('download_link' in platform) { | ||
const singlePlatform = platform; | ||
links.push(singlePlatform); | ||
} | ||
else { | ||
const platformWithPackages = platform; | ||
links.push(...platformWithPackages.packages.links); | ||
} | ||
} | ||
} | ||
const probes = links.map((link) => { | ||
return probePlatformDownloadLink(link).then((probe) => { | ||
if (!probe.ok) { | ||
errors[link.download_link] = probe.status; | ||
} | ||
}); | ||
}); | ||
await Promise.all(probes); | ||
if (Object.keys(errors).length) { | ||
const errorMsg = Object.entries(errors) | ||
.map(([url, status]) => `- ${url} -> ${status}`) | ||
.sort() | ||
.join('\n'); | ||
throw new Error(`Download center urls broken:\n${errorMsg}`); | ||
} | ||
} | ||
exports.validateDownloadLinks = validateDownloadLinks; | ||
/** | ||
* Probes the download_link for a configuration platform. | ||
* Returns the response of the probe. | ||
* | ||
* @static | ||
* @param {DownloadCenterConfigPlatform} platform | ||
* @return {Promise<ProbeResponse>} | ||
* @memberof DownloadCenter | ||
*/ | ||
function probePlatformDownloadLink(platform) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, node_fetch_1.default(platform.download_link, { method: 'HEAD' })]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); | ||
async function validateConfig(config) { | ||
validateConfigSchema(config); | ||
await validateDownloadLinks(config); | ||
} | ||
exports.probePlatformDownloadLink = probePlatformDownloadLink; | ||
/** | ||
* Validates a download center config object. | ||
* Throws an error if the object has an incorrect format or if any of the | ||
* assets link is not reachable. | ||
* | ||
* @static | ||
* @param {DownloadCenterConfig} config - | ||
* the download center product configuration document. | ||
* @return {Promise<void>} | ||
* @memberof DownloadCenter | ||
*/ | ||
function validateConfig(config) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
validateConfigSchema(config); | ||
return [4 /*yield*/, validateDownloadLinks(config)]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
} | ||
exports.validateConfig = validateConfig; | ||
var DownloadCenter = /** @class */ (function () { | ||
function DownloadCenter(bucketConfig) { | ||
var s3 = new s3_1.default(bucketConfig); | ||
class DownloadCenter { | ||
constructor(bucketConfig) { | ||
const s3 = new s3_1.default(bucketConfig); | ||
this.s3GetObject = util_1.default.promisify(s3.getObject.bind(s3)); | ||
@@ -172,136 +72,41 @@ this.s3Upload = util_1.default.promisify(s3.upload.bind(s3)); | ||
} | ||
/** | ||
* Downloads an asset from the download center. This is equivalent to a | ||
* get object from the download center s3 bucket. | ||
* | ||
* @param {string} s3ObjectKey - | ||
* the s3 object key of the asset that has to be downloaded, | ||
* ie. `my-project/asset.zip`. | ||
* @return {(Promise<Content | undefined>)} | ||
* @memberof DownloadCenter | ||
*/ | ||
DownloadCenter.prototype.downloadAsset = function (s3ObjectKey) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var object; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
if (!s3ObjectKey) { | ||
throw new Error('s3ObjectKey is required'); | ||
} | ||
return [4 /*yield*/, this.s3GetObject({ | ||
Key: s3ObjectKey, | ||
Bucket: this.s3BucketName | ||
})]; | ||
case 1: | ||
object = _a.sent(); | ||
return [2 /*return*/, object.Body]; | ||
} | ||
}); | ||
async downloadAsset(s3ObjectKey) { | ||
if (!s3ObjectKey) { | ||
throw new Error('s3ObjectKey is required'); | ||
} | ||
const object = await this.s3GetObject({ | ||
Key: s3ObjectKey, | ||
Bucket: this.s3BucketName, | ||
}); | ||
}; | ||
/** | ||
* Uploads an asset to the download center. This is equivalent to an | ||
* upload to the download center s3 bucket. | ||
* | ||
* @param {string} s3ObjectKey - | ||
* the s3 object key of the asset that has to be uploaded, | ||
* ie. `my-project/asset.zip`. | ||
* @param {Content} content - | ||
* a string, Buffer, Uint8Array, Blob or Readable containing the data of | ||
* the asset to be uploaded. | ||
* @param {UploadAssetOptions} [options={}] - | ||
* metadata for the upload. | ||
* @param {string} [options.contentType=undefined] - | ||
* an optional content type of the asset. If not specified | ||
* will be detected by s3. | ||
* @return {Promise<void>} | ||
* @memberof DownloadCenter | ||
*/ | ||
DownloadCenter.prototype.uploadAsset = function (s3ObjectKey, content, options) { | ||
if (options === void 0) { options = {}; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var uploadParams; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
if (!s3ObjectKey) { | ||
throw new Error('s3ObjectKey is required'); | ||
} | ||
uploadParams = { | ||
ACL: ACL_PUBLIC_READ, | ||
Bucket: this.s3BucketName, | ||
Key: s3ObjectKey, | ||
Body: content, | ||
ContentType: options.contentType | ||
}; | ||
return [4 /*yield*/, this.s3Upload(uploadParams)]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
/** | ||
* Downloads a product configuration from the download center bucket. | ||
* | ||
* @param {string} s3ObjectKey - | ||
* the s3 object key of the configuration that has to be downloaded, | ||
* ie. `products/compass.json`. | ||
* @return {(Promise<DownloadCenterConfig | undefined>)} - | ||
* the download center product configuration document. | ||
* @memberof DownloadCenter | ||
*/ | ||
DownloadCenter.prototype.downloadConfig = function (s3ObjectKey) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var body; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.downloadAsset(s3ObjectKey)]; | ||
case 1: | ||
body = _a.sent(); | ||
if (!body) { | ||
return [2 /*return*/]; | ||
} | ||
return [2 /*return*/, JSON.parse(body.toString())]; | ||
} | ||
}); | ||
}); | ||
}; | ||
/** | ||
* Validates and uploads a product configuration document | ||
* to the download center s3 bucket. | ||
* | ||
* @param {string} s3ObjectKey - | ||
* the s3 object key of the configuration that has to be uploaded, | ||
* ie. `products/compass.json`. | ||
* @param {DownloadCenterConfig} config - | ||
* the download center product configuration document. | ||
* | ||
* @return {Promise<void>} | ||
* @memberof DownloadCenter | ||
*/ | ||
DownloadCenter.prototype.uploadConfig = function (s3ObjectKey, config) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
if (!s3ObjectKey) { | ||
throw new Error('s3ObjectKey is required'); | ||
} | ||
return [4 /*yield*/, validateConfig(config)]; | ||
case 1: | ||
_a.sent(); | ||
return [4 /*yield*/, this.uploadAsset(s3ObjectKey, JSON.stringify(config))]; | ||
case 2: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
return DownloadCenter; | ||
}()); | ||
return object.Body; | ||
} | ||
async uploadAsset(s3ObjectKey, content, options = {}) { | ||
if (!s3ObjectKey) { | ||
throw new Error('s3ObjectKey is required'); | ||
} | ||
const uploadParams = { | ||
ACL: ACL_PUBLIC_READ, | ||
Bucket: this.s3BucketName, | ||
Key: s3ObjectKey, | ||
Body: content, | ||
ContentType: options.contentType, | ||
}; | ||
await this.s3Upload(uploadParams); | ||
} | ||
async downloadConfig(s3ObjectKey) { | ||
const body = await this.downloadAsset(s3ObjectKey); | ||
if (!body) { | ||
return; | ||
} | ||
return JSON.parse(body.toString()); | ||
} | ||
async uploadConfig(s3ObjectKey, config) { | ||
if (!s3ObjectKey) { | ||
throw new Error('s3ObjectKey is required'); | ||
} | ||
await validateConfig(config); | ||
await this.uploadAsset(s3ObjectKey, JSON.stringify(config)); | ||
} | ||
} | ||
exports.DownloadCenter = DownloadCenter; | ||
//# sourceMappingURL=download-center.js.map |
export * from './download-center'; | ||
//# sourceMappingURL=index.d.ts.map |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k; |
105
package.json
{ | ||
"name": "@mongodb-js/dl-center", | ||
"version": "1.0.1", | ||
"description": "mongodb download center internal tools", | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"scripts": { | ||
"generate-config-from-schema": "json2ts -i src/download-center-config.schema.json -o src/download-center-config.ts --bannerComment '/* eslint-disable */\n/* AUTO-GENERATED DO NOT EDIT. */'", | ||
"pretest": "npm run generate-config-from-schema", | ||
"test": "mocha --timeout 60000 --colors -r ts-node/register \"./src/*.spec.ts\"", | ||
"lint": "eslint .", | ||
"prebuild": "npm run generate-config-from-schema", | ||
"build": "rm -Rf dist && tsc -p tsconfig.json", | ||
"prepublishOnly": "npm run lint && npm run build && npm run test" | ||
"author": { | ||
"name": "MongoDB Inc", | ||
"email": "compass@mongodb.com" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"homepage": "https://github.com/mongodb-js/dl-center", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"bugs": { | ||
"url": "https://jira.mongodb.org/projects/COMPASS/issues", | ||
"email": "compass@mongodb.com" | ||
}, | ||
"homepage": "https://github.com/mongodb-js/devtools-shared", | ||
"version": "1.1.1", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/mongodb-js/dl-center.git" | ||
"url": "https://github.com/mongodb-js/devtools-shared.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/mongodb-js/dl-center/issues" | ||
}, | ||
"files": [ | ||
"dist" | ||
], | ||
"license": "Apache-2.0", | ||
"engines": { | ||
"node": ">= 12" | ||
"main": "dist/index.js", | ||
"exports": { | ||
"require": "./dist/index.js", | ||
"import": "./dist/.esm-wrapper.mjs" | ||
}, | ||
"types": "./dist/index.d.ts", | ||
"scripts": { | ||
"generate-config-from-schema": "json2ts -i src/download-center-config.schema.json -o src/download-center-config.ts --bannerComment \"/* AUTO-GENERATED DO NOT EDIT. */\"", | ||
"pretest": "npm run generate-config-from-schema && npm run reformat", | ||
"bootstrap": "npm run compile", | ||
"prepublishOnly": "npm run compile", | ||
"compile": "tsc -p tsconfig.json && gen-esm-wrapper . ./dist/.esm-wrapper.mjs", | ||
"typecheck": "tsc --noEmit", | ||
"eslint": "eslint", | ||
"prettier": "prettier", | ||
"lint": "npm run eslint . && npm run prettier -- --check .", | ||
"depcheck": "depcheck", | ||
"check": "npm run typecheck && npm run lint && npm run depcheck", | ||
"check-ci": "npm run check", | ||
"test": "mocha", | ||
"test-cov": "nyc -x \"**/*.spec.*\" --reporter=lcov --reporter=text --reporter=html npm run test", | ||
"test-watch": "npm run test -- --watch", | ||
"test-ci": "npm run test-cov", | ||
"reformat": "npm run prettier -- --write ." | ||
}, | ||
"devDependencies": { | ||
"@types/command-exists": "^1.2.0", | ||
"@types/fs-extra": "^9.0.2", | ||
"@types/mocha": "^8.0.3", | ||
"@types/node-fetch": "^2.5.7", | ||
"@typescript-eslint/eslint-plugin": "^4.4.0", | ||
"@typescript-eslint/parser": "^4.4.0", | ||
"eslint": "^7.10.0", | ||
"eslint-config-mongodb-js": "^5.0.3", | ||
"eslint-plugin-mocha": "^8.0.0", | ||
"execa": "^4.1.0", | ||
"expect": "^26.6.1", | ||
"fs-extra": "^9.0.1", | ||
"json-schema-to-typescript": "^9.1.1", | ||
"mocha": "^8.2.0", | ||
"nock": "^13.0.4", | ||
"ts-node": "^9.0.0", | ||
"typescript": "^4.0.3" | ||
"@mongodb-js/eslint-config-devtools": "0.9.10", | ||
"@mongodb-js/mocha-config-devtools": "^1.0.1", | ||
"@mongodb-js/prettier-config-devtools": "^1.0.1", | ||
"@mongodb-js/tsconfig-devtools": "^1.0.1", | ||
"@types/chai": "^4.2.21", | ||
"@types/mocha": "^9.0.0", | ||
"@types/node": "^17.0.35", | ||
"@types/s3rver": "^3.7.0", | ||
"@types/sinon-chai": "^3.2.5", | ||
"chai": "^4.3.6", | ||
"depcheck": "^1.4.1", | ||
"eslint": "^7.25.0", | ||
"gen-esm-wrapper": "^1.1.0", | ||
"json-schema-to-typescript": "^13.0.2", | ||
"mocha": "^8.4.0", | ||
"nock": "^13.3.1", | ||
"nyc": "^15.1.0", | ||
"prettier": "^2.3.2", | ||
"s3rver": "^3.7.1", | ||
"sinon": "^9.2.3", | ||
"typescript": "^5.0.4" | ||
}, | ||
"dependencies": { | ||
"ajv": "^6.12.5", | ||
"aws-sdk": "^2.770.0", | ||
"node-fetch": "^2.6.1" | ||
} | ||
"aws-sdk": "^2.1441.0", | ||
"node-fetch": "^2.6.7" | ||
}, | ||
"gitHead": "aa8bbdcb7805a680355f0a121d13d21d5a39ac4c" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
0
0
29679
21
16
306
1
0
Updatedaws-sdk@^2.1441.0
Updatednode-fetch@^2.6.7