@atlaskit/adf-schema-generator
Advanced tools
Comparing version 1.18.2 to 1.19.0
# @atlaskit/adf-schema-generator | ||
## 1.18.2 | ||
## 1.19.0 | ||
### Patch Changes | ||
### Minor Changes | ||
- 359dcc5: Added additionalProperties for object items in allOf as per full JSON schema | ||
- ffa8133: Properly support allowUnsupportedBlock and allowUnsupportedInline |
@@ -32,8 +32,14 @@ "use strict"; | ||
var json = {}; | ||
if (node.getType()) { | ||
json['props'] = { | ||
type: { | ||
type: 'enum', | ||
values: [node.getType()] | ||
} | ||
json['props'] = { | ||
type: { | ||
type: 'enum', | ||
values: [node.getType()] | ||
} | ||
}; | ||
// Text is a special node in PM and it has a text property | ||
if (node.getType() === 'text') { | ||
json['props'].text = { | ||
type: 'string', | ||
minLength: 1 | ||
}; | ||
@@ -73,5 +79,2 @@ } | ||
}(function (node, content, cycle) { | ||
if (node.isIgnored(_transformerNames.ValidatorSpecTransformerName)) { | ||
return; | ||
} | ||
var processedNode = { | ||
@@ -97,3 +100,5 @@ node: node, | ||
marks: child.marks, | ||
minItems: 1 | ||
minItems: 1, | ||
hasUnsupportedBlock: child.hasUnsupportedBlock, | ||
hasUnsupportedInline: child.hasUnsupportedInline | ||
}; | ||
@@ -106,3 +111,5 @@ }, | ||
minItems: 0, | ||
optional: true | ||
optional: true, | ||
hasUnsupportedBlock: child.hasUnsupportedBlock, | ||
hasUnsupportedInline: child.hasUnsupportedInline | ||
}; | ||
@@ -115,3 +122,5 @@ }, | ||
minItems: item.min, | ||
maxItems: item.max | ||
maxItems: item.max, | ||
hasUnsupportedBlock: child.hasUnsupportedBlock, | ||
hasUnsupportedInline: child.hasUnsupportedInline | ||
}; | ||
@@ -122,2 +131,4 @@ }, | ||
var contentTypes = []; | ||
var hasUnsupportedInline = false; | ||
var hasUnsupportedBlock = false; | ||
var _iterator = _createForOfIteratorHelper(children), | ||
@@ -143,2 +154,11 @@ _step; | ||
} | ||
if (member.node.isIgnored(_transformerNames.ValidatorSpecTransformerName)) { | ||
if (member.node.getType() === 'unsupportedInline') { | ||
hasUnsupportedInline = true; | ||
} | ||
if (member.node.getType() === 'unsupportedBlock') { | ||
hasUnsupportedBlock = true; | ||
} | ||
continue; | ||
} | ||
var _iterator3 = _createForOfIteratorHelper((_member$node$getSpec$ = member.node.getSpec().marks) !== null && _member$node$getSpec$ !== void 0 ? _member$node$getSpec$ : []), | ||
@@ -166,2 +186,11 @@ _step3; | ||
var _child$node$getSpec$m; | ||
if (child.node.isIgnored(_transformerNames.ValidatorSpecTransformerName)) { | ||
if (child.node.getType() === 'unsupportedInline') { | ||
hasUnsupportedInline = true; | ||
} | ||
if (child.node.getType() === 'unsupportedBlock') { | ||
hasUnsupportedBlock = true; | ||
} | ||
continue; | ||
} | ||
contentTypes.push(child.node.getName()); | ||
@@ -192,3 +221,5 @@ var _iterator4 = _createForOfIteratorHelper((_child$node$getSpec$m = child.node.getSpec().marks) !== null && _child$node$getSpec$m !== void 0 ? _child$node$getSpec$m : []), | ||
contentTypes: contentTypes, | ||
minItems: 0 | ||
minItems: 0, | ||
hasUnsupportedInline: hasUnsupportedInline, | ||
hasUnsupportedBlock: hasUnsupportedBlock | ||
}; | ||
@@ -195,0 +226,0 @@ } |
@@ -8,3 +8,3 @@ "use strict"; | ||
function buildContent(content) { | ||
var _content$, _content$2, _content$3, _content$5; | ||
var _content$, _content$2, _content$3, _content$5, _content$7, _content$8; | ||
var contentTypes = (_content$ = content[0]) === null || _content$ === void 0 ? void 0 : _content$.contentTypes; | ||
@@ -30,5 +30,8 @@ var type = 'array'; // splitting out type in case we need to add more types later | ||
} | ||
if (checkIfUnsupportedInline(contentTypes)) { | ||
if ((_content$7 = content[0]) !== null && _content$7 !== void 0 && _content$7.hasUnsupportedInline) { | ||
returnContent['allowUnsupportedInline'] = true; | ||
} | ||
if ((_content$8 = content[0]) !== null && _content$8 !== void 0 && _content$8.hasUnsupportedBlock) { | ||
returnContent['allowUnsupportedBlock'] = true; | ||
} | ||
return returnContent; | ||
@@ -48,7 +51,2 @@ } | ||
} | ||
function checkIfUnsupportedInline(content) { | ||
return content.some(function (item) { | ||
return item === null || item === void 0 ? void 0 : item.includes('inline'); | ||
}); | ||
} | ||
@@ -60,10 +58,10 @@ // currently this function doesn't do much but | ||
function buildMinItems(content) { | ||
var _content$7, _content$8, _content$9; | ||
if (((_content$7 = content[0]) === null || _content$7 === void 0 ? void 0 : _content$7.minItems) === 0) { | ||
var _content$9, _content$10, _content$11; | ||
if (((_content$9 = content[0]) === null || _content$9 === void 0 ? void 0 : _content$9.minItems) === 0) { | ||
return 0; | ||
} else if (((_content$8 = content[0]) === null || _content$8 === void 0 ? void 0 : _content$8.minItems) === 1) { | ||
} else if (((_content$10 = content[0]) === null || _content$10 === void 0 ? void 0 : _content$10.minItems) === 1) { | ||
return 1; | ||
} else if (((_content$9 = content[0]) === null || _content$9 === void 0 ? void 0 : _content$9.minItems) === undefined) { | ||
} else if (((_content$11 = content[0]) === null || _content$11 === void 0 ? void 0 : _content$11.minItems) === undefined) { | ||
return undefined; | ||
} | ||
} |
@@ -22,8 +22,14 @@ import { traverse } from '../../traverse'; | ||
const json = {}; | ||
if (node.getType()) { | ||
json['props'] = { | ||
type: { | ||
type: 'enum', | ||
values: [node.getType()] | ||
} | ||
json['props'] = { | ||
type: { | ||
type: 'enum', | ||
values: [node.getType()] | ||
} | ||
}; | ||
// Text is a special node in PM and it has a text property | ||
if (node.getType() === 'text') { | ||
json['props'].text = { | ||
type: 'string', | ||
minLength: 1 | ||
}; | ||
@@ -53,5 +59,2 @@ } | ||
node: (node, content, cycle) => { | ||
if (node.isIgnored(ValidatorSpecTransformerName)) { | ||
return; | ||
} | ||
const processedNode = { | ||
@@ -77,3 +80,5 @@ node, | ||
marks: child.marks, | ||
minItems: 1 | ||
minItems: 1, | ||
hasUnsupportedBlock: child.hasUnsupportedBlock, | ||
hasUnsupportedInline: child.hasUnsupportedInline | ||
}; | ||
@@ -86,3 +91,5 @@ }, | ||
minItems: 0, | ||
optional: true | ||
optional: true, | ||
hasUnsupportedBlock: child.hasUnsupportedBlock, | ||
hasUnsupportedInline: child.hasUnsupportedInline | ||
}; | ||
@@ -95,3 +102,5 @@ }, | ||
minItems: item.min, | ||
maxItems: item.max | ||
maxItems: item.max, | ||
hasUnsupportedBlock: child.hasUnsupportedBlock, | ||
hasUnsupportedInline: child.hasUnsupportedInline | ||
}; | ||
@@ -102,2 +111,4 @@ }, | ||
const contentTypes = []; | ||
let hasUnsupportedInline = false; | ||
let hasUnsupportedBlock = false; | ||
for (const child of children) { | ||
@@ -114,2 +125,11 @@ if (isGroupReturnValue(child)) { | ||
} | ||
if (member.node.isIgnored(ValidatorSpecTransformerName)) { | ||
if (member.node.getType() === 'unsupportedInline') { | ||
hasUnsupportedInline = true; | ||
} | ||
if (member.node.getType() === 'unsupportedBlock') { | ||
hasUnsupportedBlock = true; | ||
} | ||
continue; | ||
} | ||
for (const mark of (_member$node$getSpec$ = member.node.getSpec().marks) !== null && _member$node$getSpec$ !== void 0 ? _member$node$getSpec$ : []) { | ||
@@ -123,2 +143,11 @@ var _member$node$getSpec$; | ||
} else if (isNodeReturnValue(child)) { | ||
if (child.node.isIgnored(ValidatorSpecTransformerName)) { | ||
if (child.node.getType() === 'unsupportedInline') { | ||
hasUnsupportedInline = true; | ||
} | ||
if (child.node.getType() === 'unsupportedBlock') { | ||
hasUnsupportedBlock = true; | ||
} | ||
continue; | ||
} | ||
contentTypes.push(child.node.getName()); | ||
@@ -136,3 +165,5 @@ for (const mark of (_child$node$getSpec$m = child.node.getSpec().marks) !== null && _child$node$getSpec$m !== void 0 ? _child$node$getSpec$m : []) { | ||
contentTypes, | ||
minItems: 0 | ||
minItems: 0, | ||
hasUnsupportedInline, | ||
hasUnsupportedBlock | ||
}; | ||
@@ -139,0 +170,0 @@ } |
export function buildContent(content) { | ||
var _content$, _content$2, _content$3, _content$5; | ||
var _content$, _content$2, _content$3, _content$5, _content$7, _content$8; | ||
const contentTypes = (_content$ = content[0]) === null || _content$ === void 0 ? void 0 : _content$.contentTypes; | ||
@@ -23,5 +23,8 @@ const type = 'array'; // splitting out type in case we need to add more types later | ||
} | ||
if (checkIfUnsupportedInline(contentTypes)) { | ||
if ((_content$7 = content[0]) !== null && _content$7 !== void 0 && _content$7.hasUnsupportedInline) { | ||
returnContent['allowUnsupportedInline'] = true; | ||
} | ||
if ((_content$8 = content[0]) !== null && _content$8 !== void 0 && _content$8.hasUnsupportedBlock) { | ||
returnContent['allowUnsupportedBlock'] = true; | ||
} | ||
return returnContent; | ||
@@ -41,5 +44,2 @@ } | ||
} | ||
function checkIfUnsupportedInline(content) { | ||
return content.some(item => item === null || item === void 0 ? void 0 : item.includes('inline')); | ||
} | ||
@@ -51,10 +51,10 @@ // currently this function doesn't do much but | ||
function buildMinItems(content) { | ||
var _content$7, _content$8, _content$9; | ||
if (((_content$7 = content[0]) === null || _content$7 === void 0 ? void 0 : _content$7.minItems) === 0) { | ||
var _content$9, _content$10, _content$11; | ||
if (((_content$9 = content[0]) === null || _content$9 === void 0 ? void 0 : _content$9.minItems) === 0) { | ||
return 0; | ||
} else if (((_content$8 = content[0]) === null || _content$8 === void 0 ? void 0 : _content$8.minItems) === 1) { | ||
} else if (((_content$10 = content[0]) === null || _content$10 === void 0 ? void 0 : _content$10.minItems) === 1) { | ||
return 1; | ||
} else if (((_content$9 = content[0]) === null || _content$9 === void 0 ? void 0 : _content$9.minItems) === undefined) { | ||
} else if (((_content$11 = content[0]) === null || _content$11 === void 0 ? void 0 : _content$11.minItems) === undefined) { | ||
return undefined; | ||
} | ||
} |
@@ -25,8 +25,14 @@ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } | ||
var json = {}; | ||
if (node.getType()) { | ||
json['props'] = { | ||
type: { | ||
type: 'enum', | ||
values: [node.getType()] | ||
} | ||
json['props'] = { | ||
type: { | ||
type: 'enum', | ||
values: [node.getType()] | ||
} | ||
}; | ||
// Text is a special node in PM and it has a text property | ||
if (node.getType() === 'text') { | ||
json['props'].text = { | ||
type: 'string', | ||
minLength: 1 | ||
}; | ||
@@ -66,5 +72,2 @@ } | ||
}(function (node, content, cycle) { | ||
if (node.isIgnored(ValidatorSpecTransformerName)) { | ||
return; | ||
} | ||
var processedNode = { | ||
@@ -90,3 +93,5 @@ node: node, | ||
marks: child.marks, | ||
minItems: 1 | ||
minItems: 1, | ||
hasUnsupportedBlock: child.hasUnsupportedBlock, | ||
hasUnsupportedInline: child.hasUnsupportedInline | ||
}; | ||
@@ -99,3 +104,5 @@ }, | ||
minItems: 0, | ||
optional: true | ||
optional: true, | ||
hasUnsupportedBlock: child.hasUnsupportedBlock, | ||
hasUnsupportedInline: child.hasUnsupportedInline | ||
}; | ||
@@ -108,3 +115,5 @@ }, | ||
minItems: item.min, | ||
maxItems: item.max | ||
maxItems: item.max, | ||
hasUnsupportedBlock: child.hasUnsupportedBlock, | ||
hasUnsupportedInline: child.hasUnsupportedInline | ||
}; | ||
@@ -115,2 +124,4 @@ }, | ||
var contentTypes = []; | ||
var hasUnsupportedInline = false; | ||
var hasUnsupportedBlock = false; | ||
var _iterator = _createForOfIteratorHelper(children), | ||
@@ -136,2 +147,11 @@ _step; | ||
} | ||
if (member.node.isIgnored(ValidatorSpecTransformerName)) { | ||
if (member.node.getType() === 'unsupportedInline') { | ||
hasUnsupportedInline = true; | ||
} | ||
if (member.node.getType() === 'unsupportedBlock') { | ||
hasUnsupportedBlock = true; | ||
} | ||
continue; | ||
} | ||
var _iterator3 = _createForOfIteratorHelper((_member$node$getSpec$ = member.node.getSpec().marks) !== null && _member$node$getSpec$ !== void 0 ? _member$node$getSpec$ : []), | ||
@@ -159,2 +179,11 @@ _step3; | ||
var _child$node$getSpec$m; | ||
if (child.node.isIgnored(ValidatorSpecTransformerName)) { | ||
if (child.node.getType() === 'unsupportedInline') { | ||
hasUnsupportedInline = true; | ||
} | ||
if (child.node.getType() === 'unsupportedBlock') { | ||
hasUnsupportedBlock = true; | ||
} | ||
continue; | ||
} | ||
contentTypes.push(child.node.getName()); | ||
@@ -185,3 +214,5 @@ var _iterator4 = _createForOfIteratorHelper((_child$node$getSpec$m = child.node.getSpec().marks) !== null && _child$node$getSpec$m !== void 0 ? _child$node$getSpec$m : []), | ||
contentTypes: contentTypes, | ||
minItems: 0 | ||
minItems: 0, | ||
hasUnsupportedInline: hasUnsupportedInline, | ||
hasUnsupportedBlock: hasUnsupportedBlock | ||
}; | ||
@@ -188,0 +219,0 @@ } |
export function buildContent(content) { | ||
var _content$, _content$2, _content$3, _content$5; | ||
var _content$, _content$2, _content$3, _content$5, _content$7, _content$8; | ||
var contentTypes = (_content$ = content[0]) === null || _content$ === void 0 ? void 0 : _content$.contentTypes; | ||
@@ -23,5 +23,8 @@ var type = 'array'; // splitting out type in case we need to add more types later | ||
} | ||
if (checkIfUnsupportedInline(contentTypes)) { | ||
if ((_content$7 = content[0]) !== null && _content$7 !== void 0 && _content$7.hasUnsupportedInline) { | ||
returnContent['allowUnsupportedInline'] = true; | ||
} | ||
if ((_content$8 = content[0]) !== null && _content$8 !== void 0 && _content$8.hasUnsupportedBlock) { | ||
returnContent['allowUnsupportedBlock'] = true; | ||
} | ||
return returnContent; | ||
@@ -41,7 +44,2 @@ } | ||
} | ||
function checkIfUnsupportedInline(content) { | ||
return content.some(function (item) { | ||
return item === null || item === void 0 ? void 0 : item.includes('inline'); | ||
}); | ||
} | ||
@@ -53,10 +51,10 @@ // currently this function doesn't do much but | ||
function buildMinItems(content) { | ||
var _content$7, _content$8, _content$9; | ||
if (((_content$7 = content[0]) === null || _content$7 === void 0 ? void 0 : _content$7.minItems) === 0) { | ||
var _content$9, _content$10, _content$11; | ||
if (((_content$9 = content[0]) === null || _content$9 === void 0 ? void 0 : _content$9.minItems) === 0) { | ||
return 0; | ||
} else if (((_content$8 = content[0]) === null || _content$8 === void 0 ? void 0 : _content$8.minItems) === 1) { | ||
} else if (((_content$10 = content[0]) === null || _content$10 === void 0 ? void 0 : _content$10.minItems) === 1) { | ||
return 1; | ||
} else if (((_content$9 = content[0]) === null || _content$9 === void 0 ? void 0 : _content$9.minItems) === undefined) { | ||
} else if (((_content$11 = content[0]) === null || _content$11 === void 0 ? void 0 : _content$11.minItems) === undefined) { | ||
return undefined; | ||
} | ||
} |
@@ -17,3 +17,4 @@ import { ADFNode } from '../../adfNode'; | ||
optional?: boolean; | ||
unsupportedInline?: boolean; | ||
hasUnsupportedInline?: boolean; | ||
hasUnsupportedBlock?: boolean; | ||
}; | ||
@@ -20,0 +21,0 @@ export type MarksVisitorReturnType = { |
{ | ||
"name": "@atlaskit/adf-schema-generator", | ||
"version": "1.18.2", | ||
"version": "1.19.0", | ||
"description": "Generates ADF and PM schemas", | ||
@@ -5,0 +5,0 @@ "repository": "https://bitbucket.org/atlassian/adf-schema", |
@@ -26,3 +26,4 @@ import { ADFNode } from '../../adfNode'; | ||
optional?: boolean; | ||
unsupportedInline?: boolean; | ||
hasUnsupportedInline?: boolean; | ||
hasUnsupportedBlock?: boolean; | ||
}; | ||
@@ -68,6 +69,9 @@ | ||
if (node.getType()) { | ||
json['props'] = { | ||
type: { type: 'enum', values: [node.getType()] }, | ||
}; | ||
json['props'] = { | ||
type: { type: 'enum', values: [node.getType()] }, | ||
}; | ||
// Text is a special node in PM and it has a text property | ||
if (node.getType() === 'text') { | ||
json['props'].text = { type: 'string', minLength: 1 }; | ||
} | ||
@@ -113,6 +117,2 @@ | ||
node: (node, content, cycle) => { | ||
if (node.isIgnored(ValidatorSpecTransformerName)) { | ||
return; | ||
} | ||
const processedNode: NodeVisitorReturnType = { | ||
@@ -140,2 +140,4 @@ node, | ||
minItems: 1, | ||
hasUnsupportedBlock: child.hasUnsupportedBlock, | ||
hasUnsupportedInline: child.hasUnsupportedInline, | ||
}; | ||
@@ -149,2 +151,4 @@ }, | ||
optional: true, | ||
hasUnsupportedBlock: child.hasUnsupportedBlock, | ||
hasUnsupportedInline: child.hasUnsupportedInline, | ||
}; | ||
@@ -158,2 +162,4 @@ }, | ||
maxItems: item.max, | ||
hasUnsupportedBlock: child.hasUnsupportedBlock, | ||
hasUnsupportedInline: child.hasUnsupportedInline, | ||
}; | ||
@@ -164,2 +170,4 @@ }, | ||
const contentTypes: Array<string> = []; | ||
let hasUnsupportedInline = false; | ||
let hasUnsupportedBlock = false; | ||
@@ -178,2 +186,12 @@ for (const child of children) { | ||
if (member.node.isIgnored(ValidatorSpecTransformerName)) { | ||
if (member.node.getType() === 'unsupportedInline') { | ||
hasUnsupportedInline = true; | ||
} | ||
if (member.node.getType() === 'unsupportedBlock') { | ||
hasUnsupportedBlock = true; | ||
} | ||
continue; | ||
} | ||
for (const mark of member.node.getSpec().marks ?? []) { | ||
@@ -186,2 +204,11 @@ if (!mark.isIgnored(ValidatorSpecTransformerName)) { | ||
} else if (isNodeReturnValue(child)) { | ||
if (child.node.isIgnored(ValidatorSpecTransformerName)) { | ||
if (child.node.getType() === 'unsupportedInline') { | ||
hasUnsupportedInline = true; | ||
} | ||
if (child.node.getType() === 'unsupportedBlock') { | ||
hasUnsupportedBlock = true; | ||
} | ||
continue; | ||
} | ||
contentTypes.push(child.node.getName()); | ||
@@ -200,2 +227,4 @@ for (const mark of child.node.getSpec().marks ?? []) { | ||
minItems: 0, | ||
hasUnsupportedInline, | ||
hasUnsupportedBlock, | ||
}; | ||
@@ -202,0 +231,0 @@ }, |
@@ -24,5 +24,8 @@ import { ContentVisitorReturnType } from './adfToValidatorSpec'; | ||
} | ||
if (checkIfUnsupportedInline(contentTypes)) { | ||
if (content[0]?.hasUnsupportedInline) { | ||
returnContent['allowUnsupportedInline'] = true; | ||
} | ||
if (content[0]?.hasUnsupportedBlock) { | ||
returnContent['allowUnsupportedBlock'] = true; | ||
} | ||
return returnContent; | ||
@@ -43,6 +46,2 @@ } | ||
function checkIfUnsupportedInline(content: Array<string>) { | ||
return content.some((item) => item?.includes('inline')); | ||
} | ||
// currently this function doesn't do much but | ||
@@ -49,0 +48,0 @@ // it's here in case we need to add more logic |
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
422933
10839