Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@kentico/kontent-backup-manager

Package Overview
Dependencies
Maintainers
8
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kentico/kontent-backup-manager - npm Package Compare versions

Comparing version 1.10.0 to 1.12.0

10

_commonjs/package.json
{
"name": "@kentico/kontent-backup-manager",
"version": "1.10.0",
"version": "1.12.0",
"description": "This utility enables backup & restore of Kentico Kontent projects",

@@ -44,6 +44,6 @@ "preferGlobal": true,

"dependencies": {
"@kentico/kontent-management": "0.4.1",
"@kentico/kontent-management": "0.4.2",
"jszip": "3.5.0",
"rxjs": "6.6.3",
"yargs": "16.0.3",
"yargs": "16.1.0",
"flatted": "3.1.0"

@@ -53,4 +53,4 @@ },

"@types/jszip": "3.4.1",
"@types/node": "14.11.5",
"@types/yargs": "15.0.7",
"@types/node": "14.14.0",
"@types/yargs": "15.0.9",
"standard-version": "9.0.0",

@@ -57,0 +57,0 @@ "ts-node": "9.0.0",

@@ -290,3 +290,5 @@ "use strict";

responseFetched: function (listResponse, token) {
listResponse.data.items.forEach(function (m) { return _this.processItem(m.name, 'contentType', m); });
if (data.processItem) {
listResponse.data.items.forEach(function (m) { return _this.processItem(m.name, 'contentType', m); });
}
}

@@ -293,0 +295,0 @@ })

@@ -5,2 +5,3 @@ export declare type ZipContext = 'node.js' | 'browser';

context: ZipContext;
delayBetweenAssetDownloadRequestsMs?: number;
}

@@ -6,2 +6,3 @@ import { IExportAllResult } from '../export';

private config;
private readonly delayBetweenAssetRequestsMs;
private readonly contentTypesName;

@@ -21,2 +22,3 @@ private readonly contentItemsName;

createZipAsync(exportData: IExportAllResult): Promise<any>;
private sleepAsync;
private extractBinaryFilesAsync;

@@ -30,3 +32,3 @@ private getZipOutputType;

private readAndParseJsonFile;
private getBinaryDataFromUrl;
private getBinaryDataFromUrlAsync;
}

@@ -44,2 +44,3 @@ "use strict";

function ZipService(config) {
var _a;
this.config = config;

@@ -57,2 +58,3 @@ this.contentTypesName = 'contentTypes.json';

this.validationName = 'validation.json';
this.delayBetweenAssetRequestsMs = (_a = config === null || config === void 0 ? void 0 : config.delayBetweenAssetDownloadRequestsMs) !== null && _a !== void 0 ? _a : 150;
}

@@ -124,5 +126,5 @@ ZipService.prototype.extractZipAsync = function (zipFile) {

return __awaiter(this, void 0, void 0, function () {
var zip, assetsFolder, _i, _a, asset, assetIdShortFolderName, assetIdShortFolder, assetIdFolderName, assetIdFolder, assetFilename, content;
return __generator(this, function (_b) {
switch (_b.label) {
var zip, assetsFolder, _i, _a, asset, assetIdShortFolderName, assetIdShortFolder, assetIdFolderName, assetIdFolder, assetFilename, _b, _c, _d, content;
return __generator(this, function (_e) {
switch (_e.label) {
case 0:

@@ -150,19 +152,35 @@ zip = new JSZip();

}
for (_i = 0, _a = exportData.data.assets; _i < _a.length; _i++) {
asset = _a[_i];
assetIdShortFolderName = asset.id.substr(0, 3);
assetIdShortFolder = assetsFolder.folder(assetIdShortFolderName);
if (!assetIdShortFolder) {
throw Error("Could not create folder '" + this.filesName + "'");
}
assetIdFolderName = asset.id;
assetIdFolder = assetIdShortFolder.folder(assetIdFolderName);
if (!assetIdFolder) {
throw Error("Could not create folder '" + this.filesName + "'");
}
assetFilename = asset.file_name;
assetIdFolder.file(assetFilename, this.getBinaryDataFromUrl(asset.url, this.config.enableLog), {
_i = 0, _a = exportData.data.assets;
_e.label = 1;
case 1:
if (!(_i < _a.length)) return [3 /*break*/, 5];
asset = _a[_i];
assetIdShortFolderName = asset.id.substr(0, 3);
assetIdShortFolder = assetsFolder.folder(assetIdShortFolderName);
if (!assetIdShortFolder) {
throw Error("Could not create folder '" + this.filesName + "'");
}
assetIdFolderName = asset.id;
assetIdFolder = assetIdShortFolder.folder(assetIdFolderName);
if (!assetIdFolder) {
throw Error("Could not create folder '" + this.filesName + "'");
}
assetFilename = asset.file_name;
_c = (_b = assetIdFolder).file;
_d = [assetFilename];
return [4 /*yield*/, this.getBinaryDataFromUrlAsync(asset.url, this.config.enableLog)];
case 2:
_c.apply(_b, _d.concat([_e.sent(), {
binary: true
});
}
}]));
// create artificial delay between requests as to prevent errors on network
return [4 /*yield*/, this.sleepAsync(this.delayBetweenAssetRequestsMs)];
case 3:
// create artificial delay between requests as to prevent errors on network
_e.sent();
_e.label = 4;
case 4:
_i++;
return [3 /*break*/, 1];
case 5:
if (this.config.enableLog) {

@@ -172,4 +190,4 @@ console.log("Creating zip file");

return [4 /*yield*/, zip.generateAsync({ type: this.getZipOutputType() })];
case 1:
content = _b.sent();
case 6:
content = _e.sent();
if (this.config.enableLog) {

@@ -183,2 +201,5 @@ console.log("Zip file prepared");

};
ZipService.prototype.sleepAsync = function (ms) {
return new Promise(function (resolve) { return setTimeout(resolve, ms); });
};
ZipService.prototype.extractBinaryFilesAsync = function (zip, assets) {

@@ -249,7 +270,7 @@ return __awaiter(this, void 0, void 0, function () {

};
ZipService.prototype.getBinaryDataFromUrl = function (url, enableLog) {
ZipService.prototype.getBinaryDataFromUrlAsync = function (url, enableLog) {
// temp fix for Kontent Repository not validating url
url = url.replace('#', '%23');
if (enableLog) {
console.log("Downloading asset: " + url);
console.log("Start asset download: " + url);
}

@@ -260,3 +281,3 @@ return axios_1.default.get(url, {

if (enableLog) {
console.log("Downloading asset completed: " + url);
console.log("Completed asset download: " + url);
}

@@ -263,0 +284,0 @@ return response.data;

@@ -5,2 +5,21 @@ # Changelog

## [1.12.0](https://github.com/Kentico/kontent-backup-manager-js/compare/v1.11.0...v1.12.0) (2020-10-21)
### Features
* adds ability to set artificial delay between asset download requests & wait until asset is downloaded before proceeding to next ([3855127](https://github.com/Kentico/kontent-backup-manager-js/commit/3855127d563ef5452529beb634126aed08d18e9f))
### Bug Fixes
* skips processing of content types when not necessary ([2df86f2](https://github.com/Kentico/kontent-backup-manager-js/commit/2df86f2ba6bc2e63cb85408e70bcdccde0254df6))
## [1.11.0](https://github.com/Kentico/kontent-backup-manager-js/compare/v1.10.0...v1.11.0) (2020-10-21)
### Features
* updates dependencies ([62597c6](https://github.com/Kentico/kontent-backup-manager-js/commit/62597c630cd7d66767e74f5ab0568b4dc77033e2))
## [1.10.0](https://github.com/Kentico/kontent-backup-manager-js/compare/v1.9.0...v1.10.0) (2020-10-07)

@@ -7,0 +26,0 @@

{
"name": "@kentico/kontent-backup-manager",
"version": "1.10.0",
"version": "1.12.0",
"description": "This utility enables backup & restore of Kentico Kontent projects",

@@ -44,6 +44,6 @@ "preferGlobal": true,

"dependencies": {
"@kentico/kontent-management": "0.4.1",
"@kentico/kontent-management": "0.4.2",
"jszip": "3.5.0",
"rxjs": "6.6.3",
"yargs": "16.0.3",
"yargs": "16.1.0",
"flatted": "3.1.0"

@@ -53,4 +53,4 @@ },

"@types/jszip": "3.4.1",
"@types/node": "14.11.5",
"@types/yargs": "15.0.7",
"@types/node": "14.14.0",
"@types/yargs": "15.0.9",
"standard-version": "9.0.0",

@@ -57,0 +57,0 @@ "ts-node": "9.0.0",

@@ -142,3 +142,5 @@ import {

responseFetched: (listResponse, token) => {
listResponse.data.items.forEach((m) => this.processItem(m.name, 'contentType', m));
if (data.processItem) {
listResponse.data.items.forEach((m) => this.processItem(m.name, 'contentType', m));
}
}

@@ -145,0 +147,0 @@ })

@@ -6,2 +6,3 @@ export type ZipContext = 'node.js' | 'browser';

context: ZipContext
delayBetweenAssetDownloadRequestsMs?: number
}

@@ -11,2 +11,4 @@ import { AssetContracts } from '@kentico/kontent-management';

private readonly delayBetweenAssetRequestsMs: number;
private readonly contentTypesName: string = 'contentTypes.json';

@@ -25,2 +27,3 @@ private readonly contentItemsName: string = 'contentItems.json';

constructor(private config: IZipServiceConfig) {
this.delayBetweenAssetRequestsMs = config?.delayBetweenAssetDownloadRequestsMs ?? 150;
}

@@ -106,5 +109,8 @@

const assetFilename = asset.file_name;
assetIdFolder.file(assetFilename, this.getBinaryDataFromUrl(asset.url, this.config.enableLog), {
assetIdFolder.file(assetFilename, await this.getBinaryDataFromUrlAsync(asset.url, this.config.enableLog), {
binary: true
});
// create artificial delay between requests as to prevent errors on network
await this.sleepAsync(this.delayBetweenAssetRequestsMs);
}

@@ -125,2 +131,6 @@

private sleepAsync(ms: number): Promise<any> {
return new Promise((resolve: any) => setTimeout(resolve, ms));
}
private async extractBinaryFilesAsync(

@@ -180,3 +190,3 @@ zip: JSZip,

private getBinaryDataFromUrl(url: string, enableLog: boolean): Promise<any> {
private getBinaryDataFromUrlAsync(url: string, enableLog: boolean): Promise<any> {
// temp fix for Kontent Repository not validating url

@@ -186,3 +196,3 @@ url = url.replace('#', '%23');

if (enableLog) {
console.log(`Downloading asset: ${url}`);
console.log(`Start asset download: ${url}`);
}

@@ -194,3 +204,3 @@ return axios.get(url, {

if (enableLog) {
console.log(`Downloading asset completed: ${url}`);
console.log(`Completed asset download: ${url}`);
}

@@ -197,0 +207,0 @@ return response.data;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc