@backland/schema
Version:
TypeScript schema declaration and validation library with static type inference
29 lines (28 loc) • 1.02 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 getInnerGraphTypeId(input) {
if (!(input && typeof input === 'object')) {
return undefined;
}
let id;
let iterating = input;
while ('definition' in iterating) {
id = getInnerGraphTypeId(iterating.definition) || id;
iterating = iterating.definition;
}
if (id) return id;
const inputId = (0, _utils.getByPath)(input, 'id');
const inputTypeId = (0, _utils.getByPath)(input, 'type.id');
const inputMetaDefId = (0, _utils.getByPath)(input, `def.${_MetaFieldField.objectMetaFieldKey}.def.id`);
id = inputMetaDefId || inputTypeId || inputId;
return id || undefined;
}
const GraphTypeNameRegex = /^[_a-zA-Z][_a-zA-Z0-9]$/;
exports.GraphTypeNameRegex = GraphTypeNameRegex;
//# sourceMappingURL=getInnerGraphTypeId.js.map