UNPKG

@autorest/codemodel

Version:
76 lines 2.73 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ObjectSchema = exports.GroupSchema = exports.GroupProperty = exports.Discriminator = exports.Relations = void 0; exports.isObjectSchema = isObjectSchema; exports.getAllProperties = getAllProperties; exports.getAllParentProperties = getAllParentProperties; const property_1 = require("../property"); const schema_1 = require("../schema"); const schema_type_1 = require("../schema-type"); class Relations { constructor() { this.immediate = []; this.all = []; } } exports.Relations = Relations; class Discriminator { constructor(property) { this.property = property; this.immediate = {}; this.all = {}; } } exports.Discriminator = Discriminator; class GroupProperty extends property_1.Property { constructor(name, description, schema, initializer) { super(name, description, schema); this.originalParameter = new Array(); this.applyWithExclusions(["schema"], initializer); } } exports.GroupProperty = GroupProperty; class GroupSchema extends schema_1.Schema { constructor(name, description, objectInitializer) { super(name, description, schema_type_1.SchemaType.Group); this.apply(objectInitializer); } add(property) { (this.properties = this.properties || []).push(property); return property; } } exports.GroupSchema = GroupSchema; class ObjectSchema extends schema_1.Schema { constructor(name, description, objectInitializer) { super(name, description, schema_type_1.SchemaType.Object); this.apply(objectInitializer); } addProperty(property) { (this.properties = this.properties || []).push(property); return property; } } exports.ObjectSchema = ObjectSchema; function isObjectSchema(schema) { return schema.type === schema_type_1.SchemaType.Object; } // gs01: todo/Note -- these two need to be commented out to run the schema generation script function* getAllProperties(schema) { var _a, _b, _c; for (const parent of (_b = (_a = schema.parents) === null || _a === void 0 ? void 0 : _a.immediate) !== null && _b !== void 0 ? _b : []) { if (isObjectSchema(parent)) { yield* getAllProperties(parent); } } yield* (_c = schema.properties) !== null && _c !== void 0 ? _c : []; } function* getAllParentProperties(schema) { var _a, _b; for (const parent of (_b = (_a = schema.parents) === null || _a === void 0 ? void 0 : _a.immediate) !== null && _b !== void 0 ? _b : []) { if (isObjectSchema(parent)) { yield* getAllProperties(parent); } } } //# sourceMappingURL=object.js.map