@backland/schema
Version:
TypeScript schema declaration and validation library with static type inference
30 lines (29 loc) • 1.36 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.GraphTypeNameRegex = void 0;
exports.getInnerGraphTypeId = getInnerGraphTypeId;
var _utils = require("@backland/utils");
var _MetaFieldField = require("../fields/MetaFieldField");
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
function getInnerGraphTypeId(input) {
if (!(input && _typeof(input) === 'object')) {
return undefined;
}
var id;
var iterating = input;
while ('definition' in iterating) {
id = getInnerGraphTypeId(iterating.definition) || id;
iterating = iterating.definition;
}
if (id) return id;
var inputId = (0, _utils.getByPath)(input, 'id');
var inputTypeId = (0, _utils.getByPath)(input, 'type.id');
var inputMetaDefId = (0, _utils.getByPath)(input, "def.".concat(_MetaFieldField.objectMetaFieldKey, ".def.id"));
id = inputMetaDefId || inputTypeId || inputId;
return id || undefined;
}
var GraphTypeNameRegex = /^[_a-zA-Z][_a-zA-Z0-9]$/;
exports.GraphTypeNameRegex = GraphTypeNameRegex;
//# sourceMappingURL=getInnerGraphTypeId.js.map