UNPKG

@contentstack/datasync-asset-store-filesystem

Version:

Fillesystem asset store for DataSync libraries. Stores Contentstack asset-files in filesystem

24 lines (23 loc) 1.03 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.sanitizePath = exports.validateUnPublishAsset = exports.validatePublishAsset = void 0; const requiredKeysForPublish = ['url', 'locale', 'uid']; const requiredKeysForUnpublish = ['url', 'locale', 'filename', 'uid']; const validatePublishAsset = (asset) => { requiredKeysForPublish.forEach((key) => { if (!(key in asset)) { throw new Error(`${key} is missing in asset publish!\n${JSON.stringify(asset)}`); } }); }; exports.validatePublishAsset = validatePublishAsset; const validateUnPublishAsset = (asset) => { requiredKeysForUnpublish.forEach((key) => { if (!(key in asset)) { throw new Error(`${key} is missing in asset unpublish!\n${JSON.stringify(asset)}`); } }); }; exports.validateUnPublishAsset = validateUnPublishAsset; const sanitizePath = (str) => str === null || str === void 0 ? void 0 : str.replace(/^(\.\.(\/|\\|$))+/, ''); exports.sanitizePath = sanitizePath;