@kentico/kontent-backup-manager
Advanced tools
Comparing version 1.9.0 to 1.10.0
{ | ||
"name": "@kentico/kontent-backup-manager", | ||
"version": "1.9.0", | ||
"version": "1.10.0", | ||
"description": "This utility enables backup & restore of Kentico Kontent projects", | ||
@@ -44,17 +44,17 @@ "preferGlobal": true, | ||
"dependencies": { | ||
"@kentico/kontent-management": "0.3.19", | ||
"jszip": "3.4.0", | ||
"rxjs": "6.5.5", | ||
"yargs": "15.3.1", | ||
"flatted": "2.0.2" | ||
"@kentico/kontent-management": "0.4.1", | ||
"jszip": "3.5.0", | ||
"rxjs": "6.6.3", | ||
"yargs": "16.0.3", | ||
"flatted": "3.1.0" | ||
}, | ||
"devDependencies": { | ||
"@types/jszip": "3.4.1", | ||
"@types/node": "14.0.1", | ||
"@types/yargs": "15.0.5", | ||
"standard-version": "8.0.0", | ||
"ts-node": "8.10.1", | ||
"tslint": "6.1.2", | ||
"typescript": "3.9.2" | ||
"@types/node": "14.11.5", | ||
"@types/yargs": "15.0.7", | ||
"standard-version": "9.0.0", | ||
"ts-node": "9.0.0", | ||
"tslint": "6.1.3", | ||
"typescript": "4.0.3" | ||
} | ||
} |
@@ -10,4 +10,4 @@ "use strict"; | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); | ||
} | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -14,0 +14,0 @@ __exportStar(require("./clean.models"), exports); |
@@ -10,4 +10,4 @@ "use strict"; | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); | ||
} | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -14,0 +14,0 @@ __exportStar(require("./core.models"), exports); |
@@ -54,3 +54,4 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var exportItems, contentTypes, projectValidation, data, _u, _v, _w, _x, _y, _z, _0, _1; | ||
var exportItems, contentTypes, projectValidation, data, _u, _v, _w, _x, _y, _z, _0; | ||
var _1; | ||
return __generator(this, function (_2) { | ||
@@ -68,3 +69,3 @@ switch (_2.label) { | ||
languageVariant: (_r = (_q = this.config.exportFilter) === null || _q === void 0 ? void 0 : _q.includes('languageVariant')) !== null && _r !== void 0 ? _r : true, | ||
taxonomy: (_t = (_s = this.config.exportFilter) === null || _s === void 0 ? void 0 : _s.includes('taxonomy')) !== null && _t !== void 0 ? _t : true, | ||
taxonomy: (_t = (_s = this.config.exportFilter) === null || _s === void 0 ? void 0 : _s.includes('taxonomy')) !== null && _t !== void 0 ? _t : true | ||
}; | ||
@@ -77,3 +78,3 @@ return [4 /*yield*/, this.exportContentTypesAsync({ processItem: exportItems.contentType })]; | ||
projectValidation = _2.sent(); | ||
_u = { | ||
_1 = { | ||
contentTypes: exportItems.contentType ? contentTypes : [] | ||
@@ -84,70 +85,70 @@ }; | ||
case 3: | ||
_v = _2.sent(); | ||
_u = _2.sent(); | ||
return [3 /*break*/, 5]; | ||
case 4: | ||
_v = []; | ||
_u = []; | ||
_2.label = 5; | ||
case 5: | ||
_u.contentTypeSnippets = _v; | ||
_1.contentTypeSnippets = _u; | ||
if (!exportItems.taxonomy) return [3 /*break*/, 7]; | ||
return [4 /*yield*/, this.exportTaxonomiesAsync()]; | ||
case 6: | ||
_w = _2.sent(); | ||
_v = _2.sent(); | ||
return [3 /*break*/, 8]; | ||
case 7: | ||
_w = []; | ||
_v = []; | ||
_2.label = 8; | ||
case 8: | ||
_u.taxonomies = _w; | ||
_1.taxonomies = _v; | ||
if (!exportItems.contentItem) return [3 /*break*/, 10]; | ||
return [4 /*yield*/, this.exportContentItemsAsync()]; | ||
case 9: | ||
_x = _2.sent(); | ||
_w = _2.sent(); | ||
return [3 /*break*/, 11]; | ||
case 10: | ||
_x = []; | ||
_w = []; | ||
_2.label = 11; | ||
case 11: | ||
_u.contentItems = _x; | ||
_1.contentItems = _w; | ||
if (!exportItems.languageVariant) return [3 /*break*/, 13]; | ||
return [4 /*yield*/, this.exportLanguageVariantsAsync(contentTypes.map(function (m) { return m.id; }))]; | ||
case 12: | ||
_y = _2.sent(); | ||
_x = _2.sent(); | ||
return [3 /*break*/, 14]; | ||
case 13: | ||
_y = []; | ||
_x = []; | ||
_2.label = 14; | ||
case 14: | ||
_u.languageVariants = _y; | ||
_1.languageVariants = _x; | ||
if (!exportItems.asset) return [3 /*break*/, 16]; | ||
return [4 /*yield*/, this.exportAssetsAsync()]; | ||
case 15: | ||
_z = _2.sent(); | ||
_y = _2.sent(); | ||
return [3 /*break*/, 17]; | ||
case 16: | ||
_z = []; | ||
_y = []; | ||
_2.label = 17; | ||
case 17: | ||
_u.assets = _z; | ||
_1.assets = _y; | ||
if (!exportItems.language) return [3 /*break*/, 19]; | ||
return [4 /*yield*/, this.exportLanguagesAsync()]; | ||
case 18: | ||
_0 = _2.sent(); | ||
_z = _2.sent(); | ||
return [3 /*break*/, 20]; | ||
case 19: | ||
_0 = []; | ||
_z = []; | ||
_2.label = 20; | ||
case 20: | ||
_u.languages = _0; | ||
_1.languages = _z; | ||
if (!exportItems.assetFolder) return [3 /*break*/, 22]; | ||
return [4 /*yield*/, this.exportAssetFoldersAsync()]; | ||
case 21: | ||
_1 = _2.sent(); | ||
_0 = _2.sent(); | ||
return [3 /*break*/, 23]; | ||
case 22: | ||
_1 = []; | ||
_0 = []; | ||
_2.label = 23; | ||
case 23: | ||
data = (_u.assetFolders = _1, | ||
_u); | ||
data = (_1.assetFolders = _0, | ||
_1); | ||
return [2 /*return*/, { | ||
@@ -167,4 +168,4 @@ metadata: { | ||
languagesCount: data.languages.length, | ||
taxonomiesCount: data.taxonomies.length, | ||
}, | ||
taxonomiesCount: data.taxonomies.length | ||
} | ||
}, | ||
@@ -183,5 +184,3 @@ validation: projectValidation, | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.client.validateProjectContent() | ||
.forProjectId(this.config.projectId) | ||
.toPromise()]; | ||
case 0: return [4 /*yield*/, this.client.validateProjectContent().forProjectId(this.config.projectId).toPromise()]; | ||
case 1: | ||
@@ -200,6 +199,12 @@ response = _a.sent(); | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.client.listAssets().toAllPromise()]; | ||
case 0: return [4 /*yield*/, this.client | ||
.listAssets() | ||
.withListQueryConfig({ | ||
responseFetched: function (listResponse, token) { | ||
listResponse.data.items.forEach(function (m) { return _this.processItem(m.fileName, 'asset', m); }); | ||
} | ||
}) | ||
.toAllPromise()]; | ||
case 1: | ||
response = _a.sent(); | ||
response.data.items.forEach(function (m) { return _this.processItem(m.fileName, 'asset', m); }); | ||
return [2 /*return*/, response.data.items.map(function (m) { return m._raw; })]; | ||
@@ -231,6 +236,12 @@ } | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.client.listLanguages().toAllPromise()]; | ||
case 0: return [4 /*yield*/, this.client | ||
.listLanguages() | ||
.withListQueryConfig({ | ||
responseFetched: function (listResponse, token) { | ||
listResponse.data.items.forEach(function (m) { return _this.processItem(m.name, 'language', m); }); | ||
} | ||
}) | ||
.toAllPromise()]; | ||
case 1: | ||
response = _a.sent(); | ||
response.data.items.forEach(function (m) { return _this.processItem(m.name, 'language', m); }); | ||
return [2 /*return*/, response.data.items.map(function (m) { return m._raw; })]; | ||
@@ -262,6 +273,12 @@ } | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.client.listContentTypeSnippets().toAllPromise()]; | ||
case 0: return [4 /*yield*/, this.client | ||
.listContentTypeSnippets() | ||
.withListQueryConfig({ | ||
responseFetched: function (listResponse, token) { | ||
listResponse.data.items.forEach(function (m) { return _this.processItem(m.name, 'contentTypeSnippet', m); }); | ||
} | ||
}) | ||
.toAllPromise()]; | ||
case 1: | ||
response = _a.sent(); | ||
response.data.items.forEach(function (m) { return _this.processItem(m.name, 'contentTypeSnippet', m); }); | ||
return [2 /*return*/, response.data.items.map(function (m) { return m._raw; })]; | ||
@@ -278,8 +295,12 @@ } | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.client.listContentTypes().toAllPromise()]; | ||
case 0: return [4 /*yield*/, this.client | ||
.listContentTypes() | ||
.withListQueryConfig({ | ||
responseFetched: function (listResponse, token) { | ||
listResponse.data.items.forEach(function (m) { return _this.processItem(m.name, 'contentType', m); }); | ||
} | ||
}) | ||
.toAllPromise()]; | ||
case 1: | ||
response = _a.sent(); | ||
if (data.processItem) { | ||
response.data.items.forEach(function (m) { return _this.processItem(m.name, 'contentType', m); }); | ||
} | ||
return [2 /*return*/, response.data.items.map(function (m) { return m._raw; })]; | ||
@@ -296,6 +317,12 @@ } | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.client.listContentItems().toAllPromise()]; | ||
case 0: return [4 /*yield*/, this.client | ||
.listContentItems() | ||
.withListQueryConfig({ | ||
responseFetched: function (listResponse, token) { | ||
listResponse.data.items.forEach(function (m) { return _this.processItem(m.name, 'contentItem', m); }); | ||
} | ||
}) | ||
.toAllPromise()]; | ||
case 1: | ||
response = _a.sent(); | ||
response.data.items.forEach(function (m) { return _this.processItem(m.name, 'contentItem', m); }); | ||
return [2 /*return*/, response.data.items.map(function (m) { return m._raw; })]; | ||
@@ -308,36 +335,42 @@ } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var languageVariants, _i, typeIds_1, typeId, _a, _b, _c, _d, _e, _f; | ||
var languageVariants, _i, typeIds_1, typeId; | ||
var _this = this; | ||
return __generator(this, function (_g) { | ||
switch (_g.label) { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
languageVariants = []; | ||
_i = 0, typeIds_1 = typeIds; | ||
_g.label = 1; | ||
_a.label = 1; | ||
case 1: | ||
if (!(_i < typeIds_1.length)) return [3 /*break*/, 5]; | ||
typeId = typeIds_1[_i]; | ||
_b = (_a = languageVariants.push).apply; | ||
_c = [languageVariants]; | ||
return [4 /*yield*/, this.client | ||
.listLanguageVariantsOfContentTypeWithComponents() | ||
.byTypeId(typeId) | ||
.withListQueryConfig({ | ||
responseFetched: function (listResponse, token) { | ||
languageVariants.push.apply(languageVariants, listResponse.data.items.map(function (m) { return m._raw; })); | ||
listResponse.data.items.forEach(function (m) { var _a, _b; return _this.processItem((_b = (_a = m.item.id) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : '-', 'languageVariant', m); }); | ||
} | ||
}) | ||
.toAllPromise()]; | ||
case 2: | ||
_b.apply(_a, _c.concat([(_g.sent()).data.items.map(function (m) { return m._raw; })])); | ||
_e = (_d = languageVariants.push).apply; | ||
_f = [languageVariants]; | ||
_a.sent(); | ||
return [4 /*yield*/, this.client | ||
.listLanguageVariantsOfContentType() | ||
.byTypeId(typeId) | ||
.withListQueryConfig({ | ||
responseFetched: function (listResponse, token) { | ||
languageVariants.push.apply(languageVariants, listResponse.data.items.map(function (m) { return m._raw; })); | ||
listResponse.data.items.forEach(function (m) { var _a, _b; return _this.processItem((_b = (_a = m.item.id) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : '-', 'languageVariant', m); }); | ||
} | ||
}) | ||
.toAllPromise()]; | ||
case 3: | ||
_e.apply(_d, _f.concat([(_g.sent()).data.items.map(function (m) { return m._raw; })])); | ||
_g.label = 4; | ||
_a.sent(); | ||
_a.label = 4; | ||
case 4: | ||
_i++; | ||
return [3 /*break*/, 1]; | ||
case 5: | ||
languageVariants.forEach(function (m) { var _a, _b; return _this.processItem((_b = (_a = m.item.id) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : '-', 'languageVariant', m); }); | ||
return [2 /*return*/, languageVariants]; | ||
case 5: return [2 /*return*/, languageVariants]; | ||
} | ||
@@ -344,0 +377,0 @@ }); |
@@ -10,4 +10,4 @@ "use strict"; | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); | ||
} | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -14,0 +14,0 @@ __exportStar(require("./export.models"), exports); |
@@ -743,3 +743,3 @@ "use strict"; | ||
.byLanguageCodename(languageCodename) | ||
.withElements(languageVariant.elements) | ||
.withData(function (builder) { return languageVariant.elements; }) | ||
.toPromise() | ||
@@ -746,0 +746,0 @@ .then(function (response) { |
@@ -10,4 +10,4 @@ "use strict"; | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); | ||
} | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -14,0 +14,0 @@ __exportStar(require("./import.models"), exports); |
@@ -10,4 +10,4 @@ "use strict"; | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); | ||
} | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -14,0 +14,0 @@ // Public API |
@@ -10,4 +10,4 @@ "use strict"; | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); | ||
} | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -14,0 +14,0 @@ __exportStar(require("./file/file.service"), exports); |
@@ -10,4 +10,4 @@ "use strict"; | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); | ||
} | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -14,0 +14,0 @@ __exportStar(require("./zip.service"), exports); |
@@ -59,3 +59,4 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var unzippedFile, assets, result, _a, _b; | ||
var unzippedFile, assets, result; | ||
var _a, _b; | ||
return __generator(this, function (_c) { | ||
@@ -122,3 +123,3 @@ switch (_c.label) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var zip, assetsFolder, _i, _a, asset, assetIdShortFolder, assetIdFolder, assetFilename, content; | ||
var zip, assetsFolder, _i, _a, asset, assetIdShortFolderName, assetIdShortFolder, assetIdFolderName, assetIdFolder, assetFilename, content; | ||
return __generator(this, function (_b) { | ||
@@ -142,2 +143,5 @@ switch (_b.label) { | ||
assetsFolder = zip.folder(this.filesName); | ||
if (!assetsFolder) { | ||
throw Error("Could not create folder '" + this.filesName + "'"); | ||
} | ||
if (this.config.enableLog) { | ||
@@ -148,4 +152,12 @@ console.log("Adding assets to zip"); | ||
asset = _a[_i]; | ||
assetIdShortFolder = assetsFolder.folder(asset.id.substr(0, 3)); | ||
assetIdFolder = assetIdShortFolder.folder(asset.id); | ||
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; | ||
@@ -152,0 +164,0 @@ assetIdFolder.file(assetFilename, this.getBinaryDataFromUrl(asset.url, this.config.enableLog), { |
@@ -5,2 +5,9 @@ # Changelog | ||
## [1.10.0](https://github.com/Kentico/kontent-backup-manager-js/compare/v1.9.0...v1.10.0) (2020-10-07) | ||
### Features | ||
* processes items per page instead of waiting until all items are fetched from API + updates all dependencies ([f4a5b50](https://github.com/Kentico/kontent-backup-manager-js/commit/f4a5b50575a9f1505893f148a60cd2cb0f19d1a4)) | ||
## [1.9.0](https://github.com/Kentico/kontent-backup-manager-js/compare/v1.8.0...v1.9.0) (2020-09-22) | ||
@@ -7,0 +14,0 @@ |
{ | ||
"name": "@kentico/kontent-backup-manager", | ||
"version": "1.9.0", | ||
"version": "1.10.0", | ||
"description": "This utility enables backup & restore of Kentico Kontent projects", | ||
@@ -44,17 +44,17 @@ "preferGlobal": true, | ||
"dependencies": { | ||
"@kentico/kontent-management": "0.3.19", | ||
"jszip": "3.4.0", | ||
"rxjs": "6.5.5", | ||
"yargs": "15.3.1", | ||
"flatted": "2.0.2" | ||
"@kentico/kontent-management": "0.4.1", | ||
"jszip": "3.5.0", | ||
"rxjs": "6.6.3", | ||
"yargs": "16.0.3", | ||
"flatted": "3.1.0" | ||
}, | ||
"devDependencies": { | ||
"@types/jszip": "3.4.1", | ||
"@types/node": "14.0.1", | ||
"@types/yargs": "15.0.5", | ||
"standard-version": "8.0.0", | ||
"ts-node": "8.10.1", | ||
"tslint": "6.1.2", | ||
"typescript": "3.9.2" | ||
"@types/node": "14.11.5", | ||
"@types/yargs": "15.0.7", | ||
"standard-version": "9.0.0", | ||
"ts-node": "9.0.0", | ||
"tslint": "6.1.3", | ||
"typescript": "4.0.3" | ||
} | ||
} |
@@ -12,3 +12,3 @@ import { | ||
AssetFolderContracts, | ||
ProjectContracts, | ||
ProjectContracts | ||
} from '@kentico/kontent-management'; | ||
@@ -41,6 +41,6 @@ | ||
languageVariant: this.config.exportFilter?.includes('languageVariant') ?? true, | ||
taxonomy: this.config.exportFilter?.includes('taxonomy') ?? true, | ||
taxonomy: this.config.exportFilter?.includes('taxonomy') ?? true | ||
}; | ||
const contentTypes = await this.exportContentTypesAsync({processItem: exportItems.contentType}); | ||
const contentTypes = await this.exportContentTypesAsync({ processItem: exportItems.contentType }); | ||
const projectValidation = await this.exportProjectValidationAsync(); | ||
@@ -53,6 +53,8 @@ | ||
contentItems: exportItems.contentItem ? await this.exportContentItemsAsync() : [], | ||
languageVariants: exportItems.languageVariant ? await this.exportLanguageVariantsAsync(contentTypes.map(m => m.id)) : [], | ||
languageVariants: exportItems.languageVariant | ||
? await this.exportLanguageVariantsAsync(contentTypes.map((m) => m.id)) | ||
: [], | ||
assets: exportItems.asset ? await this.exportAssetsAsync() : [], | ||
languages: exportItems.language ? await this.exportLanguagesAsync() : [], | ||
assetFolders: exportItems.assetFolder ? await this.exportAssetFoldersAsync() : [], | ||
assetFolders: exportItems.assetFolder ? await this.exportAssetFoldersAsync() : [] | ||
}; | ||
@@ -65,3 +67,4 @@ | ||
projectId: this.config.projectId, | ||
isInconsistentExport: projectValidation.type_issues.length > 0 || projectValidation.variant_issues.length > 0, | ||
isInconsistentExport: | ||
projectValidation.type_issues.length > 0 || projectValidation.variant_issues.length > 0, | ||
dataOverview: { | ||
@@ -75,4 +78,4 @@ assetFoldersCount: data.assetFolders.length, | ||
languagesCount: data.languages.length, | ||
taxonomiesCount: data.taxonomies.length, | ||
}, | ||
taxonomiesCount: data.taxonomies.length | ||
} | ||
}, | ||
@@ -85,6 +88,3 @@ validation: projectValidation, | ||
public async exportProjectValidationAsync(): Promise<ProjectContracts.IProjectReportResponseContract> { | ||
const response = await this.client.validateProjectContent() | ||
.forProjectId(this.config.projectId) | ||
.toPromise(); | ||
const response = await this.client.validateProjectContent().forProjectId(this.config.projectId).toPromise(); | ||
return response.rawData; | ||
@@ -94,5 +94,11 @@ } | ||
public async exportAssetsAsync(): Promise<AssetContracts.IAssetModelContract[]> { | ||
const response = await this.client.listAssets().toAllPromise(); | ||
response.data.items.forEach(m => this.processItem(m.fileName, 'asset', m)); | ||
return response.data.items.map(m => m._raw); | ||
const response = await this.client | ||
.listAssets() | ||
.withListQueryConfig({ | ||
responseFetched: (listResponse, token) => { | ||
listResponse.data.items.forEach((m) => this.processItem(m.fileName, 'asset', m)); | ||
} | ||
}) | ||
.toAllPromise(); | ||
return response.data.items.map((m) => m._raw); | ||
} | ||
@@ -102,10 +108,16 @@ | ||
const response = await this.client.listAssetFolders().toPromise(); | ||
response.data.items.forEach(m => this.processItem(m.name, 'assetFolder', m)); | ||
return response.data.items.map(m => m._raw); | ||
response.data.items.forEach((m) => this.processItem(m.name, 'assetFolder', m)); | ||
return response.data.items.map((m) => m._raw); | ||
} | ||
public async exportLanguagesAsync(): Promise<LanguageContracts.ILanguageModelContract[]> { | ||
const response = await this.client.listLanguages().toAllPromise(); | ||
response.data.items.forEach(m => this.processItem(m.name, 'language', m)); | ||
return response.data.items.map(m => m._raw); | ||
const response = await this.client | ||
.listLanguages() | ||
.withListQueryConfig({ | ||
responseFetched: (listResponse, token) => { | ||
listResponse.data.items.forEach((m) => this.processItem(m.name, 'language', m)); | ||
} | ||
}) | ||
.toAllPromise(); | ||
return response.data.items.map((m) => m._raw); | ||
} | ||
@@ -115,24 +127,42 @@ | ||
const response = await this.client.listTaxonomies().toPromise(); | ||
response.data.taxonomies.forEach(m => this.processItem(m.name, 'taxonomy', m)); | ||
return response.data.taxonomies.map(m => m._raw); | ||
response.data.taxonomies.forEach((m) => this.processItem(m.name, 'taxonomy', m)); | ||
return response.data.taxonomies.map((m) => m._raw); | ||
} | ||
public async exportContentTypeSnippetsAsync(): Promise<ContentTypeSnippetContracts.IContentTypeSnippetContract[]> { | ||
const response = await this.client.listContentTypeSnippets().toAllPromise(); | ||
response.data.items.forEach(m => this.processItem(m.name, 'contentTypeSnippet', m)); | ||
return response.data.items.map(m => m._raw); | ||
const response = await this.client | ||
.listContentTypeSnippets() | ||
.withListQueryConfig({ | ||
responseFetched: (listResponse, token) => { | ||
listResponse.data.items.forEach((m) => this.processItem(m.name, 'contentTypeSnippet', m)); | ||
} | ||
}) | ||
.toAllPromise(); | ||
return response.data.items.map((m) => m._raw); | ||
} | ||
public async exportContentTypesAsync(data: {processItem: boolean}): Promise<ContentTypeContracts.IContentTypeContract[]> { | ||
const response = await this.client.listContentTypes().toAllPromise(); | ||
if (data.processItem) { | ||
response.data.items.forEach(m => this.processItem(m.name, 'contentType', m)); | ||
} | ||
return response.data.items.map(m => m._raw); | ||
public async exportContentTypesAsync(data: { | ||
processItem: boolean; | ||
}): Promise<ContentTypeContracts.IContentTypeContract[]> { | ||
const response = await this.client | ||
.listContentTypes() | ||
.withListQueryConfig({ | ||
responseFetched: (listResponse, token) => { | ||
listResponse.data.items.forEach((m) => this.processItem(m.name, 'contentType', m)); | ||
} | ||
}) | ||
.toAllPromise(); | ||
return response.data.items.map((m) => m._raw); | ||
} | ||
public async exportContentItemsAsync(): Promise<ContentItemContracts.IContentItemModelContract[]> { | ||
const response = await this.client.listContentItems().toAllPromise(); | ||
response.data.items.forEach(m => this.processItem(m.name, 'contentItem', m)); | ||
return response.data.items.map(m => m._raw); | ||
const response = await this.client | ||
.listContentItems() | ||
.withListQueryConfig({ | ||
responseFetched: (listResponse, token) => { | ||
listResponse.data.items.forEach((m) => this.processItem(m.name, 'contentItem', m)); | ||
} | ||
}) | ||
.toAllPromise(); | ||
return response.data.items.map((m) => m._raw); | ||
} | ||
@@ -146,23 +176,29 @@ | ||
for (const typeId of typeIds) { | ||
languageVariants.push( | ||
...( | ||
await this.client | ||
.listLanguageVariantsOfContentTypeWithComponents() | ||
.byTypeId(typeId) | ||
.toAllPromise() | ||
).data.items.map(m => m._raw) | ||
); | ||
await this.client | ||
.listLanguageVariantsOfContentTypeWithComponents() | ||
.byTypeId(typeId) | ||
.withListQueryConfig({ | ||
responseFetched: (listResponse, token) => { | ||
languageVariants.push(...listResponse.data.items.map((m) => m._raw)); | ||
listResponse.data.items.forEach((m) => | ||
this.processItem(m.item.id?.toString() ?? '-', 'languageVariant', m) | ||
); | ||
} | ||
}) | ||
.toAllPromise(); | ||
languageVariants.push( | ||
...( | ||
await this.client | ||
.listLanguageVariantsOfContentType() | ||
.byTypeId(typeId) | ||
.toAllPromise() | ||
).data.items.map(m => m._raw) | ||
); | ||
await this.client | ||
.listLanguageVariantsOfContentType() | ||
.byTypeId(typeId) | ||
.withListQueryConfig({ | ||
responseFetched: (listResponse, token) => { | ||
languageVariants.push(...listResponse.data.items.map((m) => m._raw)); | ||
listResponse.data.items.forEach((m) => | ||
this.processItem(m.item.id?.toString() ?? '-', 'languageVariant', m) | ||
); | ||
} | ||
}) | ||
.toAllPromise(); | ||
} | ||
languageVariants.forEach(m => this.processItem(m.item.id?.toString() ?? '-', 'languageVariant', m)); | ||
return languageVariants; | ||
@@ -169,0 +205,0 @@ } |
@@ -646,3 +646,3 @@ import { HttpService } from '@kentico/kontent-core'; | ||
.byLanguageCodename(languageCodename) | ||
.withElements(languageVariant.elements) | ||
.withData(builder => languageVariant.elements) | ||
.toPromise() | ||
@@ -649,0 +649,0 @@ .then((response) => { |
@@ -80,2 +80,6 @@ import { AssetContracts } from '@kentico/kontent-management'; | ||
if (!assetsFolder) { | ||
throw Error(`Could not create folder '${this.filesName}'`); | ||
} | ||
if (this.config.enableLog) { | ||
@@ -86,4 +90,16 @@ console.log(`Adding assets to zip`); | ||
for (const asset of exportData.data.assets) { | ||
const assetIdShortFolder = assetsFolder.folder(asset.id.substr(0, 3)); | ||
const assetIdFolder = assetIdShortFolder.folder(asset.id); | ||
const assetIdShortFolderName = asset.id.substr(0, 3); | ||
const assetIdShortFolder = assetsFolder.folder(assetIdShortFolderName); | ||
if (!assetIdShortFolder) { | ||
throw Error(`Could not create folder '${this.filesName}'`); | ||
} | ||
const assetIdFolderName = asset.id; | ||
const assetIdFolder = assetIdShortFolder.folder(assetIdFolderName); | ||
if (!assetIdFolder) { | ||
throw Error(`Could not create folder '${this.filesName}'`); | ||
} | ||
const assetFilename = asset.file_name; | ||
@@ -90,0 +106,0 @@ assetIdFolder.file(assetFilename, this.getBinaryDataFromUrl(asset.url, this.config.enableLog), { |
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
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
343228
5355
+ Added@kentico/kontent-core@7.2.0(transitive)
+ Added@kentico/kontent-management@0.4.1(transitive)
+ Addedaxios@0.19.2(transitive)
+ Addedcliui@7.0.4(transitive)
+ Addedescalade@3.2.0(transitive)
+ Addedflatted@3.1.0(transitive)
+ Addedjszip@3.5.0(transitive)
+ Addedrxjs@6.6.3(transitive)
+ Addedwrap-ansi@7.0.0(transitive)
+ Addedy18n@5.0.8(transitive)
+ Addedyargs@16.0.3(transitive)
+ Addedyargs-parser@20.2.9(transitive)
- Removed@kentico/kontent-core@6.0.0(transitive)
- Removed@kentico/kontent-management@0.3.19(transitive)
- Removedaxios@0.19.0(transitive)
- Removedcamelcase@5.3.1(transitive)
- Removedcliui@6.0.0(transitive)
- Removeddecamelize@1.2.0(transitive)
- Removedfind-up@4.1.0(transitive)
- Removedflatted@2.0.2(transitive)
- Removedis-buffer@2.0.5(transitive)
- Removedjszip@3.4.0(transitive)
- Removedlocate-path@5.0.0(transitive)
- Removedp-limit@2.3.0(transitive)
- Removedp-locate@4.1.0(transitive)
- Removedp-try@2.2.0(transitive)
- Removedpath-exists@4.0.0(transitive)
- Removedrequire-main-filename@2.0.0(transitive)
- Removedrxjs@6.5.5(transitive)
- Removedset-blocking@2.0.0(transitive)
- Removedwhich-module@2.0.1(transitive)
- Removedwrap-ansi@6.2.0(transitive)
- Removedy18n@4.0.3(transitive)
- Removedyargs@15.3.1(transitive)
- Removedyargs-parser@18.1.3(transitive)
Updatedflatted@3.1.0
Updatedjszip@3.5.0
Updatedrxjs@6.6.3
Updatedyargs@16.0.3