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

@sap-ux/yaml

Package Overview
Dependencies
Maintainers
3
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sap-ux/yaml - npm Package Compare versions

Comparing version 0.12.3 to 0.12.4

dist/errors/index.d.ts

1

dist/index.d.ts
export { YamlDocument, NodeComment } from './yaml-document';
export { Node, YAMLSeq, YAMLMap } from 'yaml';
export { errorCode, YAMLError } from './errors';
//# sourceMappingURL=index.d.ts.map

5

dist/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.YAMLMap = exports.YAMLSeq = exports.YamlDocument = void 0;
exports.YAMLError = exports.errorCode = exports.YAMLMap = exports.YAMLSeq = exports.YamlDocument = void 0;
var yaml_document_1 = require("./yaml-document");

@@ -9,2 +9,5 @@ Object.defineProperty(exports, "YamlDocument", { enumerable: true, get: function () { return yaml_document_1.YamlDocument; } });

Object.defineProperty(exports, "YAMLMap", { enumerable: true, get: function () { return yaml_1.YAMLMap; } });
var errors_1 = require("./errors");
Object.defineProperty(exports, "errorCode", { enumerable: true, get: function () { return errors_1.errorCode; } });
Object.defineProperty(exports, "YAMLError", { enumerable: true, get: function () { return errors_1.YAMLError; } });
//# sourceMappingURL=index.js.map

@@ -30,7 +30,11 @@ "use strict";

};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.YamlDocument = void 0;
const i18n_1 = require("./i18n");
const yaml_1 = __importStar(require("yaml"));
const merge = require("lodash.merge");
const merge_1 = __importDefault(require("lodash/merge"));
const errors_1 = require("./errors");
const texts_1 = require("./texts");
/**

@@ -52,3 +56,3 @@ * Represents a yaml document with utility functions to manipulate the document.

if (((_a = this.document.errors) === null || _a === void 0 ? void 0 : _a.length) > 0) {
throw new Error(i18n_1.t('error.yamlParsing') + '\n' + this.document.errors.map((e) => e.message).join(''));
throw new errors_1.YAMLError(errors_1.errorTemplate.yamlParsing + '\n' + this.document.errors.map((e) => e.message).join(''), errors_1.errorCode.yamlParsing);
}

@@ -66,3 +70,2 @@ }

return __awaiter(this, void 0, void 0, function* () {
yield i18n_1.initI18n();
return new YamlDocument(serializedYaml);

@@ -132,3 +135,3 @@ });

// Not at root and we're not asked to create the intermediate keys
throw new Error(i18n_1.t('error.pathDoesNotExist', { path: parentPath }));
throw new errors_1.YAMLError(texts_1.interpolate(errors_1.errorTemplate.pathDoesNotExist, { path: parentPath }), errors_1.errorCode.pathDoesNotExist);
}

@@ -157,14 +160,16 @@ }

const pathArray = this.toPathArray(path);
let seq = this.document.getIn(pathArray);
// Create a copy to work to modify
const documentCopy = this.document.clone();
let seq = documentCopy.getIn(pathArray);
if (!seq) {
if (!createIntermediateKeys) {
throw new Error(i18n_1.t('error.seqDoesNotExist', { path }));
throw new errors_1.YAMLError(texts_1.interpolate(errors_1.errorTemplate.seqDoesNotExist, { path }), errors_1.errorCode.seqDoesNotExist);
}
seq = new yaml_1.YAMLSeq();
this.document.setIn(pathArray, seq);
documentCopy.setIn(pathArray, seq);
}
else if (!yaml_1.isSeq(seq)) {
throw new Error(i18n_1.t('error.tryingToAppendToNonSequence', { path }));
throw new errors_1.YAMLError(texts_1.interpolate(errors_1.errorTemplate.tryingToAppendToNonSequence, { path }), errors_1.errorCode.tryingToAppendToNonSequence);
}
const newNode = this.document.createNode(value);
const newNode = documentCopy.createNode(value);
if (nodeComment) {

@@ -176,3 +181,3 @@ newNode.commentBefore = nodeComment;

if (typeof value !== 'object') {
throw new Error(i18n_1.t('error.scalarValuesDoNotHaveProperties'));
throw new errors_1.YAMLError(errors_1.errorTemplate.scalarValuesDoNotHaveProperties, errors_1.errorCode.scalarValuesDoNotHaveProperties);
}

@@ -182,5 +187,5 @@ const index = seq.items.length - 1;

const propPathArray = this.toPathArray(c.path);
const n = this.document.getIn([...pathArray, index, ...propPathArray], true);
const n = documentCopy.getIn([...pathArray, index, ...propPathArray], true);
if (!n) {
throw new Error(i18n_1.t('error.propertyNotFound', { path: c.path }));
throw new errors_1.YAMLError(texts_1.interpolate(errors_1.errorTemplate.propertyNotFound, { path: c.path }), errors_1.errorCode.propertyNotFound);
}

@@ -190,2 +195,4 @@ n.comment = c.comment;

}
// Modification succeeded, replace document with modified copy
this.document = documentCopy;
return this;

@@ -209,9 +216,9 @@ }

if (!seq) {
throw new Error(i18n_1.t('error.seqDoesNotExist', { path }));
throw new errors_1.YAMLError(texts_1.interpolate(errors_1.errorTemplate.seqDoesNotExist, { path }), errors_1.errorCode.seqDoesNotExist);
}
const node = seq.items.find((nodeInput) => nodeInput.toJSON()[matcher.key] === matcher.value);
if (!node) {
throw new Error(i18n_1.t('error.nodeNotFoundMatching', { path, key: matcher.key, value: matcher.value }));
throw new errors_1.YAMLError(texts_1.interpolate(errors_1.errorTemplate.nodeNotFoundMatching, { path, key: matcher.key, value: matcher.value }), errors_1.errorCode.nodeNotFoundMatching);
}
const newNode = this.document.createNode(merge(node.toJSON(), value));
const newNode = this.document.createNode(merge_1.default(node.toJSON(), value));
seq.items.splice(seq.items.indexOf(node), 1, newNode);

@@ -235,3 +242,3 @@ return this;

if (!seq || !seq.items) {
throw new Error(i18n_1.t('error.seqDoesNotExist', { path }));
throw new errors_1.YAMLError(texts_1.interpolate(errors_1.errorTemplate.seqDoesNotExist, { path }), errors_1.errorCode.seqDoesNotExist);
}

@@ -248,3 +255,3 @@ const deletedNode = seq.items.find((node, index) => {

if (!deletedNode) {
throw new Error(i18n_1.t('error.propertyNotFound', { path }));
throw new errors_1.YAMLError(texts_1.interpolate(errors_1.errorTemplate.propertyNotFound, { path }), errors_1.errorCode.propertyNotFound);
}

@@ -262,3 +269,3 @@ return this;

if (!(yaml_1.isSeq(start) || yaml_1.isMap(start))) {
throw new Error(i18n_1.t('error.startNodeMustBeCollection'));
throw new errors_1.YAMLError(errors_1.errorTemplate.startNodeMustBeCollection, errors_1.errorCode.startNodeMustBeCollection);
}

@@ -270,3 +277,3 @@ }

if (!targetNode) {
throw new Error(i18n_1.t('error.nodeNotFound', { path }));
throw new errors_1.YAMLError(texts_1.interpolate(errors_1.errorTemplate.nodeNotFound, { path }), errors_1.errorCode.nodeNotFound);
}

@@ -286,3 +293,3 @@ else {

if (!yaml_1.isSeq(a)) {
throw new Error(i18n_1.t('error.seqDoesNotExist', { path }));
throw new errors_1.YAMLError(texts_1.interpolate(errors_1.errorTemplate.seqDoesNotExist, { path }), errors_1.errorCode.seqDoesNotExist);
}

@@ -302,3 +309,3 @@ else {

if (!yaml_1.isMap(a)) {
throw new Error(i18n_1.t('error.nodeNotAMap', { path }));
throw new errors_1.YAMLError(texts_1.interpolate(errors_1.errorTemplate.nodeNotAMap, { path }), errors_1.errorCode.nodeNotAMap);
}

@@ -330,3 +337,3 @@ else {

if (!result || result.length === 0) {
throw new Error(i18n_1.t('error.pathCannotBeEmpty'));
throw new errors_1.YAMLError(errors_1.errorTemplate.pathCannotBeEmpty, errors_1.errorCode.pathCannotBeEmpty);
}

@@ -333,0 +340,0 @@ return result;

@@ -12,3 +12,3 @@ {

},
"version": "0.12.3",
"version": "0.12.4",
"main": "dist/index.js",

@@ -22,5 +22,3 @@ "files": [

"dependencies": {
"i18next": "20.3.2",
"i18next-fs-backend": "1.1.1",
"lodash.merge": "4.6.2",
"lodash": "4.17.21",
"yaml": "2.0.0-10"

@@ -30,3 +28,3 @@ },

"@types/i18next-fs-backend": "1.0.0",
"@types/lodash.merge": "4.6.6"
"@types/lodash": "4.14.176"
},

@@ -33,0 +31,0 @@ "engines": {

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