@atlaskit/adf-utils
Advanced tools
Comparing version 19.14.1 to 19.15.0
@@ -9,7 +9,12 @@ "use strict"; | ||
var _text = require("../nodes/text"); | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
function createTextNodes(nodes) { | ||
return nodes.map(createTextFromString); | ||
} | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
function createTextFromString(str) { | ||
return typeof str === 'string' ? (0, _text.text)(str) : str; | ||
} |
@@ -8,2 +8,4 @@ "use strict"; | ||
exports.isDuplicateMark = isDuplicateMark; | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
function isDuplicateMark(node, type) { | ||
@@ -17,4 +19,7 @@ if (node.marks && node.marks.some(function (mark) { | ||
} | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
function duplicateMarkError(node, type) { | ||
return "Mark with the same name '".concat(type, "' already exists on a node: ").concat(JSON.stringify(node)); | ||
} |
@@ -26,2 +26,4 @@ "use strict"; | ||
type: node.type, | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
attrs: node.attrs ? (0, _scrubContent.scrubAttrs)(node.type, node.attrs) : undefined, | ||
@@ -28,0 +30,0 @@ content: (_node$content = node.content) === null || _node$content === void 0 ? void 0 : _node$content.filter(function (c) { |
@@ -32,2 +32,5 @@ "use strict"; | ||
} | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
var updatedNode = {}; | ||
@@ -34,0 +37,0 @@ Object.entries(node).forEach(function (_ref) { |
@@ -36,2 +36,4 @@ "use strict"; | ||
}; | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
var fromEntries = function fromEntries(iterable) { | ||
@@ -102,2 +104,4 @@ return (0, _toConsumableArray2.default)(iterable).reduce(function (obj, _ref) { | ||
var scrubObj = function scrubObj(nodeType, attrsObj) { | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
var entries = Object.entries(attrsObj).map(function (_ref4) { | ||
@@ -112,2 +116,5 @@ var _BYPASS_ATTR_LIST$nod; | ||
}; | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
var scrubAttrs = exports.scrubAttrs = function scrubAttrs(nodeType, attrs) { | ||
@@ -114,0 +121,0 @@ var offset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; |
@@ -12,2 +12,8 @@ "use strict"; | ||
}); | ||
Object.defineProperty(exports, "isNestedTableExtension", { | ||
enumerable: true, | ||
get: function get() { | ||
return _nestedTableTransform.isNestedTableExtension; | ||
} | ||
}); | ||
Object.defineProperty(exports, "transformDedupeMarks", { | ||
@@ -14,0 +20,0 @@ enumerable: true, |
@@ -7,3 +7,3 @@ "use strict"; | ||
}); | ||
exports.transformNestedTablesIncomingDocument = exports.transformNestedTableNodeOutgoingDocument = void 0; | ||
exports.transformNestedTablesIncomingDocument = exports.transformNestedTableNodeOutgoingDocument = exports.isNestedTableExtension = void 0; | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
@@ -17,3 +17,3 @@ var _traverse = require("../traverse/traverse"); | ||
NESTED_TABLE_EXTENSION_KEY = 'nested-table'; | ||
var isNestedTableExtension = function isNestedTableExtension(extensionNode) { | ||
var isNestedTableExtension = exports.isNestedTableExtension = function isNestedTableExtension(extensionNode) { | ||
var _extensionNode$attrs, _extensionNode$attrs2; | ||
@@ -20,0 +20,0 @@ return ((_extensionNode$attrs = extensionNode.attrs) === null || _extensionNode$attrs === void 0 ? void 0 : _extensionNode$attrs.extensionType) === NESTED_TABLE_EXTENSION_TYPE && ((_extensionNode$attrs2 = extensionNode.attrs) === null || _extensionNode$attrs2 === void 0 ? void 0 : _extensionNode$attrs2.extensionKey) === NESTED_TABLE_EXTENSION_KEY; |
@@ -73,2 +73,4 @@ "use strict"; | ||
default: | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
return (0, _builders.listItem)([childNode]); | ||
@@ -75,0 +77,0 @@ } |
@@ -8,2 +8,4 @@ "use strict"; | ||
var _traverse = require("./traverse"); | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
function map(adf, callback) { | ||
@@ -10,0 +12,0 @@ var result = []; |
@@ -8,2 +8,4 @@ "use strict"; | ||
var _traverse = require("./traverse"); | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
function reduce(adf, callback, initial) { | ||
@@ -10,0 +12,0 @@ var result = initial; |
@@ -33,2 +33,5 @@ "use strict"; | ||
} | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/max-params | ||
function traverseNode(adfNode, parent, visitors, index, depth) { | ||
@@ -35,0 +38,0 @@ var visitor = visitors[adfNode.type] || visitors['any']; |
@@ -29,3 +29,8 @@ "use strict"; | ||
}; | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
var copy = exports.copy = function copy(source, dest, key) { | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
dest[key] = source[key]; | ||
@@ -32,0 +37,0 @@ return dest; |
@@ -16,3 +16,4 @@ "use strict"; | ||
var _rules = require("./rules"); | ||
var _excluded = ["items"]; | ||
var _excluded = ["items"]; // Ignored via go/ees005 | ||
// eslint-disable-next-line import/no-namespace | ||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); } | ||
@@ -22,2 +23,4 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } | ||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
function mapMarksItems(spec) { | ||
@@ -28,2 +31,4 @@ var fn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (x) { | ||
if (spec.props && spec.props.marks) { | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
var _ref = spec.props.marks, | ||
@@ -47,2 +52,5 @@ items = _ref.items, | ||
} | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
var partitionObject = function partitionObject(obj, predicate) { | ||
@@ -61,3 +69,7 @@ return Object.keys(obj).reduce(function (acc, key) { | ||
function createSpec(nodes, marks) { | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
return Object.keys(specs).reduce(function (newSpecs, k) { | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
var spec = _objectSpread({}, specs[k]); | ||
@@ -69,2 +81,4 @@ if (spec.props) { | ||
if ((0, _utils.isString)(spec.props.content)) { | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
spec.props.content = specs[spec.props.content]; | ||
@@ -97,3 +111,9 @@ } | ||
.map(function (item) { | ||
return (0, _utils.isString)(item) ? Array.isArray(specs[item]) ? specs[item] : [item] : item; | ||
return (0, _utils.isString)(item) ? | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
Array.isArray(specs[item]) ? | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
specs[item] : [item] : item; | ||
}) | ||
@@ -103,5 +123,12 @@ // [['emoji', 'hr', 'inline_code']] => [['emoji', 'hr', ['text', { marks: {} }]]] | ||
return item.map(function (subItem) { | ||
return Array.isArray(specs[subItem]) ? specs[subItem] : (0, _utils.isString)(subItem) ? subItem : | ||
// Now `NoMark` produces `items: []`, should be fixed in generator | ||
['text', subItem]; | ||
return ( | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
Array.isArray(specs[subItem]) ? | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
specs[subItem] : (0, _utils.isString)(subItem) ? subItem : | ||
// Now `NoMark` produces `items: []`, should be fixed in generator | ||
['text', subItem] | ||
); | ||
}) | ||
@@ -144,2 +171,5 @@ // Remove unsupported nodes & marks | ||
} | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
function getOptionsForType(type, list) { | ||
@@ -174,3 +204,7 @@ if (!list) { | ||
var _partitionObject = partitionObject(spec.props, function (key, subSpec) { | ||
return validateAttrs(subSpec, value[key]); | ||
return ( | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
validateAttrs(subSpec, value[key]) | ||
); | ||
}), | ||
@@ -197,3 +231,9 @@ _partitionObject2 = (0, _slicedToArray2.default)(_partitionObject, 2), | ||
}; | ||
return (0, _utils.isString)(value) && ((0, _utils.isDefined)(spec.minLength) ? spec.minLength <= value.length : true) && ((0, _utils.isDefined)(spec.validatorFn) ? validatorFnPassed(spec.validatorFn) : true) && (spec.pattern ? new RegExp(spec.pattern).test(value) : true); | ||
return (0, _utils.isString)(value) && ( | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
(0, _utils.isDefined)(spec.minLength) ? spec.minLength <= value.length : true) && ((0, _utils.isDefined)(spec.validatorFn) ? validatorFnPassed(spec.validatorFn) : true) && ( | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line require-unicode-regexp | ||
spec.pattern ? new RegExp(spec.pattern).test(value) : true); | ||
case 'object': | ||
@@ -257,3 +297,6 @@ return (0, _utils.isPlainObject)(value); | ||
}; | ||
var unsupportedMarkContent = function unsupportedMarkContent(errorCode, mark, errorCallback, errorMessage) { | ||
var unsupportedMarkContent = function unsupportedMarkContent(errorCode, mark, errorCallback, errorMessage | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/max-params | ||
) { | ||
var message = errorMessage || errorMessageFor(mark.type, 'unsupported mark'); | ||
@@ -274,3 +317,6 @@ if (!errorCallback) { | ||
}; | ||
var unsupportedNodeAttributesContent = function unsupportedNodeAttributesContent(entity, errorCode, invalidAttributes, message, errorCallback) { | ||
var unsupportedNodeAttributesContent = function unsupportedNodeAttributesContent(entity, errorCode, invalidAttributes, message, errorCallback | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/max-params | ||
) { | ||
if (!errorCallback) { | ||
@@ -300,2 +346,4 @@ throw new Error(message); | ||
allowPrivateAttributes = _ref2$allowPrivateAtt === void 0 ? false : _ref2$allowPrivateAtt; | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/max-params | ||
var validate = function validate(entity, errorCallback, allowed, parentSpec) { | ||
@@ -351,2 +399,5 @@ var validationResult = validateNode(entity, errorCallback, allowed, parentSpec); | ||
return validate; | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/max-params | ||
function marksValidationFor(validator, entity, errorCallback, newEntity, err) { | ||
@@ -367,2 +418,4 @@ var validationResult; | ||
} | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
function validatorFor(spec, typeOptions) { | ||
@@ -373,2 +426,5 @@ return _objectSpread(_objectSpread(_objectSpread({}, spec), typeOptions), spec.props ? { | ||
} | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/max-params | ||
function marksAfterValidation(entity, errorCallback, marksSet, validator) { | ||
@@ -413,2 +469,4 @@ return entity.marks ? entity.marks.map(function (mark) { | ||
function allowedMarksFor(validator) { | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
var _ref3 = validator.props.marks, | ||
@@ -419,2 +477,5 @@ items = _ref3.items; | ||
} | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/max-params | ||
function marksForEntitySpecNotSupportingMarks(prevEntity, newEntity, errorCallback, err) { | ||
@@ -461,4 +522,9 @@ var errorCode = 'REDUNDANT_MARKS'; | ||
}; | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
if (validatorSpec.props.text) { | ||
if ((0, _utils.isDefined)(prevEntity.text) && !validateAttrs(validatorSpec.props.text, prevEntity.text)) { | ||
if ((0, _utils.isDefined)(prevEntity.text) && | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
!validateAttrs(validatorSpec.props.text, prevEntity.text)) { | ||
result = err('INVALID_TEXT', "'text' validation failed"); | ||
@@ -474,3 +540,7 @@ } | ||
}; | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
if (validatorSpec.props.content && prevEntity.content) { | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
var _content = validatorSpec.props.content, | ||
@@ -498,2 +568,4 @@ minItems = _content.minItems, | ||
var invalidAttrs = []; | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
var validatorAttrs = {}; | ||
@@ -511,2 +583,4 @@ if (validatorSpec.props && validatorSpec.props.attrs) { | ||
var _partitionObject3 = partitionObject(attrOption.props, function (key, spec) { | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
var valueToValidate = prevEntity.attrs[key]; | ||
@@ -518,2 +592,4 @@ return validateAttrs(spec, valueToValidate); | ||
} | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
validatorAttrs = attrOption; | ||
@@ -530,2 +606,5 @@ if (!invalidAttrs.length) { | ||
} | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/max-params | ||
function attributesValidationFor(validatorSpec, prevEntity, newEntity, isMark, errorCallback) { | ||
@@ -557,3 +636,6 @@ var validatorSpecAllowsAttributes = validatorSpec.props && validatorSpec.props.attrs; | ||
} | ||
function validateAttributes(validatorSpec, prevEntity, attributes) { | ||
function validateAttributes(validatorSpec, prevEntity, | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
attributes) { | ||
var invalidAttributesResult = invalidAttributesFor(validatorSpec, prevEntity); | ||
@@ -565,2 +647,5 @@ var invalidAttrs = invalidAttributesResult.invalidAttrs; | ||
}); | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
var redundantAttrs = attrs.filter(function (a) { | ||
@@ -577,2 +662,5 @@ return !validatorAttrs.props[a]; | ||
} | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/max-params | ||
function handleUnsupportedNodeAttributes(prevEntity, newEntity, invalidAttrs, redundantAttrs, errorCallback) { | ||
@@ -613,3 +701,6 @@ var attr = invalidAttrs.concat(redundantAttrs); | ||
} | ||
function handleNoAttibutesAllowedInSpecForMark(prevEntity, attributes) { | ||
function handleNoAttibutesAllowedInSpecForMark(prevEntity, | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
attributes) { | ||
var message = errorMessageFor('redundant attributes found', Object.keys(attributes).join(', ')); | ||
@@ -628,2 +719,5 @@ var errorCode = 'REDUNDANT_ATTRIBUTES'; | ||
} | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/max-params | ||
function wrapUnSupportedNodeAttributes(prevEntity, newEntity, invalidAttrs, errorCode, message, errorCallback) { | ||
@@ -659,2 +753,5 @@ var invalidValues = {}; | ||
} | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/max-params | ||
function extraPropsValidationFor(validatorSpec, prevEntity, err, newEntity, type) { | ||
@@ -666,3 +763,7 @@ var result = { | ||
var _partitionObject5 = partitionObject(prevEntity, function (k) { | ||
return (0, _utils.isDefined)(validatorSpec.props[k]); | ||
return ( | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
(0, _utils.isDefined)(validatorSpec.props[k]) | ||
); | ||
}), | ||
@@ -690,3 +791,9 @@ _partitionObject6 = (0, _slicedToArray2.default)(_partitionObject5, 2), | ||
} | ||
function specBasedValidationFor(spec, typeOptions, prevEntity, err, newEntity, type, errorCallback, isMark) { | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/max-params | ||
function specBasedValidationFor(spec, | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
typeOptions, prevEntity, err, newEntity, type, errorCallback, isMark) { | ||
var specBasedValidationResult = { | ||
@@ -784,2 +891,4 @@ hasValidated: false | ||
if (prevEntity.content) { | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
var validateChildNode = function validateChildNode(child, index) { | ||
@@ -796,2 +905,4 @@ if (child === undefined) { | ||
}); | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
var finalMarks = marksValidationOutput.map(function (mr) { | ||
@@ -802,3 +913,6 @@ if (mr.valid) { | ||
if (validMarks.length || isLastValidationSpec || isParentTupleLike || mr.errorCode === 'INVALID_TYPE' || mr.errorCode === 'INVALID_CONTENT' || mr.errorCode === 'REDUNDANT_ATTRIBUTES' || mr.errorCode === 'INVALID_ATTRIBUTES') { | ||
return unsupportedMarkContent(mr.errorCode, mr.originalMark, errorCallback, mr.message); | ||
return unsupportedMarkContent( | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
mr.errorCode, mr.originalMark, errorCallback, mr.message); | ||
} | ||
@@ -805,0 +919,0 @@ return; |
import { text } from '../nodes/text'; | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export function createTextNodes(nodes) { | ||
return nodes.map(createTextFromString); | ||
} | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export function createTextFromString(str) { | ||
return typeof str === 'string' ? text(str) : str; | ||
} |
@@ -0,1 +1,3 @@ | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export function isDuplicateMark(node, type) { | ||
@@ -7,4 +9,7 @@ if (node.marks && node.marks.some(mark => mark.type === type)) { | ||
} | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export function duplicateMarkError(node, type) { | ||
return `Mark with the same name '${type}' already exists on a node: ${JSON.stringify(node)}`; | ||
} |
@@ -18,2 +18,4 @@ import { scrubAttrs } from './scrub-content'; | ||
type: node.type, | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
attrs: node.attrs ? scrubAttrs(node.type, node.attrs) : undefined, | ||
@@ -66,2 +68,4 @@ content: (_node$content = node.content) === null || _node$content === void 0 ? void 0 : _node$content.filter(c => (c === null || c === void 0 ? void 0 : c.type) === 'media') | ||
attrs: { | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
...scrubAttrs('media', node.attrs), | ||
@@ -68,0 +72,0 @@ type: 'external', |
@@ -26,2 +26,5 @@ import { traverse } from '../traverse/traverse'; | ||
} | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
const updatedNode = {}; | ||
@@ -28,0 +31,0 @@ Object.entries(node).forEach(([key, value]) => { |
@@ -23,2 +23,4 @@ const DUMMY_TEXT = `Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua Ut enim ad minim veniam quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur Excepteur sint occaecat cupidatat non proident sunt in culpa qui officia deserunt mollit anim id est laborum`; | ||
}; | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
const fromEntries = iterable => { | ||
@@ -87,2 +89,4 @@ return [...iterable].reduce((obj, [key, val]) => { | ||
const scrubObj = (nodeType, attrsObj) => { | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
const entries = Object.entries(attrsObj).map(([key, value]) => { | ||
@@ -94,2 +98,5 @@ var _BYPASS_ATTR_LIST$nod; | ||
}; | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export const scrubAttrs = (nodeType, attrs, offset = 0) => { | ||
@@ -96,0 +103,0 @@ if (typeof attrs === 'number') { |
@@ -10,4 +10,4 @@ // Disable no-re-export rule for entry point files | ||
export { transformInvalidMediaContent } from './transforms/invalid-media-content-transform'; | ||
export { transformNestedTablesIncomingDocument } from './transforms/nested-table-transform'; | ||
export { transformNestedTablesIncomingDocument, isNestedTableExtension } from './transforms/nested-table-transform'; | ||
export { transformNestedTableNodeOutgoingDocument } from './transforms/nested-table-transform'; | ||
export { NodeNestingTransformError } from './transforms/errors'; |
@@ -33,3 +33,3 @@ import { traverse } from '../traverse/traverse'; | ||
} | ||
let dedupedMarks = node.marks.filter(mark => { | ||
const dedupedMarks = node.marks.filter(mark => { | ||
const markType = mark.type; | ||
@@ -68,3 +68,3 @@ if (markType === 'annotation') { | ||
let isTransformed = false; | ||
let discardedMarks = []; | ||
const discardedMarks = []; | ||
const transformedAdf = traverse(adf, { | ||
@@ -71,0 +71,0 @@ text: node => { |
import { traverse } from '../traverse/traverse'; | ||
import { isEmpty } from './helpers'; | ||
const getChildrenTypeCounts = (nodeContent, allowedTypes) => { | ||
let childrenTypes = {}; | ||
const childrenTypes = {}; | ||
nodeContent.forEach((childNode, index) => { | ||
@@ -6,0 +6,0 @@ if (!(childNode !== null && childNode !== void 0 && childNode.type) || !allowedTypes.includes(childNode.type)) { |
@@ -6,3 +6,3 @@ import { traverse } from '../traverse/traverse'; | ||
NESTED_TABLE_EXTENSION_KEY = 'nested-table'; | ||
const isNestedTableExtension = extensionNode => { | ||
export const isNestedTableExtension = extensionNode => { | ||
var _extensionNode$attrs, _extensionNode$attrs2; | ||
@@ -9,0 +9,0 @@ return ((_extensionNode$attrs = extensionNode.attrs) === null || _extensionNode$attrs === void 0 ? void 0 : _extensionNode$attrs.extensionType) === NESTED_TABLE_EXTENSION_TYPE && ((_extensionNode$attrs2 = extensionNode.attrs) === null || _extensionNode$attrs2 === void 0 ? void 0 : _extensionNode$attrs2.extensionKey) === NESTED_TABLE_EXTENSION_KEY; |
@@ -59,2 +59,4 @@ import { traverse } from '../traverse/traverse'; | ||
default: | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
return listItem([childNode]); | ||
@@ -61,0 +63,0 @@ } |
import { traverse } from './traverse'; | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export function map(adf, callback) { | ||
@@ -3,0 +6,0 @@ const result = []; |
import { traverse } from './traverse'; | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export function reduce(adf, callback, initial) { | ||
@@ -3,0 +6,0 @@ let result = initial; |
@@ -22,2 +22,5 @@ export function validateVisitors(_visitors) { | ||
} | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/max-params | ||
function traverseNode(adfNode, parent, visitors, index, depth) { | ||
@@ -24,0 +27,0 @@ const visitor = visitors[adfNode.type] || visitors['any']; |
@@ -9,3 +9,8 @@ export const isDefined = x => x != null; | ||
export const isPlainObject = x => typeof x === 'object' && x !== null && !Array.isArray(x); | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export const copy = (source, dest, key) => { | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
dest[key] = source[key]; | ||
@@ -12,0 +17,0 @@ return dest; |
@@ -0,6 +1,13 @@ | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line import/no-namespace | ||
import * as specs from './specs'; | ||
import { copy, isBoolean, isDefined, isInteger, isNumber, isPlainObject, isString, makeArray } from './utils'; | ||
import { validatorFnMap } from './rules'; | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
function mapMarksItems(spec, fn = x => x) { | ||
if (spec.props && spec.props.marks) { | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
const { | ||
@@ -28,2 +35,5 @@ items, | ||
} | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
const partitionObject = (obj, predicate) => Object.keys(obj).reduce((acc, key) => { | ||
@@ -40,3 +50,7 @@ const result = predicate(key, obj[key], obj); | ||
function createSpec(nodes, marks) { | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
return Object.keys(specs).reduce((newSpecs, k) => { | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
const spec = { | ||
@@ -52,2 +66,4 @@ ...specs[k] | ||
if (isString(spec.props.content)) { | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
spec.props.content = specs[spec.props.content]; | ||
@@ -79,5 +95,17 @@ } | ||
// ['media'] => [['media']] | ||
.map(item => isString(item) ? Array.isArray(specs[item]) ? specs[item] : [item] : item) | ||
.map(item => isString(item) ? | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
Array.isArray(specs[item]) ? | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
specs[item] : [item] : item) | ||
// [['emoji', 'hr', 'inline_code']] => [['emoji', 'hr', ['text', { marks: {} }]]] | ||
.map(item => item.map(subItem => Array.isArray(specs[subItem]) ? specs[subItem] : isString(subItem) ? subItem : | ||
.map(item => item.map(subItem => | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
Array.isArray(specs[subItem]) ? | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
specs[subItem] : isString(subItem) ? subItem : | ||
// Now `NoMark` produces `items: []`, should be fixed in generator | ||
@@ -116,2 +144,5 @@ ['text', subItem]) | ||
} | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
function getOptionsForType(type, list) { | ||
@@ -143,3 +174,6 @@ if (!list) { | ||
// If spec has ".props" it is ValidatorSpecAttrs and need to pipe back in recursively | ||
const [_, invalidKeys] = partitionObject(spec.props, (key, subSpec) => validateAttrs(subSpec, value[key])); | ||
const [_, invalidKeys] = partitionObject(spec.props, (key, subSpec) => | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
validateAttrs(subSpec, value[key])); | ||
return invalidKeys.length === 0; | ||
@@ -160,3 +194,9 @@ } | ||
const validatorFnPassed = rule => typeof value === 'string' && isDefined(validatorFnMap[rule]) && validatorFnMap[rule](value); | ||
return isString(value) && (isDefined(spec.minLength) ? spec.minLength <= value.length : true) && (isDefined(spec.validatorFn) ? validatorFnPassed(spec.validatorFn) : true) && (spec.pattern ? new RegExp(spec.pattern).test(value) : true); | ||
return isString(value) && ( | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
isDefined(spec.minLength) ? spec.minLength <= value.length : true) && (isDefined(spec.validatorFn) ? validatorFnPassed(spec.validatorFn) : true) && ( | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line require-unicode-regexp | ||
spec.pattern ? new RegExp(spec.pattern).test(value) : true); | ||
case 'object': | ||
@@ -216,3 +256,6 @@ return isPlainObject(value); | ||
}; | ||
const unsupportedMarkContent = (errorCode, mark, errorCallback, errorMessage) => { | ||
const unsupportedMarkContent = (errorCode, mark, errorCallback, errorMessage | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/max-params | ||
) => { | ||
const message = errorMessage || errorMessageFor(mark.type, 'unsupported mark'); | ||
@@ -235,3 +278,6 @@ if (!errorCallback) { | ||
}; | ||
const unsupportedNodeAttributesContent = (entity, errorCode, invalidAttributes, message, errorCallback) => { | ||
const unsupportedNodeAttributesContent = (entity, errorCode, invalidAttributes, message, errorCallback | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/max-params | ||
) => { | ||
if (!errorCallback) { | ||
@@ -260,2 +306,4 @@ throw new Error(message); | ||
} = options || {}; | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/max-params | ||
const validate = (entity, errorCallback, allowed, parentSpec) => { | ||
@@ -268,7 +316,10 @@ const validationResult = validateNode(entity, errorCallback, allowed, parentSpec); | ||
}; | ||
const validateNode = (entity, errorCallback, allowed, parentSpec, isMark = false) => { | ||
const validateNode = (entity, errorCallback, allowed, parentSpec, isMark = false | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/max-params | ||
) => { | ||
const { | ||
type | ||
} = entity; | ||
let newEntity = { | ||
const newEntity = { | ||
...entity | ||
@@ -315,2 +366,5 @@ }; | ||
return validate; | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/max-params | ||
function marksValidationFor(validator, entity, errorCallback, newEntity, err) { | ||
@@ -331,2 +385,4 @@ let validationResult; | ||
} | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
function validatorFor(spec, typeOptions) { | ||
@@ -345,2 +401,5 @@ return { | ||
} | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/max-params | ||
function marksAfterValidation(entity, errorCallback, marksSet, validator) { | ||
@@ -385,2 +444,4 @@ return entity.marks ? entity.marks.map(mark => { | ||
function allowedMarksFor(validator) { | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
const { | ||
@@ -392,2 +453,5 @@ items | ||
} | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/max-params | ||
function marksForEntitySpecNotSupportingMarks(prevEntity, newEntity, errorCallback, err) { | ||
@@ -432,4 +496,9 @@ const errorCode = 'REDUNDANT_MARKS'; | ||
}; | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
if (validatorSpec.props.text) { | ||
if (isDefined(prevEntity.text) && !validateAttrs(validatorSpec.props.text, prevEntity.text)) { | ||
if (isDefined(prevEntity.text) && | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
!validateAttrs(validatorSpec.props.text, prevEntity.text)) { | ||
result = err('INVALID_TEXT', `'text' validation failed`); | ||
@@ -445,3 +514,7 @@ } | ||
}; | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
if (validatorSpec.props.content && prevEntity.content) { | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
const { | ||
@@ -470,2 +543,4 @@ minItems, | ||
let invalidAttrs = []; | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
let validatorAttrs = {}; | ||
@@ -483,2 +558,4 @@ if (validatorSpec.props && validatorSpec.props.attrs) { | ||
[, invalidAttrs] = partitionObject(attrOption.props, (key, spec) => { | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
const valueToValidate = prevEntity.attrs[key]; | ||
@@ -488,2 +565,4 @@ return validateAttrs(spec, valueToValidate); | ||
} | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
validatorAttrs = attrOption; | ||
@@ -500,2 +579,5 @@ if (!invalidAttrs.length) { | ||
} | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/max-params | ||
function attributesValidationFor(validatorSpec, prevEntity, newEntity, isMark, errorCallback) { | ||
@@ -528,3 +610,6 @@ const validatorSpecAllowsAttributes = validatorSpec.props && validatorSpec.props.attrs; | ||
} | ||
function validateAttributes(validatorSpec, prevEntity, attributes) { | ||
function validateAttributes(validatorSpec, prevEntity, | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
attributes) { | ||
const invalidAttributesResult = invalidAttributesFor(validatorSpec, prevEntity); | ||
@@ -536,2 +621,5 @@ const { | ||
const attrs = Object.keys(attributes).filter(k => !(allowPrivateAttributes && k.startsWith('__'))); | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
const redundantAttrs = attrs.filter(a => !validatorAttrs.props[a]); | ||
@@ -546,2 +634,5 @@ const hasRedundantAttrs = redundantAttrs.length > 0; | ||
} | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/max-params | ||
function handleUnsupportedNodeAttributes(prevEntity, newEntity, invalidAttrs, redundantAttrs, errorCallback) { | ||
@@ -582,3 +673,6 @@ const attr = invalidAttrs.concat(redundantAttrs); | ||
} | ||
function handleNoAttibutesAllowedInSpecForMark(prevEntity, attributes) { | ||
function handleNoAttibutesAllowedInSpecForMark(prevEntity, | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
attributes) { | ||
const message = errorMessageFor('redundant attributes found', Object.keys(attributes).join(', ')); | ||
@@ -597,6 +691,9 @@ const errorCode = 'REDUNDANT_ATTRIBUTES'; | ||
} | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/max-params | ||
function wrapUnSupportedNodeAttributes(prevEntity, newEntity, invalidAttrs, errorCode, message, errorCallback) { | ||
let invalidValues = {}; | ||
const invalidValues = {}; | ||
// eslint-disable-next-line guard-for-in | ||
for (let invalidAttr in invalidAttrs) { | ||
for (const invalidAttr in invalidAttrs) { | ||
invalidValues[invalidAttrs[invalidAttr]] = prevEntity.attrs && prevEntity.attrs[invalidAttrs[invalidAttr]]; | ||
@@ -628,8 +725,14 @@ if (newEntity.attrs) { | ||
} | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/max-params | ||
function extraPropsValidationFor(validatorSpec, prevEntity, err, newEntity, type) { | ||
let result = { | ||
const result = { | ||
valid: true, | ||
entity: prevEntity | ||
}; | ||
const [requiredProps, redundantProps] = partitionObject(prevEntity, k => isDefined(validatorSpec.props[k])); | ||
const [requiredProps, redundantProps] = partitionObject(prevEntity, k => | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
isDefined(validatorSpec.props[k])); | ||
if (redundantProps.length) { | ||
@@ -651,4 +754,10 @@ if (mode === 'loose') { | ||
} | ||
function specBasedValidationFor(spec, typeOptions, prevEntity, err, newEntity, type, errorCallback, isMark) { | ||
let specBasedValidationResult = { | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/max-params | ||
function specBasedValidationFor(spec, | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
typeOptions, prevEntity, err, newEntity, type, errorCallback, isMark) { | ||
const specBasedValidationResult = { | ||
hasValidated: false | ||
@@ -743,2 +852,4 @@ }; | ||
if (prevEntity.content) { | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
const validateChildNode = (child, index) => { | ||
@@ -748,6 +859,11 @@ if (child === undefined) { | ||
} | ||
const validateChildMarks = (childEntity, marksValidationOutput, errorCallback, isLastValidationSpec, isParentTupleLike = false) => { | ||
const validateChildMarks = (childEntity, marksValidationOutput, errorCallback, isLastValidationSpec, isParentTupleLike = false | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/max-params | ||
) => { | ||
let marksAreValid = true; | ||
if (childEntity && childEntity.marks && marksValidationOutput) { | ||
const validMarks = marksValidationOutput.filter(mark => mark.valid); | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
const finalMarks = marksValidationOutput.map(mr => { | ||
@@ -758,3 +874,6 @@ if (mr.valid) { | ||
if (validMarks.length || isLastValidationSpec || isParentTupleLike || mr.errorCode === 'INVALID_TYPE' || mr.errorCode === 'INVALID_CONTENT' || mr.errorCode === 'REDUNDANT_ATTRIBUTES' || mr.errorCode === 'INVALID_ATTRIBUTES') { | ||
return unsupportedMarkContent(mr.errorCode, mr.originalMark, errorCallback, mr.message); | ||
return unsupportedMarkContent( | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
mr.errorCode, mr.originalMark, errorCallback, mr.message); | ||
} | ||
@@ -761,0 +880,0 @@ return; |
import { text } from '../nodes/text'; | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export function createTextNodes(nodes) { | ||
return nodes.map(createTextFromString); | ||
} | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export function createTextFromString(str) { | ||
return typeof str === 'string' ? text(str) : str; | ||
} |
@@ -0,1 +1,3 @@ | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export function isDuplicateMark(node, type) { | ||
@@ -9,4 +11,7 @@ if (node.marks && node.marks.some(function (mark) { | ||
} | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export function duplicateMarkError(node, type) { | ||
return "Mark with the same name '".concat(type, "' already exists on a node: ").concat(JSON.stringify(node)); | ||
} |
@@ -19,2 +19,4 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty"; | ||
type: node.type, | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
attrs: node.attrs ? scrubAttrs(node.type, node.attrs) : undefined, | ||
@@ -21,0 +23,0 @@ content: (_node$content = node.content) === null || _node$content === void 0 ? void 0 : _node$content.filter(function (c) { |
@@ -25,2 +25,5 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray"; | ||
} | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
var updatedNode = {}; | ||
@@ -27,0 +30,0 @@ Object.entries(node).forEach(function (_ref) { |
@@ -29,2 +29,4 @@ import _typeof from "@babel/runtime/helpers/typeof"; | ||
}; | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
var fromEntries = function fromEntries(iterable) { | ||
@@ -95,2 +97,4 @@ return _toConsumableArray(iterable).reduce(function (obj, _ref) { | ||
var scrubObj = function scrubObj(nodeType, attrsObj) { | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
var entries = Object.entries(attrsObj).map(function (_ref4) { | ||
@@ -105,2 +109,5 @@ var _BYPASS_ATTR_LIST$nod; | ||
}; | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export var scrubAttrs = function scrubAttrs(nodeType, attrs) { | ||
@@ -107,0 +114,0 @@ var offset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; |
@@ -10,4 +10,4 @@ // Disable no-re-export rule for entry point files | ||
export { transformInvalidMediaContent } from './transforms/invalid-media-content-transform'; | ||
export { transformNestedTablesIncomingDocument } from './transforms/nested-table-transform'; | ||
export { transformNestedTablesIncomingDocument, isNestedTableExtension } from './transforms/nested-table-transform'; | ||
export { transformNestedTableNodeOutgoingDocument } from './transforms/nested-table-transform'; | ||
export { NodeNestingTransformError } from './transforms/errors'; |
@@ -9,3 +9,3 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty"; | ||
NESTED_TABLE_EXTENSION_KEY = 'nested-table'; | ||
var isNestedTableExtension = function isNestedTableExtension(extensionNode) { | ||
export var isNestedTableExtension = function isNestedTableExtension(extensionNode) { | ||
var _extensionNode$attrs, _extensionNode$attrs2; | ||
@@ -12,0 +12,0 @@ return ((_extensionNode$attrs = extensionNode.attrs) === null || _extensionNode$attrs === void 0 ? void 0 : _extensionNode$attrs.extensionType) === NESTED_TABLE_EXTENSION_TYPE && ((_extensionNode$attrs2 = extensionNode.attrs) === null || _extensionNode$attrs2 === void 0 ? void 0 : _extensionNode$attrs2.extensionKey) === NESTED_TABLE_EXTENSION_KEY; |
@@ -66,2 +66,4 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray"; | ||
default: | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
return listItem([childNode]); | ||
@@ -68,0 +70,0 @@ } |
import { traverse } from './traverse'; | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export function map(adf, callback) { | ||
@@ -3,0 +6,0 @@ var result = []; |
import { traverse } from './traverse'; | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export function reduce(adf, callback, initial) { | ||
@@ -3,0 +6,0 @@ var result = initial; |
@@ -25,2 +25,5 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty"; | ||
} | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/max-params | ||
function traverseNode(adfNode, parent, visitors, index, depth) { | ||
@@ -27,0 +30,0 @@ var visitor = visitors[adfNode.type] || visitors['any']; |
@@ -22,3 +22,8 @@ import _typeof from "@babel/runtime/helpers/typeof"; | ||
}; | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export var copy = function copy(source, dest, key) { | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
dest[key] = source[key]; | ||
@@ -25,0 +30,0 @@ return dest; |
@@ -7,5 +7,10 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray"; | ||
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line import/no-namespace | ||
import * as specs from './specs'; | ||
import { copy, isBoolean, isDefined, isInteger, isNumber, isPlainObject, isString, makeArray } from './utils'; | ||
import { validatorFnMap } from './rules'; | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
function mapMarksItems(spec) { | ||
@@ -16,2 +21,4 @@ var fn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (x) { | ||
if (spec.props && spec.props.marks) { | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
var _ref = spec.props.marks, | ||
@@ -35,2 +42,5 @@ items = _ref.items, | ||
} | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
var partitionObject = function partitionObject(obj, predicate) { | ||
@@ -49,3 +59,7 @@ return Object.keys(obj).reduce(function (acc, key) { | ||
function createSpec(nodes, marks) { | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
return Object.keys(specs).reduce(function (newSpecs, k) { | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
var spec = _objectSpread({}, specs[k]); | ||
@@ -57,2 +71,4 @@ if (spec.props) { | ||
if (isString(spec.props.content)) { | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
spec.props.content = specs[spec.props.content]; | ||
@@ -85,3 +101,9 @@ } | ||
.map(function (item) { | ||
return isString(item) ? Array.isArray(specs[item]) ? specs[item] : [item] : item; | ||
return isString(item) ? | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
Array.isArray(specs[item]) ? | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
specs[item] : [item] : item; | ||
}) | ||
@@ -91,5 +113,12 @@ // [['emoji', 'hr', 'inline_code']] => [['emoji', 'hr', ['text', { marks: {} }]]] | ||
return item.map(function (subItem) { | ||
return Array.isArray(specs[subItem]) ? specs[subItem] : isString(subItem) ? subItem : | ||
// Now `NoMark` produces `items: []`, should be fixed in generator | ||
['text', subItem]; | ||
return ( | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
Array.isArray(specs[subItem]) ? | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
specs[subItem] : isString(subItem) ? subItem : | ||
// Now `NoMark` produces `items: []`, should be fixed in generator | ||
['text', subItem] | ||
); | ||
}) | ||
@@ -132,2 +161,5 @@ // Remove unsupported nodes & marks | ||
} | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
function getOptionsForType(type, list) { | ||
@@ -162,3 +194,7 @@ if (!list) { | ||
var _partitionObject = partitionObject(spec.props, function (key, subSpec) { | ||
return validateAttrs(subSpec, value[key]); | ||
return ( | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
validateAttrs(subSpec, value[key]) | ||
); | ||
}), | ||
@@ -185,3 +221,9 @@ _partitionObject2 = _slicedToArray(_partitionObject, 2), | ||
}; | ||
return isString(value) && (isDefined(spec.minLength) ? spec.minLength <= value.length : true) && (isDefined(spec.validatorFn) ? validatorFnPassed(spec.validatorFn) : true) && (spec.pattern ? new RegExp(spec.pattern).test(value) : true); | ||
return isString(value) && ( | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
isDefined(spec.minLength) ? spec.minLength <= value.length : true) && (isDefined(spec.validatorFn) ? validatorFnPassed(spec.validatorFn) : true) && ( | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line require-unicode-regexp | ||
spec.pattern ? new RegExp(spec.pattern).test(value) : true); | ||
case 'object': | ||
@@ -245,3 +287,6 @@ return isPlainObject(value); | ||
}; | ||
var unsupportedMarkContent = function unsupportedMarkContent(errorCode, mark, errorCallback, errorMessage) { | ||
var unsupportedMarkContent = function unsupportedMarkContent(errorCode, mark, errorCallback, errorMessage | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/max-params | ||
) { | ||
var message = errorMessage || errorMessageFor(mark.type, 'unsupported mark'); | ||
@@ -262,3 +307,6 @@ if (!errorCallback) { | ||
}; | ||
var unsupportedNodeAttributesContent = function unsupportedNodeAttributesContent(entity, errorCode, invalidAttributes, message, errorCallback) { | ||
var unsupportedNodeAttributesContent = function unsupportedNodeAttributesContent(entity, errorCode, invalidAttributes, message, errorCallback | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/max-params | ||
) { | ||
if (!errorCallback) { | ||
@@ -288,2 +336,4 @@ throw new Error(message); | ||
allowPrivateAttributes = _ref2$allowPrivateAtt === void 0 ? false : _ref2$allowPrivateAtt; | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/max-params | ||
var validate = function validate(entity, errorCallback, allowed, parentSpec) { | ||
@@ -339,2 +389,5 @@ var validationResult = validateNode(entity, errorCallback, allowed, parentSpec); | ||
return validate; | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/max-params | ||
function marksValidationFor(validator, entity, errorCallback, newEntity, err) { | ||
@@ -355,2 +408,4 @@ var validationResult; | ||
} | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
function validatorFor(spec, typeOptions) { | ||
@@ -361,2 +416,5 @@ return _objectSpread(_objectSpread(_objectSpread({}, spec), typeOptions), spec.props ? { | ||
} | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/max-params | ||
function marksAfterValidation(entity, errorCallback, marksSet, validator) { | ||
@@ -401,2 +459,4 @@ return entity.marks ? entity.marks.map(function (mark) { | ||
function allowedMarksFor(validator) { | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
var _ref3 = validator.props.marks, | ||
@@ -407,2 +467,5 @@ items = _ref3.items; | ||
} | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/max-params | ||
function marksForEntitySpecNotSupportingMarks(prevEntity, newEntity, errorCallback, err) { | ||
@@ -449,4 +512,9 @@ var errorCode = 'REDUNDANT_MARKS'; | ||
}; | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
if (validatorSpec.props.text) { | ||
if (isDefined(prevEntity.text) && !validateAttrs(validatorSpec.props.text, prevEntity.text)) { | ||
if (isDefined(prevEntity.text) && | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
!validateAttrs(validatorSpec.props.text, prevEntity.text)) { | ||
result = err('INVALID_TEXT', "'text' validation failed"); | ||
@@ -462,3 +530,7 @@ } | ||
}; | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
if (validatorSpec.props.content && prevEntity.content) { | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
var _content = validatorSpec.props.content, | ||
@@ -486,2 +558,4 @@ minItems = _content.minItems, | ||
var invalidAttrs = []; | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
var validatorAttrs = {}; | ||
@@ -499,2 +573,4 @@ if (validatorSpec.props && validatorSpec.props.attrs) { | ||
var _partitionObject3 = partitionObject(attrOption.props, function (key, spec) { | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
var valueToValidate = prevEntity.attrs[key]; | ||
@@ -506,2 +582,4 @@ return validateAttrs(spec, valueToValidate); | ||
} | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
validatorAttrs = attrOption; | ||
@@ -518,2 +596,5 @@ if (!invalidAttrs.length) { | ||
} | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/max-params | ||
function attributesValidationFor(validatorSpec, prevEntity, newEntity, isMark, errorCallback) { | ||
@@ -545,3 +626,6 @@ var validatorSpecAllowsAttributes = validatorSpec.props && validatorSpec.props.attrs; | ||
} | ||
function validateAttributes(validatorSpec, prevEntity, attributes) { | ||
function validateAttributes(validatorSpec, prevEntity, | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
attributes) { | ||
var invalidAttributesResult = invalidAttributesFor(validatorSpec, prevEntity); | ||
@@ -553,2 +637,5 @@ var invalidAttrs = invalidAttributesResult.invalidAttrs; | ||
}); | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
var redundantAttrs = attrs.filter(function (a) { | ||
@@ -565,2 +652,5 @@ return !validatorAttrs.props[a]; | ||
} | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/max-params | ||
function handleUnsupportedNodeAttributes(prevEntity, newEntity, invalidAttrs, redundantAttrs, errorCallback) { | ||
@@ -601,3 +691,6 @@ var attr = invalidAttrs.concat(redundantAttrs); | ||
} | ||
function handleNoAttibutesAllowedInSpecForMark(prevEntity, attributes) { | ||
function handleNoAttibutesAllowedInSpecForMark(prevEntity, | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
attributes) { | ||
var message = errorMessageFor('redundant attributes found', Object.keys(attributes).join(', ')); | ||
@@ -616,2 +709,5 @@ var errorCode = 'REDUNDANT_ATTRIBUTES'; | ||
} | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/max-params | ||
function wrapUnSupportedNodeAttributes(prevEntity, newEntity, invalidAttrs, errorCode, message, errorCallback) { | ||
@@ -647,2 +743,5 @@ var invalidValues = {}; | ||
} | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/max-params | ||
function extraPropsValidationFor(validatorSpec, prevEntity, err, newEntity, type) { | ||
@@ -654,3 +753,7 @@ var result = { | ||
var _partitionObject5 = partitionObject(prevEntity, function (k) { | ||
return isDefined(validatorSpec.props[k]); | ||
return ( | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
isDefined(validatorSpec.props[k]) | ||
); | ||
}), | ||
@@ -678,3 +781,9 @@ _partitionObject6 = _slicedToArray(_partitionObject5, 2), | ||
} | ||
function specBasedValidationFor(spec, typeOptions, prevEntity, err, newEntity, type, errorCallback, isMark) { | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/max-params | ||
function specBasedValidationFor(spec, | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
typeOptions, prevEntity, err, newEntity, type, errorCallback, isMark) { | ||
var specBasedValidationResult = { | ||
@@ -772,2 +881,4 @@ hasValidated: false | ||
if (prevEntity.content) { | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
var validateChildNode = function validateChildNode(child, index) { | ||
@@ -784,2 +895,4 @@ if (child === undefined) { | ||
}); | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
var finalMarks = marksValidationOutput.map(function (mr) { | ||
@@ -790,3 +903,6 @@ if (mr.valid) { | ||
if (validMarks.length || isLastValidationSpec || isParentTupleLike || mr.errorCode === 'INVALID_TYPE' || mr.errorCode === 'INVALID_CONTENT' || mr.errorCode === 'REDUNDANT_ATTRIBUTES' || mr.errorCode === 'INVALID_ATTRIBUTES') { | ||
return unsupportedMarkContent(mr.errorCode, mr.originalMark, errorCallback, mr.message); | ||
return unsupportedMarkContent( | ||
// Ignored via go/ees005 | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
mr.errorCode, mr.originalMark, errorCallback, mr.message); | ||
} | ||
@@ -793,0 +909,0 @@ return; |
@@ -7,4 +7,4 @@ export { transformMediaLinkMarks } from './transforms/media-link-transform'; | ||
export { transformInvalidMediaContent } from './transforms/invalid-media-content-transform'; | ||
export { transformNestedTablesIncomingDocument } from './transforms/nested-table-transform'; | ||
export { transformNestedTablesIncomingDocument, isNestedTableExtension } from './transforms/nested-table-transform'; | ||
export { transformNestedTableNodeOutgoingDocument } from './transforms/nested-table-transform'; | ||
export { NodeNestingTransformError } from './transforms/errors'; |
import type { ADFEntity } from '../types'; | ||
export declare const isNestedTableExtension: (extensionNode: ADFEntity) => boolean; | ||
export declare const transformNestedTablesIncomingDocument: (adf: ADFEntity) => { | ||
@@ -3,0 +4,0 @@ transformedAdf: ADFEntity; |
@@ -7,4 +7,4 @@ export { transformMediaLinkMarks } from './transforms/media-link-transform'; | ||
export { transformInvalidMediaContent } from './transforms/invalid-media-content-transform'; | ||
export { transformNestedTablesIncomingDocument } from './transforms/nested-table-transform'; | ||
export { transformNestedTablesIncomingDocument, isNestedTableExtension } from './transforms/nested-table-transform'; | ||
export { transformNestedTableNodeOutgoingDocument } from './transforms/nested-table-transform'; | ||
export { NodeNestingTransformError } from './transforms/errors'; |
import type { ADFEntity } from '../types'; | ||
export declare const isNestedTableExtension: (extensionNode: ADFEntity) => boolean; | ||
export declare const transformNestedTablesIncomingDocument: (adf: ADFEntity) => { | ||
@@ -3,0 +4,0 @@ transformedAdf: ADFEntity; |
{ | ||
"name": "@atlaskit/adf-utils", | ||
"version": "19.14.1", | ||
"version": "19.15.0", | ||
"description": "Set of utilities to traverse, modify and create ADF documents.", | ||
@@ -5,0 +5,0 @@ "publishConfig": { |
{ | ||
"extends": "../../../tsconfig.json", | ||
"compilerOptions": { | ||
"baseUrl": "./" | ||
}, | ||
@@ -6,0 +5,0 @@ "include": [ |
Sorry, the diff of this file is too big to display
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
516186
10398
0