@api-client/core 0.11.6 → 0.11.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -45,7 +45,7 @@ export interface IApiAssociationShape {
45
45
  * - anyOf - To validate against `anyOf`, the given data must be valid against
46
46
  * any (one or more) of the given sub-schemas. When generation a schema, it takes first union schema.
47
47
  * - oneOf - To validate against `oneOf`, the given data must be valid against
48
- * exactly one of the given sub-schemas. It behaves the same as `oneOf` when generating a schema
48
+ * exactly one of the given sub-schemas. It behaves the same as `anyOf` when generating a schema
49
49
  * - not - The `not` keyword declares that an instance validates if it doesn’t
50
50
  * validate against the given sub-schema. It has no use when generating a schema.
51
51
  *
@@ -1 +1 @@
1
- {"version":3,"file":"Shapes.js","sourceRoot":"","sources":["../../../../src/amf/definitions/Shapes.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,cAAc,EACd,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,cAAc,EACd,yBAAyB,GAC1B,MAAM,gBAAgB,CAAA;AAmFvB,MAAM,UAAU,aAAa,CAAC,EAAU;IACtC,OAAO;QACL,EAAE,EAAE,kBAAkB,EAAE,EAAE;QAC1B,KAAK,EAAE,yBAAyB;QAChC,sBAAsB,EAAE,EAAE;KAC3B,CAAA;AACH,CAAC;AAED,MAAM,UAAU,KAAK,CAAC,EAAU;IAC9B,MAAM,MAAM,GAAc;QACxB,EAAE;QACF,KAAK,EAAE,EAAE;QACT,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE,EAAE;QACZ,EAAE,EAAE,EAAE;QACN,GAAG,EAAE,EAAE;QACP,IAAI,EAAE,EAAE;QACR,sBAAsB,EAAE,EAAE;KAC3B,CAAA;IACD,OAAO,MAAM,CAAA;AACf,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,EAAU;IACjC,MAAM,MAAM,GAAiB;QAC3B,GAAG,KAAK,CAAC,E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,CAAC,EAAU;IACnC,MAAM,MAAM,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAA;IAC3B,MAAM,CAAC,EAAE,GAAG,eAAe,EAAE,EAAE,CAAA;IAC/B,MAAM,CAAC,KAAK,GAAG,cAAc,CAAA;IAC7B,OAAO,MAAM,CAAA;AACf,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,EAAU;IACnC,MAAM,MAAM,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAA;IAC3B,MAAM,CAAC,EAAE,GAAG,eAAe,EAAE,EAAE,CAAA;IAC/B,MAAM,CAAC,KAAK,GAAG,cAAc,CAAA;IAC7B,OAAO,EAAE,GAAG,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,CAAA;AACjC,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,EAAU;IACtC,MAAM,MAAM,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAA;IAC3B,MAAM,CAAC,KAAK,GAAG,iBAAiB,CAAA;IAChC,OAAO,MAAM,CAAA;AACf,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,EAAU,EAAE,OAAgB;IACzD,MAAM,MAAM,GAAuB;QACjC,GAAG,KAAK,CAAC,EAAE,CAAC;QACZ,EAAE,EAAE,aAAa,EAAE,EAAE;QACrB,KAAK,EAAE,kBAAkB;QACzB,QAAQ,EAAE,OAAO,IAAI,EAAE;KACxB,CAAA;IACD,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["import {\n IAmfAnyTypes,\n IAmfArrayTypes,\n IAmfFileTypes,\n IAmfNodeTypes,\n IAmfPropertyTypes,\n IAmfRecursiveTypes,\n IAmfScalarTypes,\n IAmfTupleTypes,\n IAmfUnionTypes,\n IAmfXmlSerializationTypes,\n} from '../AmfTypes.js'\nimport { IApiDocumentation, IApiDocumentSourceMaps } from './Api.js'\nimport { IApiDomainProperty } from './Base.js'\n\nexport type IShapeUnion =\n | IApiScalarShape\n | IApiNodeShape\n | IApiUnionShape\n | IApiFileShape\n | IApiSchemaShape\n | IApiAnyShape\n | IApiArrayShape\n | IApiTupleShape\n | IApiRecursiveShape\n\nexport interface IApiAssociationShape {\n /**\n * This is custom property not available in AMF and used with data associations.\n *\n * Whether the target entity should be embedded under the property name.\n * When false, this association is just an information that one entity depend on another.\n * When true, it changes the definition of the schema having this association to\n * add the target schema properties inline with this property.\n *\n * **When true**\n *\n * ```javascript\n * // generated schema for `address` association\n * {\n * \"name\": \"example value\",\n * \"address\": {\n * \"city\": \"example value\",\n * ...\n * }\n * }\n * ```\n *\n * **When false**\n *\n * ```javascript\n * // generated schema for `address` association\n * {\n * \"name\": \"example value\",\n * \"address\": \"the key of the referenced schema\"\n * }\n * ```\n */\n linked?: boolean\n /**\n * When the association has multiple targets the union type should be\n * set to describe which union this is.\n *\n * Possible values are:\n *\n * - allOf - To validate against `allOf`, the given data must be valid against\n * all of the given sub-schemas. When generating, it's a sum of all properties.\n * - anyOf - To validate against `anyOf`, the given data must be valid against\n * any (one or more) of the given sub-schemas. When generation a schema, it takes first union schema.\n * - oneOf - To validate against `oneOf`, the given data must be valid against\n * exactly one of the given sub-schemas. It behaves the same as `oneOf` when generating a schema\n * - not - The `not` keyword declares that an instance validates if it doesn’t\n * validate against the given sub-schema. It has no use when generating a schema.\n *\n * @default anyOf\n */\n unionType?: 'allOf' | 'anyOf' | 'oneOf' | 'not'\n}\n\nexport interface IApiDataExample extends IApiDomainProperty {\n name?: string\n displayName?: string\n description?: string\n /**\n * This is the \"raw\" property of AMF\n */\n value?: string\n structuredValue?: IApiDataNodeUnion\n strict: boolean\n mediaType?: string\n location?: string\n sourceMaps?: IApiDocumentSourceMaps\n}\n\nexport function xmlSerializer(id: string): IApiXmlSerializer {\n return {\n id: `xml-serializer-${id}`,\n types: IAmfXmlSerializationTypes,\n customDomainProperties: [],\n }\n}\n\nexport function shape(id: string): IApiShape {\n const result: IApiShape = {\n id,\n types: [],\n values: [],\n inherits: [],\n or: [],\n and: [],\n xone: [],\n customDomainProperties: [],\n }\n return result\n}\n\nexport function anyShape(id: string): IApiAnyShape {\n const result: IApiAnyShape = {\n ...shape(id),\n types: IAmfAnyTypes,\n examples: [],\n xmlSerialization: xmlSerializer(id),\n }\n return result\n}\n\nexport function nodeShape(id: string): IApiNodeShape {\n const result = anyShape(id)\n result.types = IAmfNodeTypes\n result.id = `node-shape-${id}`\n return {\n ...result,\n properties: [],\n dependencies: [],\n customShapeProperties: [],\n customShapePropertyDefinitions: [],\n }\n}\n\nexport function scalarShape(id: string): IApiScalarShape {\n const result = anyShape(id)\n result.id = `scalar-shape-${id}`\n result.types = IAmfScalarTypes\n return result\n}\n\nexport function unionShape(id: string): IApiUnionShape {\n const result = anyShape(id)\n result.id = `union-shape-${id}`\n result.types = IAmfUnionTypes\n return { ...result, anyOf: [] }\n}\n\nexport function fileShape(id: string): IApiFileShape {\n const result = anyShape(id)\n result.id = `file-shape-${id}`\n result.types = IAmfFileTypes\n return result\n}\n\nexport function arrayShape(id: string): IApiArrayShape {\n const result = anyShape(id)\n result.id = `array-shape-${id}`\n result.types = IAmfArrayTypes\n return result\n}\n\nexport function tupleShape(id: string): IApiTupleShape {\n const result = anyShape(id)\n result.id = `tuple-shape-${id}`\n result.types = IAmfTupleTypes\n return { ...result, items: [] }\n}\n\nexport function propertyShape(id: string): IApiPropertyShape {\n const result = anyShape(id)\n result.types = IAmfPropertyTypes\n return result\n}\n\nexport function recursiveShape(id: string, fixedId?: string): IApiRecursiveShape {\n const result: IApiRecursiveShape = {\n ...shape(id),\n id: `recursive-${id}`,\n types: IAmfRecursiveTypes,\n fixPoint: fixedId || '',\n }\n return result\n}\n\nexport interface IApiShape extends IApiDomainProperty {\n /**\n * Enum values for this shape.\n */\n values: IApiDataNodeUnion[]\n /**\n * The list of shapes that this shape inherits from\n */\n inherits: IShapeUnion[]\n /**\n * The `anyOf` union type.\n */\n or: IShapeUnion[]\n /**\n * The `allOf` union type.\n */\n and: IShapeUnion[]\n /**\n * The `oneOf` union type.\n */\n xone: IShapeUnion[]\n /**\n * The name of the shape in the system.\n */\n name?: string\n /**\n * The display name for the shape in the UI.\n */\n displayName?: string\n /**\n * The description of the shape.\n */\n description?: string\n /**\n * The default value encoded as a string\n */\n defaultValueStr?: string\n /**\n * The description of the default value of the shape.\n */\n defaultValue?: IApiDataNodeUnion\n /**\n * Whether the shape is deprecated.\n */\n deprecated?: boolean\n /**\n * Whether the shape is a read only shape (disallow writes to the value)\n */\n readOnly?: boolean\n /**\n * Whether the shape can only be written to (disallow reading the value)\n */\n writeOnly?: boolean\n not?: IShapeUnion\n /**\n * A label that appeared on a link.\n */\n linkLabel?: string\n sourceMaps?: IApiDocumentSourceMaps\n}\n\n/**\n * A property of an API operation.\n */\nexport interface IApiPropertyShape<T = IShapeUnion> extends IApiShape {\n /**\n * The path of the property. Essentially, it is link generated by the AMF library\n * where the fragment part is the name of the property.\n */\n path?: string\n /**\n * The parameter shape definition\n */\n range?: T\n /**\n * When > 0 then the parameter is required.\n */\n minCount?: number\n maxCount?: number\n}\n\nexport interface IApiAnyShape extends IApiShape {\n documentation?: IApiDocumentation\n /**\n * Description of how the shape should be serialized as XML.\n */\n xmlSerialization: IApiXmlSerializer\n /**\n * Examples defined for the shape.\n */\n examples: IApiDataExample[]\n}\n\n/**\n * Describes an object shape.\n */\nexport interface IApiNodeShape extends IApiAnyShape {\n minProperties?: number\n maxProperties?: number\n closed?: boolean\n customShapeProperties: string[]\n customShapePropertyDefinitions: string[]\n discriminator?: string\n discriminatorValue?: string\n properties: IApiPropertyShape[]\n dependencies: string[]\n}\n\nexport interface IApiXmlSerializer extends IApiDomainProperty {\n /**\n * Whether this property should be represented as an attribute of the parent shape.\n *\n * ```\n * <Person name=\"John Doe\"></Person>\n * ```\n */\n attribute?: boolean\n /**\n * When the property is an array (has the `multiple` set to true in the data model)\n * then it tells that the list of values should be wrapped with a parent\n * element:\n *\n * ```\n * <Person>\n * <Person fullName=\"John Doe\"></Person>\n * <Person fullName=\"Other Doe\"></Person>\n * </Person>\n * ```\n *\n * Use this with the combination with `name` to describe the name of the wrapped\n * element\n *\n * ```\n * <people>\n * <Person fullName=\"John Doe\"></Person>\n * </people>\n * ```\n *\n * Note, this is mutually exclusive with `attribute`.\n */\n wrapped?: boolean\n /**\n * The name of the attribute or a wrapped property to use when serializing the property.\n *\n * Attribute name\n * ```xml\n * <Person fullName=\"John Doe\"></Person>\n * ```\n *\n * Wrapped name\n * ```xml\n * <people>\n * <Person name=\"John Doe\"></Person>\n * </people>\n * ```\n */\n name?: string\n /**\n * The XML namespace to use.\n *\n * ```xml\n * <Person ns:name=\"John Doe\"></Person>\n * ```\n */\n namespace?: string\n /**\n * Name prefix\n *\n * ```xml\n * <ns:Person name=\"John Doe\"></ns:Person>\n * ```\n */\n prefix?: string\n sourceMaps?: IApiDocumentSourceMaps\n}\n\nexport interface IApiScalarShape extends IApiAnyShape {\n dataType?: string\n pattern?: string\n minLength?: number\n maxLength?: number\n minimum?: number\n maximum?: number\n exclusiveMinimum?: boolean\n exclusiveMaximum?: boolean\n format?: string\n multipleOf?: number\n}\n\nexport interface IApiFileShape extends IApiAnyShape {\n fileTypes?: string[]\n pattern?: string\n minLength?: number\n maxLength?: number\n minimum?: number\n maximum?: number\n exclusiveMinimum?: boolean\n exclusiveMaximum?: boolean\n format?: string\n multipleOf?: number\n}\n\nexport interface IApiSchemaShape extends IApiAnyShape {\n mediaType?: string\n raw?: string\n}\n\nexport interface IApiUnionShape extends IApiAnyShape {\n anyOf: IShapeUnion[]\n}\n\nexport interface IApiDataArrangeShape extends IApiAnyShape {\n minItems?: number\n maxItems?: number\n uniqueItems?: boolean\n}\n\nexport interface IApiArrayShape<T = IShapeUnion> extends IApiDataArrangeShape {\n items?: T\n}\n\nexport interface IApiTupleShape<T = IShapeUnion> extends IApiDataArrangeShape {\n items: T[]\n additionalItems?: boolean\n}\n\nexport interface IApiRecursiveShape extends IApiShape {\n fixPoint: string\n}\n\nexport interface IApiDataNode extends IApiDomainProperty {\n name?: string\n}\n\nexport interface IApiObjectNode extends IApiDataNode {\n properties: Record<string, IApiDataNodeUnion>\n}\n\nexport interface IApiScalarNode extends IApiDataNode {\n value?: string\n dataType?: string\n}\n\nexport interface IApiArrayNode extends IApiDataNode {\n members: IApiDataNodeUnion[]\n}\n\nexport type IApiDataNodeUnion = IApiDataNode | IApiObjectNode | IApiScalarNode | IApiArrayNode\n"]}
1
+ {"version":3,"file":"Shapes.js","sourceRoot":"","sources":["../../../../src/amf/definitions/Shapes.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,cAAc,EACd,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,cAAc,EACd,yBAAyB,GAC1B,MAAM,gBAAgB,CAAA;AAmFvB,MAAM,UAAU,aAAa,CAAC,EAAU;IACtC,OAAO;QACL,EAAE,EAAE,kBAAkB,EAAE,EAAE;QAC1B,KAAK,EAAE,yBAAyB;QAChC,sBAAsB,EAAE,EAAE;KAC3B,CAAA;AACH,CAAC;AAED,MAAM,UAAU,KAAK,CAAC,EAAU;IAC9B,MAAM,MAAM,GAAc;QACxB,EAAE;QACF,KAAK,EAAE,EAAE;QACT,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE,EAAE;QACZ,EAAE,EAAE,EAAE;QACN,GAAG,EAAE,EAAE;QACP,IAAI,EAAE,EAAE;QACR,sBAAsB,EAAE,EAAE;KAC3B,CAAA;IACD,OAAO,MAAM,CAAA;AACf,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,EAAU;IACjC,MAAM,MAAM,GAAiB;QAC3B,GAAG,KAAK,CAAC,EAAE,CAAC;QACZ,KAAK,EAAE,YAAY;QACnB,QAAQ,EAAE,EAAE;QACZ,gBAAgB,EAAE,aAAa,CAAC,EAAE,CAAC;KACpC,CAAA;IACD,OAAO,MAAM,CAAA;AACf,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,EAAU;IAClC,MAAM,MAAM,GAAG,QAAQ,CAAC,EAAE,CAA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EAAU;IACnC,MAAM,MAAM,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAA;IAC3B,MAAM,CAAC,EAAE,GAAG,eAAe,EAAE,EAAE,CAAA;IAC/B,MAAM,CAAC,KAAK,GAAG,cAAc,CAAA;IAC7B,OAAO,EAAE,GAAG,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,CAAA;AACjC,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,EAAU;IACtC,MAAM,MAAM,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAA;IAC3B,MAAM,CAAC,KAAK,GAAG,iBAAiB,CAAA;IAChC,OAAO,MAAM,CAAA;AACf,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,EAAU,EAAE,OAAgB;IACzD,MAAM,MAAM,GAAuB;QACjC,GAAG,KAAK,CAAC,EAAE,CAAC;QACZ,EAAE,EAAE,aAAa,EAAE,EAAE;QACrB,KAAK,EAAE,kBAAkB;QACzB,QAAQ,EAAE,OAAO,IAAI,EAAE;KACxB,CAAA;IACD,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["import {\n IAmfAnyTypes,\n IAmfArrayTypes,\n IAmfFileTypes,\n IAmfNodeTypes,\n IAmfPropertyTypes,\n IAmfRecursiveTypes,\n IAmfScalarTypes,\n IAmfTupleTypes,\n IAmfUnionTypes,\n IAmfXmlSerializationTypes,\n} from '../AmfTypes.js'\nimport { IApiDocumentation, IApiDocumentSourceMaps } from './Api.js'\nimport { IApiDomainProperty } from './Base.js'\n\nexport type IShapeUnion =\n | IApiScalarShape\n | IApiNodeShape\n | IApiUnionShape\n | IApiFileShape\n | IApiSchemaShape\n | IApiAnyShape\n | IApiArrayShape\n | IApiTupleShape\n | IApiRecursiveShape\n\nexport interface IApiAssociationShape {\n /**\n * This is custom property not available in AMF and used with data associations.\n *\n * Whether the target entity should be embedded under the property name.\n * When false, this association is just an information that one entity depend on another.\n * When true, it changes the definition of the schema having this association to\n * add the target schema properties inline with this property.\n *\n * **When true**\n *\n * ```javascript\n * // generated schema for `address` association\n * {\n * \"name\": \"example value\",\n * \"address\": {\n * \"city\": \"example value\",\n * ...\n * }\n * }\n * ```\n *\n * **When false**\n *\n * ```javascript\n * // generated schema for `address` association\n * {\n * \"name\": \"example value\",\n * \"address\": \"the key of the referenced schema\"\n * }\n * ```\n */\n linked?: boolean\n /**\n * When the association has multiple targets the union type should be\n * set to describe which union this is.\n *\n * Possible values are:\n *\n * - allOf - To validate against `allOf`, the given data must be valid against\n * all of the given sub-schemas. When generating, it's a sum of all properties.\n * - anyOf - To validate against `anyOf`, the given data must be valid against\n * any (one or more) of the given sub-schemas. When generation a schema, it takes first union schema.\n * - oneOf - To validate against `oneOf`, the given data must be valid against\n * exactly one of the given sub-schemas. It behaves the same as `anyOf` when generating a schema\n * - not - The `not` keyword declares that an instance validates if it doesn’t\n * validate against the given sub-schema. It has no use when generating a schema.\n *\n * @default anyOf\n */\n unionType?: 'allOf' | 'anyOf' | 'oneOf' | 'not'\n}\n\nexport interface IApiDataExample extends IApiDomainProperty {\n name?: string\n displayName?: string\n description?: string\n /**\n * This is the \"raw\" property of AMF\n */\n value?: string\n structuredValue?: IApiDataNodeUnion\n strict: boolean\n mediaType?: string\n location?: string\n sourceMaps?: IApiDocumentSourceMaps\n}\n\nexport function xmlSerializer(id: string): IApiXmlSerializer {\n return {\n id: `xml-serializer-${id}`,\n types: IAmfXmlSerializationTypes,\n customDomainProperties: [],\n }\n}\n\nexport function shape(id: string): IApiShape {\n const result: IApiShape = {\n id,\n types: [],\n values: [],\n inherits: [],\n or: [],\n and: [],\n xone: [],\n customDomainProperties: [],\n }\n return result\n}\n\nexport function anyShape(id: string): IApiAnyShape {\n const result: IApiAnyShape = {\n ...shape(id),\n types: IAmfAnyTypes,\n examples: [],\n xmlSerialization: xmlSerializer(id),\n }\n return result\n}\n\nexport function nodeShape(id: string): IApiNodeShape {\n const result = anyShape(id)\n result.types = IAmfNodeTypes\n result.id = `node-shape-${id}`\n return {\n ...result,\n properties: [],\n dependencies: [],\n customShapeProperties: [],\n customShapePropertyDefinitions: [],\n }\n}\n\nexport function scalarShape(id: string): IApiScalarShape {\n const result = anyShape(id)\n result.id = `scalar-shape-${id}`\n result.types = IAmfScalarTypes\n return result\n}\n\nexport function unionShape(id: string): IApiUnionShape {\n const result = anyShape(id)\n result.id = `union-shape-${id}`\n result.types = IAmfUnionTypes\n return { ...result, anyOf: [] }\n}\n\nexport function fileShape(id: string): IApiFileShape {\n const result = anyShape(id)\n result.id = `file-shape-${id}`\n result.types = IAmfFileTypes\n return result\n}\n\nexport function arrayShape(id: string): IApiArrayShape {\n const result = anyShape(id)\n result.id = `array-shape-${id}`\n result.types = IAmfArrayTypes\n return result\n}\n\nexport function tupleShape(id: string): IApiTupleShape {\n const result = anyShape(id)\n result.id = `tuple-shape-${id}`\n result.types = IAmfTupleTypes\n return { ...result, items: [] }\n}\n\nexport function propertyShape(id: string): IApiPropertyShape {\n const result = anyShape(id)\n result.types = IAmfPropertyTypes\n return result\n}\n\nexport function recursiveShape(id: string, fixedId?: string): IApiRecursiveShape {\n const result: IApiRecursiveShape = {\n ...shape(id),\n id: `recursive-${id}`,\n types: IAmfRecursiveTypes,\n fixPoint: fixedId || '',\n }\n return result\n}\n\nexport interface IApiShape extends IApiDomainProperty {\n /**\n * Enum values for this shape.\n */\n values: IApiDataNodeUnion[]\n /**\n * The list of shapes that this shape inherits from\n */\n inherits: IShapeUnion[]\n /**\n * The `anyOf` union type.\n */\n or: IShapeUnion[]\n /**\n * The `allOf` union type.\n */\n and: IShapeUnion[]\n /**\n * The `oneOf` union type.\n */\n xone: IShapeUnion[]\n /**\n * The name of the shape in the system.\n */\n name?: string\n /**\n * The display name for the shape in the UI.\n */\n displayName?: string\n /**\n * The description of the shape.\n */\n description?: string\n /**\n * The default value encoded as a string\n */\n defaultValueStr?: string\n /**\n * The description of the default value of the shape.\n */\n defaultValue?: IApiDataNodeUnion\n /**\n * Whether the shape is deprecated.\n */\n deprecated?: boolean\n /**\n * Whether the shape is a read only shape (disallow writes to the value)\n */\n readOnly?: boolean\n /**\n * Whether the shape can only be written to (disallow reading the value)\n */\n writeOnly?: boolean\n not?: IShapeUnion\n /**\n * A label that appeared on a link.\n */\n linkLabel?: string\n sourceMaps?: IApiDocumentSourceMaps\n}\n\n/**\n * A property of an API operation.\n */\nexport interface IApiPropertyShape<T = IShapeUnion> extends IApiShape {\n /**\n * The path of the property. Essentially, it is link generated by the AMF library\n * where the fragment part is the name of the property.\n */\n path?: string\n /**\n * The parameter shape definition\n */\n range?: T\n /**\n * When > 0 then the parameter is required.\n */\n minCount?: number\n maxCount?: number\n}\n\nexport interface IApiAnyShape extends IApiShape {\n documentation?: IApiDocumentation\n /**\n * Description of how the shape should be serialized as XML.\n */\n xmlSerialization: IApiXmlSerializer\n /**\n * Examples defined for the shape.\n */\n examples: IApiDataExample[]\n}\n\n/**\n * Describes an object shape.\n */\nexport interface IApiNodeShape extends IApiAnyShape {\n minProperties?: number\n maxProperties?: number\n closed?: boolean\n customShapeProperties: string[]\n customShapePropertyDefinitions: string[]\n discriminator?: string\n discriminatorValue?: string\n properties: IApiPropertyShape[]\n dependencies: string[]\n}\n\nexport interface IApiXmlSerializer extends IApiDomainProperty {\n /**\n * Whether this property should be represented as an attribute of the parent shape.\n *\n * ```\n * <Person name=\"John Doe\"></Person>\n * ```\n */\n attribute?: boolean\n /**\n * When the property is an array (has the `multiple` set to true in the data model)\n * then it tells that the list of values should be wrapped with a parent\n * element:\n *\n * ```\n * <Person>\n * <Person fullName=\"John Doe\"></Person>\n * <Person fullName=\"Other Doe\"></Person>\n * </Person>\n * ```\n *\n * Use this with the combination with `name` to describe the name of the wrapped\n * element\n *\n * ```\n * <people>\n * <Person fullName=\"John Doe\"></Person>\n * </people>\n * ```\n *\n * Note, this is mutually exclusive with `attribute`.\n */\n wrapped?: boolean\n /**\n * The name of the attribute or a wrapped property to use when serializing the property.\n *\n * Attribute name\n * ```xml\n * <Person fullName=\"John Doe\"></Person>\n * ```\n *\n * Wrapped name\n * ```xml\n * <people>\n * <Person name=\"John Doe\"></Person>\n * </people>\n * ```\n */\n name?: string\n /**\n * The XML namespace to use.\n *\n * ```xml\n * <Person ns:name=\"John Doe\"></Person>\n * ```\n */\n namespace?: string\n /**\n * Name prefix\n *\n * ```xml\n * <ns:Person name=\"John Doe\"></ns:Person>\n * ```\n */\n prefix?: string\n sourceMaps?: IApiDocumentSourceMaps\n}\n\nexport interface IApiScalarShape extends IApiAnyShape {\n dataType?: string\n pattern?: string\n minLength?: number\n maxLength?: number\n minimum?: number\n maximum?: number\n exclusiveMinimum?: boolean\n exclusiveMaximum?: boolean\n format?: string\n multipleOf?: number\n}\n\nexport interface IApiFileShape extends IApiAnyShape {\n fileTypes?: string[]\n pattern?: string\n minLength?: number\n maxLength?: number\n minimum?: number\n maximum?: number\n exclusiveMinimum?: boolean\n exclusiveMaximum?: boolean\n format?: string\n multipleOf?: number\n}\n\nexport interface IApiSchemaShape extends IApiAnyShape {\n mediaType?: string\n raw?: string\n}\n\nexport interface IApiUnionShape extends IApiAnyShape {\n anyOf: IShapeUnion[]\n}\n\nexport interface IApiDataArrangeShape extends IApiAnyShape {\n minItems?: number\n maxItems?: number\n uniqueItems?: boolean\n}\n\nexport interface IApiArrayShape<T = IShapeUnion> extends IApiDataArrangeShape {\n items?: T\n}\n\nexport interface IApiTupleShape<T = IShapeUnion> extends IApiDataArrangeShape {\n items: T[]\n additionalItems?: boolean\n}\n\nexport interface IApiRecursiveShape extends IApiShape {\n fixPoint: string\n}\n\nexport interface IApiDataNode extends IApiDomainProperty {\n name?: string\n}\n\nexport interface IApiObjectNode extends IApiDataNode {\n properties: Record<string, IApiDataNodeUnion>\n}\n\nexport interface IApiScalarNode extends IApiDataNode {\n value?: string\n dataType?: string\n}\n\nexport interface IApiArrayNode extends IApiDataNode {\n members: IApiDataNodeUnion[]\n}\n\nexport type IApiDataNodeUnion = IApiDataNode | IApiObjectNode | IApiScalarNode | IApiArrayNode\n"]}
@@ -251,9 +251,9 @@ export declare class DataAssociation {
251
251
  */
252
252
  ensureSchema(): IApiAssociationShape;
253
253
  /**
254
- * Checks whether the passed value is one of the supported data proprty attributes.
254
+ * Checks whether the passed value is one of the supported data property attributes.
255
255
  * @param value The value to test
256
- * @returns True when the passed value is one of the supported data proprty attributes.
256
+ * @returns True when the passed value is one of the supported data property attributes.
257
257
  */
258
258
  static isValidAttribute(value: unknown): value is DataAttributeAttribute;
259
259
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"DataAssociation.d.ts","sourceRoot":"","sources":["../../../src/modeling/DataAssociation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAA;AAEtF,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAElD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AACxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAA;AACpG,OAAO,EAA2B,KAAK,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AAEtF;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,OAAO,mBAAmB,CAAA;IAChC;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;;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OAMG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,GAAG,eAAe;IAMnE;;OAEG;gBAEM,IAAI,EAAE,aAAa,EAC1B,KAAK,CAAC,EAAE,MAAM,GAAG,gBAAgB;IA2BnC;;;;OAIG;IACH,GAAG,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI;IAsCjC;;;;;;OAMG;IACH,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IA8BrC;;;;OAIG;IACH,MAAM,IAAI,gBAAgB;IAwB1B;;;;OAIG;IACH,UAAU,IAAI,UAAU,EAAE;IAK1B;;OAEG;IACH,MAAM,IAAI,IAAI;IAad;;;;;OAKG;IACH,SAAS,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IAEnC;;;;;;OAMG;IACH,SAAS,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI;IA8CjE;;;;OAIG;IACH,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,WAAW,GAAG,IAAI;IAa3D;;;;;;;;;OASG;IACH,UAAU,IAAI,iBAAiB;IAK/B;;OAEG;IACH,SAAS,IAAI,UAAU;IAIvB;;;;OAIG;IACH,iBAAiB,IAAI,UAAU;IAM/B;;;OAGG;IACH,YAAY,IAAI,oBAAoB;IAOpC;;;;OAIG;IACH,MAAM,CAAC,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,sBAAsB;IAOxE;;;OAGG;IACH,aAAa,IAAI,sBAAsB;IASvC;;;;OAIG;IACH,WAAW,CAAC,IAAI,EAAE,KAAK,GAAG,UAAU,GAAG,mBAAmB,GAAG,SAAS;CAIvE"}
@@ -303,6 +303,16 @@ export class DataAssociation {
303
303
  namespace = typed.root.key;
304
304
  }
305
305
  }
306
+ if (this.targets.some((i) => i.key === key)) {
307
+ const message = `Target ${key} already exists.`;
308
+ throw new ValidationError([
309
+ {
310
+ field: 'targets',
311
+ message,
312
+ rule: 'unique',
313
+ },
314
+ ], { message });
315
+ }
306
316
  if (namespace && namespace !== this.root.key) {
307
317
  const foreignNamespace = this.root.foreign.find((ns) => ns.key === namespace);
308
318
  if (!foreignNamespace) {
@@ -376,9 +386,9 @@ export class DataAssociation {
376
386
  return this.schema;
377
387
  }
378
388
  /**
379
- * Checks whether the passed value is one of the supported data proprty attributes.
389
+ * Checks whether the passed value is one of the supported data property attributes.
380
390
  * @param value The value to test
381
- * @returns True when the passed value is one of the supported data proprty attributes.
391
+ * @returns True when the passed value is one of the supported data property attributes.
382
392
  */
383
393
  static isValidAttribute(value) {
384
394
  if (typeof value !== 'string') {
@@ -1 +1 @@
1
- {"version":3,"file":"DataAssociation.js","sourceRoot":"","sources":["../../../src/modeling/DataAssociation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAA;AAE/D,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAC/B,OAAO,EAAU,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAGlD,OAAO,EAA+B,eAAe,EAAE,MAAM,mCAAmC,CAAA;AAChG,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAExD,OAAO,EAAE,uBAAuB,EAA+B,MAAM,iBAAiB,CAAA;AAuEtF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,OAAO,eAAe;IA0FjB;IAzFT,IAAI,GAAG,mBAAmB,CAAA;IAE1B,GAAG,GAAG,EAAE,CAAA;IAER;;OAEG;IACH,IAAI,GAAU,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;IAEhC;;OAEG;IACH,QAAQ,CAAU;IAElB;;OAEG;IACH,QAAQ,CAAU;IAElB;;;;OAIG;IACH,OAAO,GAAwB,EAAE,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QACpC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,OAAO,KAAK,CAAA;QACd,CAAC;QACD,OAAO,uBAAuB,CAAC,QAAQ,CAAC,KAA+B,CAAC,CAAA;IAC1E,CAAC;IAED;;;OAGG;IACH,aAAa;QACX,IAAI,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,KAAK,CAAmC,CAAA;QAC1F,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAwB,CAAA;YAC1D,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QAC5B,CAAC;QACD,OAAO,MAAM,CAAC,MAAgC,CAAA;IAChD,CAAC;IAED;;;;OAIG;IACH,WAAW,CAAC,IAAwB;QAClC,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAuB,CAAA;QAC7E,OAAO,IAAI,EAAE,MAAM,CAAA;IACrB,CAAC;CACF","sourcesContent":["import { Json } from '@api-client/json'\nimport { AmfShapeGenerator } from '../amf/AmfShapeGenerator.js'\nimport { IApiAssociationShape, IApiPropertyShape } from '../amf/definitions/Shapes.js'\nimport v4 from '../lib/uuid.js'\nimport { IThing, Thing } from '../models/Thing.js'\nimport { DataEntity, IDataEntity } from './DataEntity.js'\nimport { DataNamespace } from './DataNamespace.js'\nimport { type FieldValidationMessage, ValidationError } from '../exceptions/validation_error.js'\nimport { DataAssociationKind } from '../models/kinds.js'\nimport type { AssociationBinding, AssociationBindings, AssociationWebBindings } from './Bindings.js'\nimport { DataAttributeAttributes, type DataAttributeAttribute } from './DataFormat.js'\n\n/**\n * Describes association target of an entity\n */\nexport interface AssociationTarget {\n /**\n * The key of the associated entity.\n */\n key: string\n /**\n * The key of the namespace to look for entities.\n * By default it is the current (root) namespace. When this is set the program\n * will look into `foreign` of the root namespace for the definition\n * of the entity.\n */\n namespace?: string\n}\n\n/**\n * Describes an association between entities. An association is another property of an entity.\n * The `name` is the name of the property and the value is the associated target or targets.\n *\n * An association can have multiple targets to allow describing the model as `allOf`, `anyOf` and `oneOf` schemas.\n * When the association has only one target, then generated schema cannot have union types.\n *\n * Depending on the schema translation an association can be embedded as a sub-object in the generated schema\n * or can be references via a primary key.\n */\nexport interface IDataAssociation {\n kind: typeof DataAssociationKind\n /**\n * The key of the association.\n */\n key: string\n /**\n * The data association description.\n */\n info: IThing\n /**\n * Wether the data association is required.\n */\n required?: boolean\n /**\n * Whether the data association allows multiple items.\n */\n multiple?: boolean\n /**\n * The list of keys associated with the entity through this association.\n * An association without a target is considered invalid and discarded when processing the values.\n * When multiple associations are set then we are dealing with an union.\n */\n targets?: AssociationTarget[]\n /**\n * The schema allowing to translate the model into a specific format (like JSON, RAML, XML, etc.)\n *\n * When this is defined then it is used as the schema. When this is not defined it uses\n * referenced entities schemas. Note, changes in the referenced entities may not be propagated\n * to schemas altered by the user.\n */\n schema?: IApiAssociationShape\n /**\n * The list of bindings for this property.\n *\n * A binding defines a translation from a data model to a specific format.\n * For example allows to define properties required to generate AMF shape and therefore RAML/OAS shapes for web APIs\n * or a protocol buffer schema.\n */\n bindings?: AssociationBinding[]\n}\n\n/**\n * Describes an association between entities. An association is a relationship defined on an entity\n * that links it to one or more other entities. The association has a `name` which is used as the\n * property name in the context of the parent entity, and it connects to a set of `targets`\n * representing the associated entities.\n *\n * An association can have multiple targets to allow describing the model as `allOf`, `anyOf`, or `oneOf`\n * schemas. When the association has only one target, then the generated schema cannot have union types.\n *\n * Depending on the schema translation, an association can be embedded as a sub-object in the generated\n * schema, or it can be referenced via a primary key.\n *\n * ## Key Concepts\n *\n * - **Targets**: An association's `targets` specify the entities that this association points to.\n * Each target is defined by:\n * - `key`: The key of the target entity.\n * - `namespace` (optional): The key of the namespace where the target entity is defined.\n * If not specified, it defaults to the current namespace.\n *\n * - **Cardinality**:\n * - `multiple` (boolean): Indicates whether the association allows multiple target entities.\n * If `true`, it's a to-many relationship; otherwise, it's a to-one relationship.\n *\n * - **Schema**:\n * - `schema` (optional): A custom schema for the association, allowing manual definition of the\n * association's structure in specific formats (e.g., JSON, RAML, XML).\n * When provided, this schema overrides the automatically generated schema based on the\n * target entities.\n * - **Important**: If a custom schema is defined and changes are made to the referenced\n * entities, those changes **will not** be automatically propagated to the custom schema.\n * This means the custom schema may become outdated and no longer accurately reflect the\n * structure of the target entities.\n *\n * - **Hidden**:\n * - `hidden`: (boolean) Defines if this association is a part of the schema or not.\n */\nexport class DataAssociation {\n kind = DataAssociationKind\n\n key = ''\n\n /**\n * The description of the data association.\n */\n info: Thing = Thing.fromName('')\n\n /**\n * Wether the data association is required.\n */\n required?: boolean\n\n /**\n * Whether the data association allows multiple items.\n */\n multiple?: boolean\n\n /**\n * The list of keys associated with the entity through this association.\n * An association without a target is considered invalid and discarded when processing the values.\n * When multiple associations are set then we are dealing with an union.\n */\n targets: AssociationTarget[] = []\n\n /**\n * The schema allowing to translate the model into a specific format (like JSON, RAML, XML, etc.)\n *\n * When this is defined then it is used as the schema. When this is not defined it uses\n * referenced entities schemas. Note, changes in the referenced entities may not be propagated\n * to schemas altered by the user.\n */\n schema?: IApiAssociationShape\n\n /**\n * The list of bindings for this property.\n *\n * A binding defines a translation from a data model to a specific format.\n * For example allows to define properties required to generate AMF shape and therefore RAML/OAS shapes for web APIs\n * or a protocol buffer schema.\n */\n bindings: AssociationBinding[] = []\n\n /**\n * Returns true when the association has 0 or 1 targets.\n */\n get isSingle(): boolean {\n return this.targets.length < 2\n }\n\n /**\n * Creates an instance of DataAssociation from a target entity key.\n * Note, this entity will have no name. The default name is used instead.\n *\n * @param root The namespace root.\n * @param target The target entity key.\n * @param namespace The optional key of the target association when different to the current one.\n * @returns A new `DataAssociation` instance.\n */\n static fromTarget(root: DataNamespace, target: string, namespace?: string): DataAssociation {\n const assoc = new DataAssociation(root)\n const info: AssociationTarget = {\n key: target,\n }\n if (namespace) {\n info.namespace = namespace\n }\n assoc.targets = [info]\n return assoc\n }\n\n /**\n * Creates an instance of DataAssociation from a name, without defining a target.\n *\n * @param root The namespace root.\n * @param name The name of the association.\n * @returns A new `DataAssociation` instance.\n */\n static fromName(root: DataNamespace, name: string): DataAssociation {\n const assoc = new DataAssociation(root)\n assoc.info = Thing.fromName(name)\n return assoc\n }\n\n /**\n * @param input The data association definition to restore.\n */\n constructor(\n public root: DataNamespace,\n input?: string | IDataAssociation\n ) {\n let init: IDataAssociation\n if (typeof input === 'string') {\n try {\n init = JSON.parse(input)\n } catch {\n throw new ValidationError([\n {\n field: '',\n message: 'Unable to parse the data association input as JSON.',\n rule: 'object_required',\n },\n ])\n }\n } else if (typeof input === 'object') {\n init = input\n } else {\n init = {\n kind: DataAssociationKind,\n key: v4(),\n info: Thing.fromName('Unnamed association').toJSON(),\n }\n }\n this.new(init)\n }\n\n /**\n * Initializes the association using provided data.\n *\n * @param init - The data association definition to restore.\n */\n new(init: IDataAssociation): this {\n DataAssociation.validate(init)\n const { info, key = v4(), kind = DataAssociationKind, schema, multiple, required, targets, bindings } = init\n this.kind = kind\n this.key = key\n if (info) {\n this.info = new Thing(info)\n } else {\n this.info = Thing.fromName('')\n }\n if (schema) {\n this.schema = Json.clone(schema)\n } else {\n this.schema = undefined\n }\n if (typeof multiple === 'boolean') {\n this.multiple = multiple\n } else {\n this.multiple = undefined\n }\n if (typeof required === 'boolean') {\n this.required = required\n } else {\n this.required = undefined\n }\n if (Array.isArray(targets)) {\n this.targets = targets.map((i) => ({ ...i }))\n } else {\n this.targets = []\n }\n if (Array.isArray(bindings)) {\n this.bindings = bindings.map((i) => Json.clone(i))\n } else {\n this.bindings = []\n }\n return this\n }\n\n /**\n * Validates if the input object is a valid `DataAssociation` definition.\n * Throws a `ValidationError` if the input is invalid.\n *\n * @param input The object to validate.\n * @throws {ValidationError} When the validation fails.\n */\n static validate(input: unknown): void {\n const typed = input as IDataAssociation\n const messages: FieldValidationMessage[] = []\n if (!typed) {\n messages.push({\n field: '',\n message: 'The input is required. None given',\n rule: 'required',\n })\n throw new ValidationError(messages)\n }\n if (typed.kind !== DataAssociationKind) {\n messages.push({\n field: 'kind',\n message: `The kind property must be ${DataAssociationKind}`,\n rule: 'invalid',\n })\n }\n if (typed.info && typeof typed.info !== 'object') {\n messages.push({\n field: 'info',\n message: 'The info property must be an object',\n rule: 'invalid',\n })\n }\n if (messages.length) {\n throw new ValidationError(messages)\n }\n }\n\n /**\n * Generates an object representing the association, suitable for serialization.\n *\n * @returns A plain object representation of the `DataAssociation`.\n */\n toJSON(): IDataAssociation {\n const result: IDataAssociation = {\n kind: DataAssociationKind,\n key: this.key,\n info: this.info.toJSON(),\n }\n if (this.schema) {\n result.schema = Json.clone(this.schema)\n }\n if (typeof this.multiple === 'boolean') {\n result.multiple = this.multiple\n }\n if (typeof this.required === 'boolean') {\n result.required = this.required\n }\n if (Array.isArray(this.targets) && this.targets.length) {\n result.targets = this.targets.map((i) => ({ ...i }))\n }\n if (Array.isArray(this.bindings) && this.bindings.length) {\n result.bindings = this.bindings.map((i) => Json.clone(i))\n }\n return result\n }\n\n /**\n * Retrieves the list of target entities.\n *\n * @returns An array of `DataEntity` instances representing the targets of this association.\n */\n getTargets(): DataEntity[] {\n const { targets } = this\n return this.root.findAssociatedEntities(targets).filter((i) => !!i) as DataEntity[]\n }\n\n /**\n * Removes self from the parent entity and the namespace definition.\n */\n remove(): void {\n const { root } = this\n const entity = root.definitions.entities.find((i) => i.associations.some((j) => j.key === this.key))\n if (entity) {\n const assocIndex = entity.associations.findIndex((i) => i.key === this.key)\n entity.associations.splice(assocIndex, 1)\n }\n const defIndex = this.root.definitions.associations.findIndex((i) => i.key === this.key)\n if (defIndex >= 0) {\n this.root.definitions.associations.splice(defIndex, 1)\n }\n }\n\n /**\n * Adds a target entity to the association.\n * If the entity comes from another namespace then it is set as a foreign entity.\n *\n * @param entity - The `DataEntity` instance to add.\n */\n addTarget(entity: DataEntity): void\n\n /**\n * Adds a target entity to the association.\n *\n * @param entity - The `IDataEntity` definition or just its key.\n * @param namespace - The key of the foreign namespace this entity belongs to.\n * Do not set this value for local entities.\n */\n addTarget(entity: IDataEntity | string, namespace?: string): void\n\n /**\n * @param init The key of an entity, its instance, or schema.\n * @param namespace - The key of the foreign namespace this entity belongs to.\n * Do not set this value for local entities.\n */\n addTarget(init: string | DataEntity | IDataEntity, namespace?: string): void {\n let key: string\n if (typeof init === 'string') {\n key = init\n } else {\n key = init.key\n const typed = init as IDataEntity & { root?: DataNamespace }\n if (!namespace && typed.root && typed.root !== this.root) {\n namespace = typed.root.key\n }\n }\n if (namespace && namespace !== this.root.key) {\n const foreignNamespace = this.root.foreign.find((ns) => ns.key === namespace)\n if (!foreignNamespace) {\n throw new Error(`Foreign namespace \"${namespace}\" does not exist.`)\n }\n }\n const info: AssociationTarget = {\n key,\n }\n if (namespace) {\n info.namespace = namespace\n }\n this.targets.push(info)\n }\n\n /**\n * Removes a target entity from the targets list.\n *\n * @param init The key of an entity, its instance, or schema.\n */\n removeTarget(init: string | DataEntity | IDataEntity): void {\n let key: string\n if (typeof init === 'string') {\n key = init\n } else {\n key = init.key\n }\n const index = this.targets.findIndex((i) => i.key === key)\n if (index >= 0) {\n this.targets.splice(index, 1)\n }\n }\n\n /**\n * Creates a Property Shape of AMF.\n * The property itself is auto-generated. If the `schema` is defined then it is used\n * as the `range` of the property. Otherwise basic shape is generated for the range.\n *\n * This is a preferred way of reading the AMF shape as this synchronizes changed\n * data properties with the shape definition.\n *\n * @returns AMF property shape definition.\n */\n toApiShape(): IApiPropertyShape {\n const serializer = new AmfShapeGenerator()\n return serializer.associationProperty(this)\n }\n\n /**\n * @deprecated Use the `getParentInstance()` method instead.\n */\n getParent(): DataEntity {\n return this.getParentInstance()\n }\n\n /**\n * Retrieves the parent entity of this association.\n *\n * @returns The `DataEntity` instance that contains this association.\n */\n getParentInstance(): DataEntity {\n // this is forced as an association is only created when an entity is created\n // so it has to be defined.\n return this.root.definitions.entities.find((i) => i.associations.some((a) => a.key === this.key)) as DataEntity\n }\n\n /**\n * Creates the `schema` object if missing and returns it.\n * @returns The schema object.\n */\n ensureSchema(): IApiAssociationShape {\n if (!this.schema) {\n this.schema = {}\n }\n return this.schema\n }\n\n /**\n * Checks whether the passed value is one of the supported data proprty attributes.\n * @param value The value to test\n * @returns True when the passed value is one of the supported data proprty attributes.\n */\n static isValidAttribute(value: unknown): value is DataAttributeAttribute {\n if (typeof value !== 'string') {\n return false\n }\n return DataAttributeAttributes.includes(value as DataAttributeAttribute)\n }\n\n /**\n * Creates if not existing and returns web bindings definition.\n * @returns The web binding definition\n */\n getWebBinding(): AssociationWebBindings {\n let object = this.bindings.find((i) => i.type === 'web') as AssociationBinding | undefined\n if (!object) {\n object = { type: 'web', schema: {} } as AssociationBinding\n this.bindings.push(object)\n }\n return object.schema as AssociationWebBindings\n }\n\n /**\n * Returns the schema value of the binding, if any was created.\n * @param type The type of the binding to read.\n * @returns The binding schema, if any\n */\n readBinding(type: 'web' | 'protobuf'): AssociationBindings | undefined {\n const item = this.bindings.find((i) => i.type === type) as AssociationBinding\n return item?.schema\n }\n}\n"]}
1
+ {"version":3,"file":"DataAssociation.js","sourceRoot":"","sources":["../../../src/modeling/DataAssociation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAA;AAE/D,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAC/B,OAAO,EAAU,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAGlD,OAAO,EAA+B,eAAe,EAAE,MAAM,mCAAmC,CAAA;AAChG,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAExD,OAAO,EAAE,uBAAuB,EAA+B,MAAM,iB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ED;;;;OAIG;IACH,WAAW,CAAC,IAAwB;QAClC,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAuB,CAAA;QAC7E,OAAO,IAAI,EAAE,MAAM,CAAA;IACrB,CAAC;CACF","sourcesContent":["import { Json } from '@api-client/json'\nimport { AmfShapeGenerator } from '../amf/AmfShapeGenerator.js'\nimport { IApiAssociationShape, IApiPropertyShape } from '../amf/definitions/Shapes.js'\nimport v4 from '../lib/uuid.js'\nimport { IThing, Thing } from '../models/Thing.js'\nimport { DataEntity, IDataEntity } from './DataEntity.js'\nimport { DataNamespace } from './DataNamespace.js'\nimport { type FieldValidationMessage, ValidationError } from '../exceptions/validation_error.js'\nimport { DataAssociationKind } from '../models/kinds.js'\nimport type { AssociationBinding, AssociationBindings, AssociationWebBindings } from './Bindings.js'\nimport { DataAttributeAttributes, type DataAttributeAttribute } from './DataFormat.js'\n\n/**\n * Describes association target of an entity\n */\nexport interface AssociationTarget {\n /**\n * The key of the associated entity.\n */\n key: string\n /**\n * The key of the namespace to look for entities.\n * By default it is the current (root) namespace. When this is set the program\n * will look into `foreign` of the root namespace for the definition\n * of the entity.\n */\n namespace?: string\n}\n\n/**\n * Describes an association between entities. An association is another property of an entity.\n * The `name` is the name of the property and the value is the associated target or targets.\n *\n * An association can have multiple targets to allow describing the model as `allOf`, `anyOf` and `oneOf` schemas.\n * When the association has only one target, then generated schema cannot have union types.\n *\n * Depending on the schema translation an association can be embedded as a sub-object in the generated schema\n * or can be references via a primary key.\n */\nexport interface IDataAssociation {\n kind: typeof DataAssociationKind\n /**\n * The key of the association.\n */\n key: string\n /**\n * The data association description.\n */\n info: IThing\n /**\n * Wether the data association is required.\n */\n required?: boolean\n /**\n * Whether the data association allows multiple items.\n */\n multiple?: boolean\n /**\n * The list of keys associated with the entity through this association.\n * An association without a target is considered invalid and discarded when processing the values.\n * When multiple associations are set then we are dealing with an union.\n */\n targets?: AssociationTarget[]\n /**\n * The schema allowing to translate the model into a specific format (like JSON, RAML, XML, etc.)\n *\n * When this is defined then it is used as the schema. When this is not defined it uses\n * referenced entities schemas. Note, changes in the referenced entities may not be propagated\n * to schemas altered by the user.\n */\n schema?: IApiAssociationShape\n /**\n * The list of bindings for this property.\n *\n * A binding defines a translation from a data model to a specific format.\n * For example allows to define properties required to generate AMF shape and therefore RAML/OAS shapes for web APIs\n * or a protocol buffer schema.\n */\n bindings?: AssociationBinding[]\n}\n\n/**\n * Describes an association between entities. An association is a relationship defined on an entity\n * that links it to one or more other entities. The association has a `name` which is used as the\n * property name in the context of the parent entity, and it connects to a set of `targets`\n * representing the associated entities.\n *\n * An association can have multiple targets to allow describing the model as `allOf`, `anyOf`, or `oneOf`\n * schemas. When the association has only one target, then the generated schema cannot have union types.\n *\n * Depending on the schema translation, an association can be embedded as a sub-object in the generated\n * schema, or it can be referenced via a primary key.\n *\n * ## Key Concepts\n *\n * - **Targets**: An association's `targets` specify the entities that this association points to.\n * Each target is defined by:\n * - `key`: The key of the target entity.\n * - `namespace` (optional): The key of the namespace where the target entity is defined.\n * If not specified, it defaults to the current namespace.\n *\n * - **Cardinality**:\n * - `multiple` (boolean): Indicates whether the association allows multiple target entities.\n * If `true`, it's a to-many relationship; otherwise, it's a to-one relationship.\n *\n * - **Schema**:\n * - `schema` (optional): A custom schema for the association, allowing manual definition of the\n * association's structure in specific formats (e.g., JSON, RAML, XML).\n * When provided, this schema overrides the automatically generated schema based on the\n * target entities.\n * - **Important**: If a custom schema is defined and changes are made to the referenced\n * entities, those changes **will not** be automatically propagated to the custom schema.\n * This means the custom schema may become outdated and no longer accurately reflect the\n * structure of the target entities.\n *\n * - **Hidden**:\n * - `hidden`: (boolean) Defines if this association is a part of the schema or not.\n */\nexport class DataAssociation {\n kind = DataAssociationKind\n\n key = ''\n\n /**\n * The description of the data association.\n */\n info: Thing = Thing.fromName('')\n\n /**\n * Wether the data association is required.\n */\n required?: boolean\n\n /**\n * Whether the data association allows multiple items.\n */\n multiple?: boolean\n\n /**\n * The list of keys associated with the entity through this association.\n * An association without a target is considered invalid and discarded when processing the values.\n * When multiple associations are set then we are dealing with an union.\n */\n targets: AssociationTarget[] = []\n\n /**\n * The schema allowing to translate the model into a specific format (like JSON, RAML, XML, etc.)\n *\n * When this is defined then it is used as the schema. When this is not defined it uses\n * referenced entities schemas. Note, changes in the referenced entities may not be propagated\n * to schemas altered by the user.\n */\n schema?: IApiAssociationShape\n\n /**\n * The list of bindings for this property.\n *\n * A binding defines a translation from a data model to a specific format.\n * For example allows to define properties required to generate AMF shape and therefore RAML/OAS shapes for web APIs\n * or a protocol buffer schema.\n */\n bindings: AssociationBinding[] = []\n\n /**\n * Returns true when the association has 0 or 1 targets.\n */\n get isSingle(): boolean {\n return this.targets.length < 2\n }\n\n /**\n * Creates an instance of DataAssociation from a target entity key.\n * Note, this entity will have no name. The default name is used instead.\n *\n * @param root The namespace root.\n * @param target The target entity key.\n * @param namespace The optional key of the target association when different to the current one.\n * @returns A new `DataAssociation` instance.\n */\n static fromTarget(root: DataNamespace, target: string, namespace?: string): DataAssociation {\n const assoc = new DataAssociation(root)\n const info: AssociationTarget = {\n key: target,\n }\n if (namespace) {\n info.namespace = namespace\n }\n assoc.targets = [info]\n return assoc\n }\n\n /**\n * Creates an instance of DataAssociation from a name, without defining a target.\n *\n * @param root The namespace root.\n * @param name The name of the association.\n * @returns A new `DataAssociation` instance.\n */\n static fromName(root: DataNamespace, name: string): DataAssociation {\n const assoc = new DataAssociation(root)\n assoc.info = Thing.fromName(name)\n return assoc\n }\n\n /**\n * @param input The data association definition to restore.\n */\n constructor(\n public root: DataNamespace,\n input?: string | IDataAssociation\n ) {\n let init: IDataAssociation\n if (typeof input === 'string') {\n try {\n init = JSON.parse(input)\n } catch {\n throw new ValidationError([\n {\n field: '',\n message: 'Unable to parse the data association input as JSON.',\n rule: 'object_required',\n },\n ])\n }\n } else if (typeof input === 'object') {\n init = input\n } else {\n init = {\n kind: DataAssociationKind,\n key: v4(),\n info: Thing.fromName('Unnamed association').toJSON(),\n }\n }\n this.new(init)\n }\n\n /**\n * Initializes the association using provided data.\n *\n * @param init - The data association definition to restore.\n */\n new(init: IDataAssociation): this {\n DataAssociation.validate(init)\n const { info, key = v4(), kind = DataAssociationKind, schema, multiple, required, targets, bindings } = init\n this.kind = kind\n this.key = key\n if (info) {\n this.info = new Thing(info)\n } else {\n this.info = Thing.fromName('')\n }\n if (schema) {\n this.schema = Json.clone(schema)\n } else {\n this.schema = undefined\n }\n if (typeof multiple === 'boolean') {\n this.multiple = multiple\n } else {\n this.multiple = undefined\n }\n if (typeof required === 'boolean') {\n this.required = required\n } else {\n this.required = undefined\n }\n if (Array.isArray(targets)) {\n this.targets = targets.map((i) => ({ ...i }))\n } else {\n this.targets = []\n }\n if (Array.isArray(bindings)) {\n this.bindings = bindings.map((i) => Json.clone(i))\n } else {\n this.bindings = []\n }\n return this\n }\n\n /**\n * Validates if the input object is a valid `DataAssociation` definition.\n * Throws a `ValidationError` if the input is invalid.\n *\n * @param input The object to validate.\n * @throws {ValidationError} When the validation fails.\n */\n static validate(input: unknown): void {\n const typed = input as IDataAssociation\n const messages: FieldValidationMessage[] = []\n if (!typed) {\n messages.push({\n field: '',\n message: 'The input is required. None given',\n rule: 'required',\n })\n throw new ValidationError(messages)\n }\n if (typed.kind !== DataAssociationKind) {\n messages.push({\n field: 'kind',\n message: `The kind property must be ${DataAssociationKind}`,\n rule: 'invalid',\n })\n }\n if (typed.info && typeof typed.info !== 'object') {\n messages.push({\n field: 'info',\n message: 'The info property must be an object',\n rule: 'invalid',\n })\n }\n if (messages.length) {\n throw new ValidationError(messages)\n }\n }\n\n /**\n * Generates an object representing the association, suitable for serialization.\n *\n * @returns A plain object representation of the `DataAssociation`.\n */\n toJSON(): IDataAssociation {\n const result: IDataAssociation = {\n kind: DataAssociationKind,\n key: this.key,\n info: this.info.toJSON(),\n }\n if (this.schema) {\n result.schema = Json.clone(this.schema)\n }\n if (typeof this.multiple === 'boolean') {\n result.multiple = this.multiple\n }\n if (typeof this.required === 'boolean') {\n result.required = this.required\n }\n if (Array.isArray(this.targets) && this.targets.length) {\n result.targets = this.targets.map((i) => ({ ...i }))\n }\n if (Array.isArray(this.bindings) && this.bindings.length) {\n result.bindings = this.bindings.map((i) => Json.clone(i))\n }\n return result\n }\n\n /**\n * Retrieves the list of target entities.\n *\n * @returns An array of `DataEntity` instances representing the targets of this association.\n */\n getTargets(): DataEntity[] {\n const { targets } = this\n return this.root.findAssociatedEntities(targets).filter((i) => !!i) as DataEntity[]\n }\n\n /**\n * Removes self from the parent entity and the namespace definition.\n */\n remove(): void {\n const { root } = this\n const entity = root.definitions.entities.find((i) => i.associations.some((j) => j.key === this.key))\n if (entity) {\n const assocIndex = entity.associations.findIndex((i) => i.key === this.key)\n entity.associations.splice(assocIndex, 1)\n }\n const defIndex = this.root.definitions.associations.findIndex((i) => i.key === this.key)\n if (defIndex >= 0) {\n this.root.definitions.associations.splice(defIndex, 1)\n }\n }\n\n /**\n * Adds a target entity to the association.\n * If the entity comes from another namespace then it is set as a foreign entity.\n *\n * @param entity - The `DataEntity` instance to add.\n */\n addTarget(entity: DataEntity): void\n\n /**\n * Adds a target entity to the association.\n *\n * @param entity - The `IDataEntity` definition or just its key.\n * @param namespace - The key of the foreign namespace this entity belongs to.\n * Do not set this value for local entities.\n */\n addTarget(entity: IDataEntity | string, namespace?: string): void\n\n /**\n * @param init The key of an entity, its instance, or schema.\n * @param namespace - The key of the foreign namespace this entity belongs to.\n * Do not set this value for local entities.\n */\n addTarget(init: string | DataEntity | IDataEntity, namespace?: string): void {\n let key: string\n if (typeof init === 'string') {\n key = init\n } else {\n key = init.key\n const typed = init as IDataEntity & { root?: DataNamespace }\n if (!namespace && typed.root && typed.root !== this.root) {\n namespace = typed.root.key\n }\n }\n if (this.targets.some((i) => i.key === key)) {\n const message = `Target ${key} already exists.`\n throw new ValidationError(\n [\n {\n field: 'targets',\n message,\n rule: 'unique',\n },\n ],\n { message }\n )\n }\n if (namespace && namespace !== this.root.key) {\n const foreignNamespace = this.root.foreign.find((ns) => ns.key === namespace)\n if (!foreignNamespace) {\n throw new Error(`Foreign namespace \"${namespace}\" does not exist.`)\n }\n }\n const info: AssociationTarget = {\n key,\n }\n if (namespace) {\n info.namespace = namespace\n }\n this.targets.push(info)\n }\n\n /**\n * Removes a target entity from the targets list.\n *\n * @param init The key of an entity, its instance, or schema.\n */\n removeTarget(init: string | DataEntity | IDataEntity): void {\n let key: string\n if (typeof init === 'string') {\n key = init\n } else {\n key = init.key\n }\n const index = this.targets.findIndex((i) => i.key === key)\n if (index >= 0) {\n this.targets.splice(index, 1)\n }\n }\n\n /**\n * Creates a Property Shape of AMF.\n * The property itself is auto-generated. If the `schema` is defined then it is used\n * as the `range` of the property. Otherwise basic shape is generated for the range.\n *\n * This is a preferred way of reading the AMF shape as this synchronizes changed\n * data properties with the shape definition.\n *\n * @returns AMF property shape definition.\n */\n toApiShape(): IApiPropertyShape {\n const serializer = new AmfShapeGenerator()\n return serializer.associationProperty(this)\n }\n\n /**\n * @deprecated Use the `getParentInstance()` method instead.\n */\n getParent(): DataEntity {\n return this.getParentInstance()\n }\n\n /**\n * Retrieves the parent entity of this association.\n *\n * @returns The `DataEntity` instance that contains this association.\n */\n getParentInstance(): DataEntity {\n // this is forced as an association is only created when an entity is created\n // so it has to be defined.\n return this.root.definitions.entities.find((i) => i.associations.some((a) => a.key === this.key)) as DataEntity\n }\n\n /**\n * Creates the `schema` object if missing and returns it.\n * @returns The schema object.\n */\n ensureSchema(): IApiAssociationShape {\n if (!this.schema) {\n this.schema = {}\n }\n return this.schema\n }\n\n /**\n * Checks whether the passed value is one of the supported data property attributes.\n * @param value The value to test\n * @returns True when the passed value is one of the supported data property attributes.\n */\n static isValidAttribute(value: unknown): value is DataAttributeAttribute {\n if (typeof value !== 'string') {\n return false\n }\n return DataAttributeAttributes.includes(value as DataAttributeAttribute)\n }\n\n /**\n * Creates if not existing and returns web bindings definition.\n * @returns The web binding definition\n */\n getWebBinding(): AssociationWebBindings {\n let object = this.bindings.find((i) => i.type === 'web') as AssociationBinding | undefined\n if (!object) {\n object = { type: 'web', schema: {} } as AssociationBinding\n this.bindings.push(object)\n }\n return object.schema as AssociationWebBindings\n }\n\n /**\n * Returns the schema value of the binding, if any was created.\n * @param type The type of the binding to read.\n * @returns The binding schema, if any\n */\n readBinding(type: 'web' | 'protobuf'): AssociationBindings | undefined {\n const item = this.bindings.find((i) => i.type === type) as AssociationBinding\n return item?.schema\n }\n}\n"]}
@@ -237,6 +237,15 @@ export declare class DataEntity {
237
237
  * @returns `this` for chaining.
238
238
  */
239
239
  addParent(key: string): this;
240
+ /**
241
+ * Removes a parent reference from this entity.
242
+ * It keeps the parent as is.
243
+ *
244
+ * @param key The key of the parent entity to remove.
245
+ * @throws ValidationError when the parent is not found.
246
+ * @returns Self for chaining.
247
+ */
248
+ removeParent(key: string): this;
240
249
  /**
241
250
  * Checks if the entity has a circular parent relationship when attempting to add a new parent.
242
251
  * @param key The key of the parent being added.
@@ -1 +1 @@
1
- {"version":3,"file":"DataEntity.d.ts","sourceRoot":"","sources":["../../../src/modeling/DataEntity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAElD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,aAAa,EAAE,WAAW,E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SAAS,IAAI,SAAS,GAAG,SAAS;IAIlC;;OAEG;IACH,iBAAiB,IAAI,SAAS,GAAG,SAAS;IAI1C;;;;;OAKG;IACH,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IA8D5B;;;;;;;OAOG;IACH,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAmB/B;;;;OAIG;IACH,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAsBvC;;;;;;OAMG;IACH,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,GAAG,OAAO;IAItE;;;;OAIG;IACH,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAMrC;;;;;OAKG;IACF,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC;IAOvD;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,kBAAkB,IAAI,UAAU,EAAE;IAclC,MAAM,CAAC,kBAAkB,CAAC,SAAS,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,GAAG,UAAU,EAAE;IAYpF;;OAEG;IACH,WAAW,IAAI,cAAc,EAAE;IAgC/B;;;;;;OAMG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAgBzB;;;;OAIG;IACH,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAY5B;;;;;;;;;OASG;IACH,UAAU,IAAI,WAAW;IAKzB;;OAEG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,mBAAwB,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS;IAWrG,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO;CAyBlE"}
@@ -491,7 +491,7 @@ export class DataEntity {
491
491
  /**
492
492
  * @deprecated Use the `getParentInstance()` method instead.
493
493
  */
494
- // This method name colides with the `getParents()` method.
494
+ // This method name collides with the `getParents()` method.
495
495
  getParent() {
496
496
  return this.getParentInstance();
497
497
  }
@@ -549,13 +549,36 @@ export class DataEntity {
549
549
  {
550
550
  field: 'parents',
551
551
  message,
552
- rule: 'exists',
552
+ rule: 'unique',
553
553
  },
554
554
  ], { message });
555
555
  }
556
556
  this.parents.push(key);
557
557
  return this;
558
558
  }
559
+ /**
560
+ * Removes a parent reference from this entity.
561
+ * It keeps the parent as is.
562
+ *
563
+ * @param key The key of the parent entity to remove.
564
+ * @throws ValidationError when the parent is not found.
565
+ * @returns Self for chaining.
566
+ */
567
+ removeParent(key) {
568
+ const index = this.parents.findIndex((i) => i === key);
569
+ if (index < 0) {
570
+ const message = `Parent ${key} not found.`;
571
+ throw new ValidationError([
572
+ {
573
+ field: 'parents',
574
+ message,
575
+ rule: 'not-found',
576
+ },
577
+ ], { message });
578
+ }
579
+ this.parents.splice(index, 1);
580
+ return this;
581
+ }
559
582
  /**
560
583
  * Checks if the entity has a circular parent relationship when attempting to add a new parent.
561
584
  * @param key The key of the parent being added.
@@ -1 +1 @@
1
- {"version":3,"file":"DataEntity.js","sourceRoot":"","sources":["../../../src/modeling/DataEntity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAE/B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAEhD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAEtD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAGnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAA;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAA;AAEjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,4CAA4C,CAAA;AACpF,OAAO,EAAE,0BAA0B,EAAE,MAAM,+CAA+C,CAAA;AAC1F,OAAO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AE,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAA;QAClG,KAAK,MAAM,EAAE,IAAI,SAAS,EAAE,CAAC;YAC3B,KAAK,MAAM,EAAE,IAAI,WAAW,EAAE,CAAC;gBAC7B,MAAM,MAAM,GAAG,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,CAAA;gBAC9B,IAAI,MAAM,EAAE,CAAC;oBACX,OAAO,MAAM,CAAA;gBACf,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAA;IACd,CAAC;CACF","sourcesContent":["import { IThing, Thing } from '../models/Thing.js'\nimport v4 from '../lib/uuid.js'\nimport { DataNamespace } from './DataNamespace.js'\nimport { DataProperty } from './DataProperty.js'\nimport { type DataPropertyType } from './DataFormat.js'\nimport { DataAssociation } from './DataAssociation.js'\nimport { FileBreadcrumb } from '../models/store/File.js'\nimport { DataEntityKind } from '../models/kinds.js'\nimport { DataModel } from './DataModel.js'\nimport { IApiNodeShape, IShapeUnion } from '../amf/definitions/Shapes.js'\nimport { AmfShapeGenerator } from '../amf/AmfShapeGenerator.js'\nimport { ApiSchemaGenerator } from '../amf/ApiSchemaGenerator.js'\nimport { IShapeRenderOptions } from '../amf/shape/ShapeBase.js'\nimport { RemovePropertyException } from '../exceptions/remove_property_exception.js'\nimport { RemoveAssociationException } from '../exceptions/remove_association_exception.js'\nimport { ValidationError, type FieldValidationMessage } from '../exceptions/validation_error.js'\nimport { RemoveEntityException } from '../exceptions/remove_entity_exception.js'\nimport { ForeignAssociationException } from '../exceptions/foreign_association_exception.js'\n\ninterface OrderedItem {\n type: 'property' | 'association'\n key: string\n}\n\n/**\n * Data entity is the smallest description of a data in the system\n * It contains properties and associations. At least one entity describe a data model.\n */\nexport interface IDataEntity {\n kind: typeof DataEntityKind\n /**\n * The key of the namespace.\n */\n key: string\n /**\n * The data entity description.\n */\n info: IThing\n\n /**\n * Optional general purpose tags for the UI.\n */\n tags?: string[]\n\n /**\n * For future use.\n *\n * The keys of the taxonomy items associated with the entity.\n */\n taxonomy?: string[]\n\n /**\n * The list of keys of properties that belong to this entity.\n */\n properties?: string[]\n\n /**\n * The list of keys of associations that belong to this entity.\n */\n associations?: string[]\n\n /**\n * The ordered list of fields (properties and associations) in the schema.\n * These only keep references to the properties and associations.\n * The order of the fields is important as it defines the order of the\n * properties in the schema.\n */\n fields?: OrderedItem[]\n\n /**\n * The list of keys of entities that are parents to this entity.\n *\n * This potentially may cause a conflict when two parents declare the same\n * property. In such situation this entity should define own property\n * with the same name to shadow parent property. When the property is\n * not shadowed this may cause unexpected results as the processing could result\n * with inconsistent definition of a schema because the last read property wins.\n *\n * @todo(jarrodek): This should also hold a reference to a namespace to support\n * foreign entities as parents.\n */\n parents?: string[]\n\n /**\n * Whether this entity is deprecated.\n */\n deprecated?: boolean\n\n /**\n * The schema allowing to translate the model into a specific format (like JSON, RAML, XML, etc.)\n */\n schema?: IApiNodeShape\n}\n\n/**\n * Data entity is the smallest description of a data in the system\n * It contains properties and associations. At least one entity describe a data model.\n */\nexport class DataEntity {\n kind = DataEntityKind\n\n key = ''\n\n /**\n * The description of the data namespace.\n */\n info: Thing = Thing.fromName('')\n\n /**\n * Optional general purpose tags for the UI.\n */\n tags: string[] = []\n\n /**\n * Reserved for future use.\n *\n * The keys of the taxonomy items associated with the entity.\n */\n taxonomy: string[] = []\n\n /**\n * The list of keys of properties that belong to this entity.\n */\n properties: DataProperty[] = []\n\n /**\n * The list of keys of associations that belong to this entity.\n */\n associations: DataAssociation[] = []\n\n /**\n * The ordered list of fields (properties and associations) in the schema.\n * These only keep references to the properties and associations.\n * The order of the fields is important as it defines the order of the\n * properties in the schema.\n */\n fields: OrderedItem[] = []\n\n /**\n * The list of keys of entities that are parents to this entity.\n *\n * This potentially may cause a conflict when two parents declare the same\n * property. In such situation this entity should define own property\n * with the same name to shadow parent property. When the property is\n * not shadowed this may cause unexpected results as the processing could result\n * with inconsistent definition of a schema because the last read property wins.\n */\n parents: string[] = []\n\n /**\n * Whether this entity is deprecated.\n */\n deprecated?: boolean\n\n static fromName(root: DataNamespace, name: string): DataEntity {\n const entity = new DataEntity(root)\n entity.info = Thing.fromName(name)\n return entity\n }\n\n /**\n * @param input The data entity definition to restore.\n */\n constructor(\n public root: DataNamespace,\n input?: string | IDataEntity\n ) {\n let init: IDataEntity\n if (typeof input === 'string') {\n init = JSON.parse(input)\n } else if (typeof input === 'object') {\n init = input\n } else {\n init = {\n kind: DataEntityKind,\n key: v4(),\n info: Thing.fromName('').toJSON(),\n }\n }\n this.new(init)\n }\n\n new(init: IDataEntity): void {\n DataEntity.validate(init)\n const {\n info,\n key = v4(),\n kind = DataEntityKind,\n tags,\n taxonomy,\n parents,\n properties,\n associations,\n fields,\n deprecated,\n } = init\n this.kind = kind\n this.key = key\n if (info) {\n this.info = new Thing(info)\n } else {\n this.info = Thing.fromName('')\n }\n if (Array.isArray(tags)) {\n this.tags = [...tags]\n } else {\n this.tags = []\n }\n if (Array.isArray(taxonomy)) {\n this.taxonomy = [...taxonomy]\n } else {\n this.taxonomy = []\n }\n if (Array.isArray(parents)) {\n this.parents = [...parents]\n } else {\n this.parents = []\n }\n this.properties = []\n if (Array.isArray(properties)) {\n properties.forEach((key) => {\n const value = this._readProperty(key)\n if (value) {\n this.properties.push(value)\n }\n })\n }\n this.associations = []\n if (Array.isArray(associations)) {\n associations.forEach((key) => {\n const value = this._readAssociation(key)\n if (value) {\n this.associations.push(value)\n }\n })\n }\n if (Array.isArray(fields)) {\n this.fields = [...fields]\n } else {\n this.fields = this.createOrderedFields()\n }\n if (typeof deprecated === 'boolean') {\n this.deprecated = deprecated\n } else {\n this.deprecated = undefined\n }\n }\n\n private createOrderedFields(): OrderedItem[] {\n const result: OrderedItem[] = []\n this.properties.forEach((i) => {\n result.push({\n type: 'property',\n key: i.key,\n })\n })\n this.associations.forEach((i) => {\n result.push({\n type: 'association',\n key: i.key,\n })\n })\n return result\n }\n\n static validate(input: unknown): void {\n const typed = input as IDataEntity\n const messages: FieldValidationMessage[] = []\n if (!typed) {\n messages.push({\n field: '',\n message: 'The input is required. None given',\n rule: 'required',\n })\n throw new ValidationError(messages)\n }\n if (typed.kind !== DataEntityKind) {\n messages.push({\n field: 'kind',\n message: `The kind property must be ${DataEntityKind}`,\n rule: 'invalid',\n })\n }\n if (messages.length) {\n throw new ValidationError(messages, { message: 'Invalid data entity definition.' })\n }\n }\n\n toJSON(): IDataEntity {\n const result: IDataEntity = {\n kind: DataEntityKind,\n key: this.key,\n info: this.info.toJSON(),\n }\n if (Array.isArray(this.tags) && this.tags.length) {\n result.tags = [...this.tags]\n }\n if (Array.isArray(this.taxonomy) && this.taxonomy.length) {\n result.taxonomy = [...this.taxonomy]\n }\n if (Array.isArray(this.parents) && this.parents.length) {\n result.parents = [...this.parents]\n }\n if (Array.isArray(this.properties) && this.properties.length) {\n result.properties = this.properties.map((i) => i.key)\n }\n if (Array.isArray(this.associations) && this.associations.length) {\n result.associations = this.associations.map((i) => i.key)\n }\n if (Array.isArray(this.fields) && this.fields.length) {\n result.fields = [...this.fields]\n }\n if (Array.isArray(this.taxonomy) && this.taxonomy.length) {\n result.taxonomy = [...this.taxonomy]\n }\n if (Array.isArray(this.tags) && this.tags.length) {\n result.tags = [...this.tags]\n }\n if (typeof this.deprecated === 'boolean') {\n result.deprecated = this.deprecated\n }\n return result\n }\n\n protected _readAssociation(key: string): DataAssociation | undefined {\n return this.root.definitions.associations.find((i) => i.key === key)\n }\n\n protected _readProperty(key: string): DataProperty | undefined {\n return this.root.definitions.properties.find((i) => i.key === key)\n }\n\n /**\n * Creates a property with a passed type.\n * @param type The type of the property\n * @returns The created property\n */\n addTypedProperty(type: DataPropertyType, name?: string): DataProperty {\n const property = DataProperty.fromType(this.root, type)\n if (name) {\n property.info.name = name\n }\n this.root.definitions.properties.push(property)\n this.properties.push(property)\n this.fields.push({ type: 'property', key: property.key })\n return property\n }\n\n /**\n * Creates a property with a passed type.\n * @param name The name of the property.\n * @returns The created property\n */\n addNamedProperty(name: string): DataProperty {\n const property = DataProperty.fromName(this.root, name)\n this.root.definitions.properties.push(property)\n this.properties.push(property)\n this.fields.push({ type: 'property', key: property.key })\n return property\n }\n\n /**\n * Removes the property from the entity and namespace definitions.\n * @param key The key of the property to remove.\n */\n removeProperty(key: string): void {\n const thisIndex = this.properties.findIndex((i) => i.key === key)\n if (thisIndex < 0) {\n throw new RemovePropertyException(`Trying to remove the ${key} property, but it doesn't exist.`)\n }\n const propertyToRemove = this.properties[thisIndex]\n this.properties.splice(thisIndex, 1)\n const defIndex = this.root.definitions.properties.findIndex((i) => i.key === key)\n if (defIndex >= 0) {\n this.root.definitions.properties.splice(defIndex, 1)\n }\n this.removeField(key)\n propertyToRemove.remove()\n }\n\n private removeField(key: string): void {\n this.fields = this.fields.filter((item) => item.key !== key)\n }\n\n /**\n * Lists all properties for this Entity.\n * @returns The list of properties that belong to this entity.\n */\n listProperties(): DataProperty[] {\n return [...this.properties]\n }\n\n /**\n * Lists all associations for this Entity.\n * @returns The list of associations that belong to this entity.\n */\n listAssociations(): DataAssociation[] {\n return [...this.associations]\n }\n\n /**\n * Generates an ordered list of fields (properties and associations) for this entity.\n *\n * @returns The list of fields (properties and associations) that belong to this entity.\n */\n listFields(): (DataAssociation | DataProperty)[] {\n const result: (DataAssociation | DataProperty)[] = []\n this.fields.forEach((i) => {\n if (i.type === 'property') {\n const property = this.properties.find((p) => p.key === i.key)\n if (property) {\n result.push(property)\n }\n } else if (i.type === 'association') {\n const association = this.associations.find((a) => a.key === i.key)\n if (association) {\n result.push(association)\n }\n }\n })\n return result\n }\n\n /**\n * Moves the field to a new index.\n * @param key The key of the field to move.\n * @param toIndex The new index to which move the field to.\n */\n moveField(key: string, toIndex: number): void {\n const fromIndex = this.fields.findIndex((i) => i.key === key)\n if (fromIndex < 0) {\n throw new ValidationError([{ field: 'fields', message: `Field ${key} not found.`, rule: 'not-found' }])\n }\n if (toIndex < 0 || toIndex >= this.fields.length) {\n throw new ValidationError([{ field: 'fields', message: `Invalid index ${toIndex}.`, rule: 'invalid' }])\n }\n const [item] = this.fields.splice(fromIndex, 1)\n this.fields.splice(toIndex, 0, item)\n }\n\n /**\n * Creates an association for a given name, adds it to definitions, and returns it.\n * @param name The name of the association\n * @returns The created association\n */\n addNamedAssociation(name: string): DataAssociation {\n const result = DataAssociation.fromName(this.root, name)\n this.root.definitions.associations.push(result)\n this.associations.push(result)\n this.fields.push({ type: 'association', key: result.key })\n return result\n }\n\n /**\n * Creates an association for a given target, adds it to definitions, and returns it.\n *\n * @param target The target entity key of the association\n * @param namespace The target entity namespace when different to the current namespace.\n * @param name Optional name.\n * @returns The created association\n */\n addTargetAssociation(target: string | DataEntity, name?: string): DataAssociation {\n let key: string\n if (typeof target === 'string') {\n key = target\n } else {\n key = target.key\n }\n const result = DataAssociation.fromTarget(this.root, key)\n if (name) {\n result.info.name = name\n }\n this.root.definitions.associations.push(result)\n this.associations.push(result)\n this.fields.push({ type: 'association', key: result.key })\n return result\n }\n\n /**\n * Creates an association for a given target that is in another namespace\n * @param target The target entity key of the association\n * @param namespace The target entity namespace when different to the current namespace.\n * @param name Optional name.\n * @returns The created association\n */\n addForeignAssociation(target: string | DataEntity, namespace: string, name?: string): DataAssociation {\n let key: string\n if (typeof target === 'string') {\n key = target\n } else {\n key = target.key\n }\n if (!this.root.hasForeignNamespace(namespace)) {\n throw new ForeignAssociationException(\n `Trying to add a foreign association but the foreign namespace is not defined.`\n )\n }\n const result = DataAssociation.fromTarget(this.root, key, namespace)\n if (name) {\n result.info.name = name\n }\n this.root.definitions.associations.push(result)\n this.associations.push(result)\n this.fields.push({ type: 'association', key: result.key })\n return result\n }\n\n /**\n * Removes an association from the entity and, namespace definitions.\n * @param key The key of the association to remove.\n */\n removeAssociation(key: string): void {\n const thisIndex = this.associations.findIndex((i) => i.key === key)\n if (thisIndex < 0) {\n // return\n throw new RemoveAssociationException(`Trying to remove the ${key} association, but it doesn't exist.`)\n }\n const associationToRemove = this.associations[thisIndex]\n this.associations.splice(thisIndex, 1)\n const defIndex = this.root.definitions.associations.findIndex((i) => i.key === key)\n if (defIndex >= 0) {\n this.root.definitions.associations.splice(defIndex, 1)\n }\n this.removeField(key)\n associationToRemove.remove()\n }\n\n /**\n * Reads the list of parents for the entity, inside the root namespace. The computed list contains the list of all\n * parents in the inheritance chain in no particular order.\n * @param recursive Whether to include parent parents as well.\n */\n getComputedParents(recursive?: boolean): DataEntity[] {\n const { entities } = this.root.definitions\n let result: DataEntity[] = []\n this.parents.forEach((key) => {\n const parent = entities.find((i) => i.key === key)\n if (parent) {\n result.push(parent)\n if (recursive) {\n result = result.concat(parent.getComputedParents())\n }\n }\n })\n return result\n }\n\n /**\n * Computes list of all children, inside the root namespace, that extends this entity.\n * The children are not ordered.\n */\n getComputedChildren(): DataEntity[] {\n const { entities } = this.root.definitions\n return entities.filter((i) => i.parents.includes(this.key))\n }\n\n /**\n * Computes a list of entities that are associated with the current entity.\n */\n getComputedAssociations(): DataEntity[] {\n const { associations } = this\n const result: DataEntity[] = []\n associations.forEach((assoc) => {\n if (!assoc.targets.length) {\n return\n }\n const entities = this.root.findAssociatedEntities(assoc.targets)\n entities.forEach((entity) => {\n if (entity) {\n result.push(entity)\n }\n })\n })\n return result\n }\n\n /**\n * Removes self from the namespace with all properties and attributes.\n */\n remove(): void {\n const { key, properties, associations, root } = this\n // check if some entity has reference to this entity as a target\n const associationsToEntity = this.root.definitions.associations.filter((a) =>\n a.targets.some((t) => t.key === this.key)\n )\n if (associationsToEntity.length > 0) {\n const entitiesNames = associationsToEntity.reduce<string[]>((acc, association) => {\n const entity = root.definitions.entities.find((e) => e.associations.some((a) => a.key === association.key))\n if (entity) {\n acc.push(entity.info.name as string)\n }\n return acc\n }, [])\n throw new RemoveEntityException(\n `Cannot remove entity ${this.info.name} because it is used as a target in associations in entities: ${entitiesNames.join(', ')}.`\n )\n }\n\n // remove own stuff\n properties.forEach((p) => this.removeProperty(p.key))\n associations.forEach((a) => this.removeAssociation(a.key))\n // remove from the root\n const index = root.definitions.entities.findIndex((i) => i.key === key)\n if (index >= 0) {\n root.definitions.entities.splice(index, 1)\n }\n // remove from the parent\n const model = this.getParentInstance()\n if (model) {\n const entityIndex = model.entities.findIndex((e) => e.key === this.key)\n model.entities.splice(entityIndex, 1)\n }\n }\n\n /**\n * @deprecated Use the `getParentInstance()` method instead.\n */\n // This method name colides with the `getParents()` method.\n getParent(): DataModel | undefined {\n return this.getParentInstance()\n }\n\n /**\n * Returns a parent data model where this entity exist.\n */\n getParentInstance(): DataModel | undefined {\n return this.root.definitions.models.find((m) => m.entities.some((e) => e.key === this.key))\n }\n\n /**\n * Adds a parent reference to this entity.\n * This will not add the parent to the namespace. It only adds a reference to the parent.\n * @param key The key of the parent entity to add.\n * @returns `this` for chaining.\n */\n addParent(key: string): this {\n // Prevent adding self as parent\n if (key === this.key) {\n const message = 'Entity cannot be a parent of itself.'\n throw new ValidationError(\n [\n {\n field: 'parents',\n message,\n rule: 'circular',\n },\n ],\n { message }\n )\n }\n // check if parent exists\n const parent = this.root.definitions.entities.find((i) => i.key === key)\n if (!parent) {\n const message = `Entity with key \"${key}\" not found.`\n throw new ValidationError(\n [\n {\n field: 'parents',\n message,\n rule: 'not-exists',\n },\n ],\n { message }\n )\n }\n // Check for circular inheritance\n if (this.hasCircularParent(key)) {\n const message = `Circular inheritance detected. Cannot add ${key} as a parent.`\n throw new ValidationError(\n [\n {\n field: 'parents',\n message,\n rule: 'circular',\n },\n ],\n { message }\n )\n }\n const has = this.parents.some((i) => i === key)\n if (has) {\n const message = `Parent ${key} already exists.`\n throw new ValidationError(\n [\n {\n field: 'parents',\n message,\n rule: 'exists',\n },\n ],\n { message }\n )\n }\n this.parents.push(key)\n return this\n }\n\n /**\n * Checks if the entity has a circular parent relationship when attempting to add a new parent.\n * @param key The key of the parent being added.\n * @returns true if adding this parent would create a circular relationship.\n */\n hasCircularParent(key: string): boolean {\n const { entities } = this.root.definitions\n // Check if new parent is one of the children.\n const children = this.getComputedChildren()\n if (children.some((c) => c.key === key)) {\n return true\n }\n // check if this entity is in parents chain.\n let current: DataEntity | undefined = entities.find((e) => e.key === key)\n while (current) {\n if (current.key === this.key) {\n return true\n }\n // for (const parentKey of current.parents) {\n // current = parentKey ? entities.find((e) => e.key === parentKey) : undefined\n // }\n const parentKey = current.parents[0] // Assuming single inheritance\n current = parentKey ? entities.find((e) => e.key === parentKey) : undefined\n }\n return false\n }\n\n /**\n * Tests whether one entity is associated with another.\n *\n * @param entity1 The source entity\n * @param entity2 The target entity\n * @returns true when there's any path from one entity to another.\n */\n static isAssociated(entity1: DataEntity, entity2: DataEntity): boolean {\n return entity1.isAssociated(entity2.key)\n }\n\n /**\n * Tests whether this entity is somehow associated with another entity.\n * @param target The key of the target entity to test for association with.\n * @returns true if this entity has any association to the `target` entity.\n */\n isAssociated(target: string): boolean {\n const it = this.associationPath(target)\n const path = it.next().value\n return !!path\n }\n\n /**\n * Prints out all associations from one entity to another through all entities that may be in between.\n * @param toEntity The key to the target entity\n * @yields The path containing keys of entities from this entity to the `toEntity`\n * (inclusive) and all entities in between.\n */\n *associationPath(toEntity: string): Generator<string[]> {\n const graph = this.root.associationGraph()\n for (const path of this.root.associationPath(this.key, toEntity, graph)) {\n yield path\n }\n }\n\n /**\n * Returns a list of entities that are associated with this entity as a target.\n *\n * This method identifies entities that have an association where this entity is a target.\n * In other words, it finds entities that \"point to\" this entity through an association.\n *\n * For example, consider the following relationships:\n *\n * ```plain\n * A -> B (A has an association that targets B)\n * C -> B (C has an association that targets B)\n * B -> D (B has an association that targets D)\n *\n * Calling `getRelatedEntities()` on B would return [A, C]\n * Calling `getRelatedEntities()` on D would return [B]\n * Calling `getRelatedEntities()` on A would return []\n * ```\n *\n * Note, this method only returns entities that are directly associated with this entity as a target.\n * It does not traverse the association graph to find indirectly related entities.\n *\n * @returns An array of `DataEntity` instances that have an association targeting this entity.\n */\n getRelatedEntities(): DataEntity[] {\n const { key, root } = this\n const result = DataEntity.getRelatedEntities(root, key)\n root.foreign.forEach((ns) => {\n const other = DataEntity.getRelatedEntities(ns, key)\n other.forEach((entity) => {\n if (!result.includes(entity)) {\n result.push(entity)\n }\n })\n })\n return result\n }\n\n static getRelatedEntities(namespace: DataNamespace, entityKey: string): DataEntity[] {\n const result: DataEntity[] = []\n const inverse = namespace.definitions.associations.filter((i) => i.targets.some((j) => j.key === entityKey))\n inverse.forEach((assoc) => {\n const entity = namespace.definitions.entities.find((e) => e.associations.includes(assoc))\n if (entity && !result.includes(entity)) {\n result.push(entity)\n }\n })\n return result\n }\n\n /**\n * Creates breadcrumbs from this entity to the root namespace.\n */\n breadcrumbs(): FileBreadcrumb[] {\n const result: FileBreadcrumb[] = []\n result.push({\n key: this.key,\n name: this.info.name || 'Unnamed entity',\n kind: DataEntityKind,\n })\n const model = this.getParentInstance()\n if (model) {\n result.push({\n key: model.key,\n kind: model.kind,\n name: model.info.name || 'Unnamed data model',\n })\n let parent = model.getParentInstance()\n while (parent && parent !== this.root) {\n result.push({\n key: parent.key,\n kind: parent.kind,\n name: parent.info.name || 'Unnamed namespace',\n })\n parent = parent.getParentInstance()\n }\n }\n result.push({\n key: this.root.key,\n name: this.root.info.name || 'Unnamed namespace',\n kind: this.root.kind,\n })\n return result.reverse()\n }\n\n /**\n * Adds a new tag to the property. It also populates the root namespace's tags when tag is new.\n *\n * Note, it does nothing when the tag is already defined.\n *\n * @param tag The tag to add.\n */\n addTag(tag: string): void {\n if (!tag) {\n return\n }\n const lower = tag.toLowerCase()\n const { tags } = this\n if (tags.some((t) => t.toLowerCase() === lower)) {\n return\n }\n tags.push(tag)\n const { definitions } = this.root\n if (!definitions.tags.some((t) => t.toLowerCase() === lower)) {\n definitions.tags.push(tag)\n }\n }\n\n /**\n * Removes a tag from the property. Unlike the `addTag()` this won't remove a `tag` from the root namespace.\n *\n * @param tag The tag to remove.\n */\n removeTag(tag: string): void {\n if (!tag) {\n return\n }\n const lower = tag.toLowerCase()\n const { tags } = this\n const index = tags.findIndex((t) => t.toLowerCase() === lower)\n if (index >= 0) {\n tags.splice(index, 1)\n }\n }\n\n /**\n * Creates a Shape of AMF.\n * The property itself is auto-generated. If the `schema` is defined then it is used\n * as the `range` of the property. Otherwise basic shape is generated for the range.\n *\n * This is a preferred way of reading the AMF shape as this synchronizes changed\n * data properties with the shape definition.\n *\n * @returns AMF property shape definition.\n */\n toApiShape(): IShapeUnion {\n const serializer = new AmfShapeGenerator()\n return serializer.entity(this)\n }\n\n /**\n * Reads the schema of the Entity and generates an example for it.\n */\n toExample(mime: string, opts: IShapeRenderOptions = {}): string | number | boolean | null | undefined {\n const shape = this.toApiShape()\n const generator = new ApiSchemaGenerator(mime, {\n renderExamples: typeof opts.renderExamples === 'boolean' ? opts.renderExamples : true,\n renderMocked: typeof opts.renderMocked === 'boolean' ? opts.renderMocked : true,\n renderOptional: typeof opts.renderOptional === 'boolean' ? opts.renderOptional : true,\n selectedUnions: opts.selectedUnions,\n })\n return generator.generate(shape)\n }\n\n hasClosedCycle(rootEntity: string, targetEntity: string): boolean {\n if (targetEntity === this.key) {\n // self association\n return true\n }\n const g = this.root.associationGraph()\n const selfPaths: string[][] = []\n const targetPaths: string[][] = []\n for (const path of this.root.associationPath(rootEntity, this.key, g)) {\n selfPaths.push(path)\n }\n for (const path of this.root.associationPath(targetEntity, this.key, g)) {\n targetPaths.push(path)\n }\n const checker = (arr: string[], target: string[]): boolean => target.every((v) => arr.includes(v))\n for (const sp of selfPaths) {\n for (const tp of targetPaths) {\n const result = checker(sp, tp)\n if (result) {\n return result\n }\n }\n }\n return false\n }\n}\n"]}
1
+ {"version":3,"file":"DataEntity.js","sourceRoot":"","sources":["../../../src/modeling/DataEntity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAE/B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAEhD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;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AAK,CAAC,CAAA;IAClC,CAAC;IAED,cAAc,CAAC,UAAkB,EAAE,YAAoB;QACrD,IAAI,YAAY,KAAK,IAAI,CAAC,GAAG,EAAE,CAAC;YAC9B,mBAAmB;YACnB,OAAO,IAAI,CAAA;QACb,CAAC;QACD,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAA;QACtC,MAAM,SAAS,GAAe,EAAE,CAAA;QAChC,MAAM,WAAW,GAAe,EAAE,CAAA;QAClC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC;YACtE,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACtB,CAAC;QACD,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,YAAY,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC;YACxE,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACxB,CAAC;QACD,MAAM,OAAO,GAAG,CAAC,GAAa,EAAE,MAAgB,EAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAA;QAClG,KAAK,MAAM,EAAE,IAAI,SAAS,EAAE,CAAC;YAC3B,KAAK,MAAM,EAAE,IAAI,WAAW,EAAE,CAAC;gBAC7B,MAAM,MAAM,GAAG,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,CAAA;gBAC9B,IAAI,MAAM,EAAE,CAAC;oBACX,OAAO,MAAM,CAAA;gBACf,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAA;IACd,CAAC;CACF","sourcesContent":["import { IThing, Thing } from '../models/Thing.js'\nimport v4 from '../lib/uuid.js'\nimport { DataNamespace } from './DataNamespace.js'\nimport { DataProperty } from './DataProperty.js'\nimport { type DataPropertyType } from './DataFormat.js'\nimport { DataAssociation } from './DataAssociation.js'\nimport { FileBreadcrumb } from '../models/store/File.js'\nimport { DataEntityKind } from '../models/kinds.js'\nimport { DataModel } from './DataModel.js'\nimport { IApiNodeShape, IShapeUnion } from '../amf/definitions/Shapes.js'\nimport { AmfShapeGenerator } from '../amf/AmfShapeGenerator.js'\nimport { ApiSchemaGenerator } from '../amf/ApiSchemaGenerator.js'\nimport { IShapeRenderOptions } from '../amf/shape/ShapeBase.js'\nimport { RemovePropertyException } from '../exceptions/remove_property_exception.js'\nimport { RemoveAssociationException } from '../exceptions/remove_association_exception.js'\nimport { ValidationError, type FieldValidationMessage } from '../exceptions/validation_error.js'\nimport { RemoveEntityException } from '../exceptions/remove_entity_exception.js'\nimport { ForeignAssociationException } from '../exceptions/foreign_association_exception.js'\n\ninterface OrderedItem {\n type: 'property' | 'association'\n key: string\n}\n\n/**\n * Data entity is the smallest description of a data in the system\n * It contains properties and associations. At least one entity describe a data model.\n */\nexport interface IDataEntity {\n kind: typeof DataEntityKind\n /**\n * The key of the namespace.\n */\n key: string\n /**\n * The data entity description.\n */\n info: IThing\n\n /**\n * Optional general purpose tags for the UI.\n */\n tags?: string[]\n\n /**\n * For future use.\n *\n * The keys of the taxonomy items associated with the entity.\n */\n taxonomy?: string[]\n\n /**\n * The list of keys of properties that belong to this entity.\n */\n properties?: string[]\n\n /**\n * The list of keys of associations that belong to this entity.\n */\n associations?: string[]\n\n /**\n * The ordered list of fields (properties and associations) in the schema.\n * These only keep references to the properties and associations.\n * The order of the fields is important as it defines the order of the\n * properties in the schema.\n */\n fields?: OrderedItem[]\n\n /**\n * The list of keys of entities that are parents to this entity.\n *\n * This potentially may cause a conflict when two parents declare the same\n * property. In such situation this entity should define own property\n * with the same name to shadow parent property. When the property is\n * not shadowed this may cause unexpected results as the processing could result\n * with inconsistent definition of a schema because the last read property wins.\n *\n * @todo(jarrodek): This should also hold a reference to a namespace to support\n * foreign entities as parents.\n */\n parents?: string[]\n\n /**\n * Whether this entity is deprecated.\n */\n deprecated?: boolean\n\n /**\n * The schema allowing to translate the model into a specific format (like JSON, RAML, XML, etc.)\n */\n schema?: IApiNodeShape\n}\n\n/**\n * Data entity is the smallest description of a data in the system\n * It contains properties and associations. At least one entity describe a data model.\n */\nexport class DataEntity {\n kind = DataEntityKind\n\n key = ''\n\n /**\n * The description of the data namespace.\n */\n info: Thing = Thing.fromName('')\n\n /**\n * Optional general purpose tags for the UI.\n */\n tags: string[] = []\n\n /**\n * Reserved for future use.\n *\n * The keys of the taxonomy items associated with the entity.\n */\n taxonomy: string[] = []\n\n /**\n * The list of keys of properties that belong to this entity.\n */\n properties: DataProperty[] = []\n\n /**\n * The list of keys of associations that belong to this entity.\n */\n associations: DataAssociation[] = []\n\n /**\n * The ordered list of fields (properties and associations) in the schema.\n * These only keep references to the properties and associations.\n * The order of the fields is important as it defines the order of the\n * properties in the schema.\n */\n fields: OrderedItem[] = []\n\n /**\n * The list of keys of entities that are parents to this entity.\n *\n * This potentially may cause a conflict when two parents declare the same\n * property. In such situation this entity should define own property\n * with the same name to shadow parent property. When the property is\n * not shadowed this may cause unexpected results as the processing could result\n * with inconsistent definition of a schema because the last read property wins.\n */\n parents: string[] = []\n\n /**\n * Whether this entity is deprecated.\n */\n deprecated?: boolean\n\n static fromName(root: DataNamespace, name: string): DataEntity {\n const entity = new DataEntity(root)\n entity.info = Thing.fromName(name)\n return entity\n }\n\n /**\n * @param input The data entity definition to restore.\n */\n constructor(\n public root: DataNamespace,\n input?: string | IDataEntity\n ) {\n let init: IDataEntity\n if (typeof input === 'string') {\n init = JSON.parse(input)\n } else if (typeof input === 'object') {\n init = input\n } else {\n init = {\n kind: DataEntityKind,\n key: v4(),\n info: Thing.fromName('').toJSON(),\n }\n }\n this.new(init)\n }\n\n new(init: IDataEntity): void {\n DataEntity.validate(init)\n const {\n info,\n key = v4(),\n kind = DataEntityKind,\n tags,\n taxonomy,\n parents,\n properties,\n associations,\n fields,\n deprecated,\n } = init\n this.kind = kind\n this.key = key\n if (info) {\n this.info = new Thing(info)\n } else {\n this.info = Thing.fromName('')\n }\n if (Array.isArray(tags)) {\n this.tags = [...tags]\n } else {\n this.tags = []\n }\n if (Array.isArray(taxonomy)) {\n this.taxonomy = [...taxonomy]\n } else {\n this.taxonomy = []\n }\n if (Array.isArray(parents)) {\n this.parents = [...parents]\n } else {\n this.parents = []\n }\n this.properties = []\n if (Array.isArray(properties)) {\n properties.forEach((key) => {\n const value = this._readProperty(key)\n if (value) {\n this.properties.push(value)\n }\n })\n }\n this.associations = []\n if (Array.isArray(associations)) {\n associations.forEach((key) => {\n const value = this._readAssociation(key)\n if (value) {\n this.associations.push(value)\n }\n })\n }\n if (Array.isArray(fields)) {\n this.fields = [...fields]\n } else {\n this.fields = this.createOrderedFields()\n }\n if (typeof deprecated === 'boolean') {\n this.deprecated = deprecated\n } else {\n this.deprecated = undefined\n }\n }\n\n private createOrderedFields(): OrderedItem[] {\n const result: OrderedItem[] = []\n this.properties.forEach((i) => {\n result.push({\n type: 'property',\n key: i.key,\n })\n })\n this.associations.forEach((i) => {\n result.push({\n type: 'association',\n key: i.key,\n })\n })\n return result\n }\n\n static validate(input: unknown): void {\n const typed = input as IDataEntity\n const messages: FieldValidationMessage[] = []\n if (!typed) {\n messages.push({\n field: '',\n message: 'The input is required. None given',\n rule: 'required',\n })\n throw new ValidationError(messages)\n }\n if (typed.kind !== DataEntityKind) {\n messages.push({\n field: 'kind',\n message: `The kind property must be ${DataEntityKind}`,\n rule: 'invalid',\n })\n }\n if (messages.length) {\n throw new ValidationError(messages, { message: 'Invalid data entity definition.' })\n }\n }\n\n toJSON(): IDataEntity {\n const result: IDataEntity = {\n kind: DataEntityKind,\n key: this.key,\n info: this.info.toJSON(),\n }\n if (Array.isArray(this.tags) && this.tags.length) {\n result.tags = [...this.tags]\n }\n if (Array.isArray(this.taxonomy) && this.taxonomy.length) {\n result.taxonomy = [...this.taxonomy]\n }\n if (Array.isArray(this.parents) && this.parents.length) {\n result.parents = [...this.parents]\n }\n if (Array.isArray(this.properties) && this.properties.length) {\n result.properties = this.properties.map((i) => i.key)\n }\n if (Array.isArray(this.associations) && this.associations.length) {\n result.associations = this.associations.map((i) => i.key)\n }\n if (Array.isArray(this.fields) && this.fields.length) {\n result.fields = [...this.fields]\n }\n if (Array.isArray(this.taxonomy) && this.taxonomy.length) {\n result.taxonomy = [...this.taxonomy]\n }\n if (Array.isArray(this.tags) && this.tags.length) {\n result.tags = [...this.tags]\n }\n if (typeof this.deprecated === 'boolean') {\n result.deprecated = this.deprecated\n }\n return result\n }\n\n protected _readAssociation(key: string): DataAssociation | undefined {\n return this.root.definitions.associations.find((i) => i.key === key)\n }\n\n protected _readProperty(key: string): DataProperty | undefined {\n return this.root.definitions.properties.find((i) => i.key === key)\n }\n\n /**\n * Creates a property with a passed type.\n * @param type The type of the property\n * @returns The created property\n */\n addTypedProperty(type: DataPropertyType, name?: string): DataProperty {\n const property = DataProperty.fromType(this.root, type)\n if (name) {\n property.info.name = name\n }\n this.root.definitions.properties.push(property)\n this.properties.push(property)\n this.fields.push({ type: 'property', key: property.key })\n return property\n }\n\n /**\n * Creates a property with a passed type.\n * @param name The name of the property.\n * @returns The created property\n */\n addNamedProperty(name: string): DataProperty {\n const property = DataProperty.fromName(this.root, name)\n this.root.definitions.properties.push(property)\n this.properties.push(property)\n this.fields.push({ type: 'property', key: property.key })\n return property\n }\n\n /**\n * Removes the property from the entity and namespace definitions.\n * @param key The key of the property to remove.\n */\n removeProperty(key: string): void {\n const thisIndex = this.properties.findIndex((i) => i.key === key)\n if (thisIndex < 0) {\n throw new RemovePropertyException(`Trying to remove the ${key} property, but it doesn't exist.`)\n }\n const propertyToRemove = this.properties[thisIndex]\n this.properties.splice(thisIndex, 1)\n const defIndex = this.root.definitions.properties.findIndex((i) => i.key === key)\n if (defIndex >= 0) {\n this.root.definitions.properties.splice(defIndex, 1)\n }\n this.removeField(key)\n propertyToRemove.remove()\n }\n\n private removeField(key: string): void {\n this.fields = this.fields.filter((item) => item.key !== key)\n }\n\n /**\n * Lists all properties for this Entity.\n * @returns The list of properties that belong to this entity.\n */\n listProperties(): DataProperty[] {\n return [...this.properties]\n }\n\n /**\n * Lists all associations for this Entity.\n * @returns The list of associations that belong to this entity.\n */\n listAssociations(): DataAssociation[] {\n return [...this.associations]\n }\n\n /**\n * Generates an ordered list of fields (properties and associations) for this entity.\n *\n * @returns The list of fields (properties and associations) that belong to this entity.\n */\n listFields(): (DataAssociation | DataProperty)[] {\n const result: (DataAssociation | DataProperty)[] = []\n this.fields.forEach((i) => {\n if (i.type === 'property') {\n const property = this.properties.find((p) => p.key === i.key)\n if (property) {\n result.push(property)\n }\n } else if (i.type === 'association') {\n const association = this.associations.find((a) => a.key === i.key)\n if (association) {\n result.push(association)\n }\n }\n })\n return result\n }\n\n /**\n * Moves the field to a new index.\n * @param key The key of the field to move.\n * @param toIndex The new index to which move the field to.\n */\n moveField(key: string, toIndex: number): void {\n const fromIndex = this.fields.findIndex((i) => i.key === key)\n if (fromIndex < 0) {\n throw new ValidationError([{ field: 'fields', message: `Field ${key} not found.`, rule: 'not-found' }])\n }\n if (toIndex < 0 || toIndex >= this.fields.length) {\n throw new ValidationError([{ field: 'fields', message: `Invalid index ${toIndex}.`, rule: 'invalid' }])\n }\n const [item] = this.fields.splice(fromIndex, 1)\n this.fields.splice(toIndex, 0, item)\n }\n\n /**\n * Creates an association for a given name, adds it to definitions, and returns it.\n * @param name The name of the association\n * @returns The created association\n */\n addNamedAssociation(name: string): DataAssociation {\n const result = DataAssociation.fromName(this.root, name)\n this.root.definitions.associations.push(result)\n this.associations.push(result)\n this.fields.push({ type: 'association', key: result.key })\n return result\n }\n\n /**\n * Creates an association for a given target, adds it to definitions, and returns it.\n *\n * @param target The target entity key of the association\n * @param namespace The target entity namespace when different to the current namespace.\n * @param name Optional name.\n * @returns The created association\n */\n addTargetAssociation(target: string | DataEntity, name?: string): DataAssociation {\n let key: string\n if (typeof target === 'string') {\n key = target\n } else {\n key = target.key\n }\n const result = DataAssociation.fromTarget(this.root, key)\n if (name) {\n result.info.name = name\n }\n this.root.definitions.associations.push(result)\n this.associations.push(result)\n this.fields.push({ type: 'association', key: result.key })\n return result\n }\n\n /**\n * Creates an association for a given target that is in another namespace\n * @param target The target entity key of the association\n * @param namespace The target entity namespace when different to the current namespace.\n * @param name Optional name.\n * @returns The created association\n */\n addForeignAssociation(target: string | DataEntity, namespace: string, name?: string): DataAssociation {\n let key: string\n if (typeof target === 'string') {\n key = target\n } else {\n key = target.key\n }\n if (!this.root.hasForeignNamespace(namespace)) {\n throw new ForeignAssociationException(\n `Trying to add a foreign association but the foreign namespace is not defined.`\n )\n }\n const result = DataAssociation.fromTarget(this.root, key, namespace)\n if (name) {\n result.info.name = name\n }\n this.root.definitions.associations.push(result)\n this.associations.push(result)\n this.fields.push({ type: 'association', key: result.key })\n return result\n }\n\n /**\n * Removes an association from the entity and, namespace definitions.\n * @param key The key of the association to remove.\n */\n removeAssociation(key: string): void {\n const thisIndex = this.associations.findIndex((i) => i.key === key)\n if (thisIndex < 0) {\n // return\n throw new RemoveAssociationException(`Trying to remove the ${key} association, but it doesn't exist.`)\n }\n const associationToRemove = this.associations[thisIndex]\n this.associations.splice(thisIndex, 1)\n const defIndex = this.root.definitions.associations.findIndex((i) => i.key === key)\n if (defIndex >= 0) {\n this.root.definitions.associations.splice(defIndex, 1)\n }\n this.removeField(key)\n associationToRemove.remove()\n }\n\n /**\n * Reads the list of parents for the entity, inside the root namespace. The computed list contains the list of all\n * parents in the inheritance chain in no particular order.\n * @param recursive Whether to include parent parents as well.\n */\n getComputedParents(recursive?: boolean): DataEntity[] {\n const { entities } = this.root.definitions\n let result: DataEntity[] = []\n this.parents.forEach((key) => {\n const parent = entities.find((i) => i.key === key)\n if (parent) {\n result.push(parent)\n if (recursive) {\n result = result.concat(parent.getComputedParents())\n }\n }\n })\n return result\n }\n\n /**\n * Computes list of all children, inside the root namespace, that extends this entity.\n * The children are not ordered.\n */\n getComputedChildren(): DataEntity[] {\n const { entities } = this.root.definitions\n return entities.filter((i) => i.parents.includes(this.key))\n }\n\n /**\n * Computes a list of entities that are associated with the current entity.\n */\n getComputedAssociations(): DataEntity[] {\n const { associations } = this\n const result: DataEntity[] = []\n associations.forEach((assoc) => {\n if (!assoc.targets.length) {\n return\n }\n const entities = this.root.findAssociatedEntities(assoc.targets)\n entities.forEach((entity) => {\n if (entity) {\n result.push(entity)\n }\n })\n })\n return result\n }\n\n /**\n * Removes self from the namespace with all properties and attributes.\n */\n remove(): void {\n const { key, properties, associations, root } = this\n // check if some entity has reference to this entity as a target\n const associationsToEntity = this.root.definitions.associations.filter((a) =>\n a.targets.some((t) => t.key === this.key)\n )\n if (associationsToEntity.length > 0) {\n const entitiesNames = associationsToEntity.reduce<string[]>((acc, association) => {\n const entity = root.definitions.entities.find((e) => e.associations.some((a) => a.key === association.key))\n if (entity) {\n acc.push(entity.info.name as string)\n }\n return acc\n }, [])\n throw new RemoveEntityException(\n `Cannot remove entity ${this.info.name} because it is used as a target in associations in entities: ${entitiesNames.join(', ')}.`\n )\n }\n\n // remove own stuff\n properties.forEach((p) => this.removeProperty(p.key))\n associations.forEach((a) => this.removeAssociation(a.key))\n // remove from the root\n const index = root.definitions.entities.findIndex((i) => i.key === key)\n if (index >= 0) {\n root.definitions.entities.splice(index, 1)\n }\n // remove from the parent\n const model = this.getParentInstance()\n if (model) {\n const entityIndex = model.entities.findIndex((e) => e.key === this.key)\n model.entities.splice(entityIndex, 1)\n }\n }\n\n /**\n * @deprecated Use the `getParentInstance()` method instead.\n */\n // This method name collides with the `getParents()` method.\n getParent(): DataModel | undefined {\n return this.getParentInstance()\n }\n\n /**\n * Returns a parent data model where this entity exist.\n */\n getParentInstance(): DataModel | undefined {\n return this.root.definitions.models.find((m) => m.entities.some((e) => e.key === this.key))\n }\n\n /**\n * Adds a parent reference to this entity.\n * This will not add the parent to the namespace. It only adds a reference to the parent.\n * @param key The key of the parent entity to add.\n * @returns `this` for chaining.\n */\n addParent(key: string): this {\n // Prevent adding self as parent\n if (key === this.key) {\n const message = 'Entity cannot be a parent of itself.'\n throw new ValidationError(\n [\n {\n field: 'parents',\n message,\n rule: 'circular',\n },\n ],\n { message }\n )\n }\n // check if parent exists\n const parent = this.root.definitions.entities.find((i) => i.key === key)\n if (!parent) {\n const message = `Entity with key \"${key}\" not found.`\n throw new ValidationError(\n [\n {\n field: 'parents',\n message,\n rule: 'not-exists',\n },\n ],\n { message }\n )\n }\n // Check for circular inheritance\n if (this.hasCircularParent(key)) {\n const message = `Circular inheritance detected. Cannot add ${key} as a parent.`\n throw new ValidationError(\n [\n {\n field: 'parents',\n message,\n rule: 'circular',\n },\n ],\n { message }\n )\n }\n const has = this.parents.some((i) => i === key)\n if (has) {\n const message = `Parent ${key} already exists.`\n throw new ValidationError(\n [\n {\n field: 'parents',\n message,\n rule: 'unique',\n },\n ],\n { message }\n )\n }\n this.parents.push(key)\n return this\n }\n\n /**\n * Removes a parent reference from this entity.\n * It keeps the parent as is.\n *\n * @param key The key of the parent entity to remove.\n * @throws ValidationError when the parent is not found.\n * @returns Self for chaining.\n */\n removeParent(key: string): this {\n const index = this.parents.findIndex((i) => i === key)\n if (index < 0) {\n const message = `Parent ${key} not found.`\n throw new ValidationError(\n [\n {\n field: 'parents',\n message,\n rule: 'not-found',\n },\n ],\n { message }\n )\n }\n this.parents.splice(index, 1)\n return this\n }\n\n /**\n * Checks if the entity has a circular parent relationship when attempting to add a new parent.\n * @param key The key of the parent being added.\n * @returns true if adding this parent would create a circular relationship.\n */\n hasCircularParent(key: string): boolean {\n const { entities } = this.root.definitions\n // Check if new parent is one of the children.\n const children = this.getComputedChildren()\n if (children.some((c) => c.key === key)) {\n return true\n }\n // check if this entity is in parents chain.\n let current: DataEntity | undefined = entities.find((e) => e.key === key)\n while (current) {\n if (current.key === this.key) {\n return true\n }\n // for (const parentKey of current.parents) {\n // current = parentKey ? entities.find((e) => e.key === parentKey) : undefined\n // }\n const parentKey = current.parents[0] // Assuming single inheritance\n current = parentKey ? entities.find((e) => e.key === parentKey) : undefined\n }\n return false\n }\n\n /**\n * Tests whether one entity is associated with another.\n *\n * @param entity1 The source entity\n * @param entity2 The target entity\n * @returns true when there's any path from one entity to another.\n */\n static isAssociated(entity1: DataEntity, entity2: DataEntity): boolean {\n return entity1.isAssociated(entity2.key)\n }\n\n /**\n * Tests whether this entity is somehow associated with another entity.\n * @param target The key of the target entity to test for association with.\n * @returns true if this entity has any association to the `target` entity.\n */\n isAssociated(target: string): boolean {\n const it = this.associationPath(target)\n const path = it.next().value\n return !!path\n }\n\n /**\n * Prints out all associations from one entity to another through all entities that may be in between.\n * @param toEntity The key to the target entity\n * @yields The path containing keys of entities from this entity to the `toEntity`\n * (inclusive) and all entities in between.\n */\n *associationPath(toEntity: string): Generator<string[]> {\n const graph = this.root.associationGraph()\n for (const path of this.root.associationPath(this.key, toEntity, graph)) {\n yield path\n }\n }\n\n /**\n * Returns a list of entities that are associated with this entity as a target.\n *\n * This method identifies entities that have an association where this entity is a target.\n * In other words, it finds entities that \"point to\" this entity through an association.\n *\n * For example, consider the following relationships:\n *\n * ```plain\n * A -> B (A has an association that targets B)\n * C -> B (C has an association that targets B)\n * B -> D (B has an association that targets D)\n *\n * Calling `getRelatedEntities()` on B would return [A, C]\n * Calling `getRelatedEntities()` on D would return [B]\n * Calling `getRelatedEntities()` on A would return []\n * ```\n *\n * Note, this method only returns entities that are directly associated with this entity as a target.\n * It does not traverse the association graph to find indirectly related entities.\n *\n * @returns An array of `DataEntity` instances that have an association targeting this entity.\n */\n getRelatedEntities(): DataEntity[] {\n const { key, root } = this\n const result = DataEntity.getRelatedEntities(root, key)\n root.foreign.forEach((ns) => {\n const other = DataEntity.getRelatedEntities(ns, key)\n other.forEach((entity) => {\n if (!result.includes(entity)) {\n result.push(entity)\n }\n })\n })\n return result\n }\n\n static getRelatedEntities(namespace: DataNamespace, entityKey: string): DataEntity[] {\n const result: DataEntity[] = []\n const inverse = namespace.definitions.associations.filter((i) => i.targets.some((j) => j.key === entityKey))\n inverse.forEach((assoc) => {\n const entity = namespace.definitions.entities.find((e) => e.associations.includes(assoc))\n if (entity && !result.includes(entity)) {\n result.push(entity)\n }\n })\n return result\n }\n\n /**\n * Creates breadcrumbs from this entity to the root namespace.\n */\n breadcrumbs(): FileBreadcrumb[] {\n const result: FileBreadcrumb[] = []\n result.push({\n key: this.key,\n name: this.info.name || 'Unnamed entity',\n kind: DataEntityKind,\n })\n const model = this.getParentInstance()\n if (model) {\n result.push({\n key: model.key,\n kind: model.kind,\n name: model.info.name || 'Unnamed data model',\n })\n let parent = model.getParentInstance()\n while (parent && parent !== this.root) {\n result.push({\n key: parent.key,\n kind: parent.kind,\n name: parent.info.name || 'Unnamed namespace',\n })\n parent = parent.getParentInstance()\n }\n }\n result.push({\n key: this.root.key,\n name: this.root.info.name || 'Unnamed namespace',\n kind: this.root.kind,\n })\n return result.reverse()\n }\n\n /**\n * Adds a new tag to the property. It also populates the root namespace's tags when tag is new.\n *\n * Note, it does nothing when the tag is already defined.\n *\n * @param tag The tag to add.\n */\n addTag(tag: string): void {\n if (!tag) {\n return\n }\n const lower = tag.toLowerCase()\n const { tags } = this\n if (tags.some((t) => t.toLowerCase() === lower)) {\n return\n }\n tags.push(tag)\n const { definitions } = this.root\n if (!definitions.tags.some((t) => t.toLowerCase() === lower)) {\n definitions.tags.push(tag)\n }\n }\n\n /**\n * Removes a tag from the property. Unlike the `addTag()` this won't remove a `tag` from the root namespace.\n *\n * @param tag The tag to remove.\n */\n removeTag(tag: string): void {\n if (!tag) {\n return\n }\n const lower = tag.toLowerCase()\n const { tags } = this\n const index = tags.findIndex((t) => t.toLowerCase() === lower)\n if (index >= 0) {\n tags.splice(index, 1)\n }\n }\n\n /**\n * Creates a Shape of AMF.\n * The property itself is auto-generated. If the `schema` is defined then it is used\n * as the `range` of the property. Otherwise basic shape is generated for the range.\n *\n * This is a preferred way of reading the AMF shape as this synchronizes changed\n * data properties with the shape definition.\n *\n * @returns AMF property shape definition.\n */\n toApiShape(): IShapeUnion {\n const serializer = new AmfShapeGenerator()\n return serializer.entity(this)\n }\n\n /**\n * Reads the schema of the Entity and generates an example for it.\n */\n toExample(mime: string, opts: IShapeRenderOptions = {}): string | number | boolean | null | undefined {\n const shape = this.toApiShape()\n const generator = new ApiSchemaGenerator(mime, {\n renderExamples: typeof opts.renderExamples === 'boolean' ? opts.renderExamples : true,\n renderMocked: typeof opts.renderMocked === 'boolean' ? opts.renderMocked : true,\n renderOptional: typeof opts.renderOptional === 'boolean' ? opts.renderOptional : true,\n selectedUnions: opts.selectedUnions,\n })\n return generator.generate(shape)\n }\n\n hasClosedCycle(rootEntity: string, targetEntity: string): boolean {\n if (targetEntity === this.key) {\n // self association\n return true\n }\n const g = this.root.associationGraph()\n const selfPaths: string[][] = []\n const targetPaths: string[][] = []\n for (const path of this.root.associationPath(rootEntity, this.key, g)) {\n selfPaths.push(path)\n }\n for (const path of this.root.associationPath(targetEntity, this.key, g)) {\n targetPaths.push(path)\n }\n const checker = (arr: string[], target: string[]): boolean => target.every((v) => arr.includes(v))\n for (const sp of selfPaths) {\n for (const tp of targetPaths) {\n const result = checker(sp, tp)\n if (result) {\n return result\n }\n }\n }\n return false\n }\n}\n"]}
@@ -42473,13 +42473,13 @@
42473
42473
  "@id": "#210"
42474
42474
  },
42475
42475
  {
42476
- "@id": "#219"
42477
- },
42478
- {
42479
42476
  "@id": "#213"
42480
42477
  },
42481
42478
  {
42482
42479
  "@id": "#216"
42480
+ },
42481
+ {
42482
+ "@id": "#219"
42483
42483
  }
42484
42484
  ],
42485
42485
  "doc:root": false,
@@ -43913,7 +43913,7 @@
43913
43913
  "doc:ExternalDomainElement",
43914
43914
  "doc:DomainElement"
43915
43915
  ],
43916
- "doc:raw": "-\n type: 'GENERAL'\n value: 'info@company.be'\n-\n type: 'IT_DEPT'\n value: 'it-service@company.be'\n",
43916
+ "doc:raw": "type: 'GENERAL'\ncountryDialCode : '+32'\nareaCode : '21'\nsubscriberNumber: '12.87.00'\nformatted: '+32-(0)21 302099'\n",
43917
43917
  "core:mediaType": "application/yaml",
43918
43918
  "sourcemaps:sources": [
43919
43919
  {
@@ -43934,7 +43934,7 @@
43934
43934
  "doc:ExternalDomainElement",
43935
43935
  "doc:DomainElement"
43936
43936
  ],
43937
- "doc:raw": "type: \"GENERAL\"\nvalue: \"www.company.be\"\n",
43937
+ "doc:raw": "-\n type: 'GENERAL'\n value: 'info@company.be'\n-\n type: 'IT_DEPT'\n value: 'it-service@company.be'\n",
43938
43938
  "core:mediaType": "application/yaml",
43939
43939
  "sourcemaps:sources": [
43940
43940
  {
@@ -43955,7 +43955,7 @@
43955
43955
  "doc:ExternalDomainElement",
43956
43956
  "doc:DomainElement"
43957
43957
  ],
43958
- "doc:raw": "type: 'GENERAL'\ncountryDialCode : '+32'\nareaCode : '21'\nsubscriberNumber: '12.87.00'\nformatted: '+32-(0)21 302099'\n",
43958
+ "doc:raw": "type: \"GENERAL\"\nvalue: \"www.company.be\"\n",
43959
43959
  "core:mediaType": "application/yaml",
43960
43960
  "sourcemaps:sources": [
43961
43961
  {
@@ -44781,17 +44781,17 @@
44781
44781
  {
44782
44782
  "@id": "#215/source-map/lexical/element_0",
44783
44783
  "sourcemaps:element": "amf://id#215",
44784
- "sourcemaps:value": "[(1,0)-(7,0)]"
44784
+ "sourcemaps:value": "[(1,0)-(6,0)]"
44785
44785
  },
44786
44786
  {
44787
44787
  "@id": "#218/source-map/lexical/element_0",
44788
44788
  "sourcemaps:element": "amf://id#218",
44789
- "sourcemaps:value": "[(1,0)-(3,0)]"
44789
+ "sourcemaps:value": "[(1,0)-(7,0)]"
44790
44790
  },
44791
44791
  {
44792
44792
  "@id": "#221/source-map/lexical/element_0",
44793
44793
  "sourcemaps:element": "amf://id#221",
44794
- "sourcemaps:value": "[(1,0)-(6,0)]"
44794
+ "sourcemaps:value": "[(1,0)-(3,0)]"
44795
44795
  },
44796
44796
  {
44797
44797
  "@id": "#338/source-map/synthesized-field/element_1",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@api-client/core",
3
3
  "description": "The API Client's core client library. Works in NodeJS and in a ES enabled browser.",
4
- "version": "0.11.6",
4
+ "version": "0.11.7",
5
5
  "license": "Apache-2.0",
6
6
  "exports": {
7
7
  "./browser.js": {
@@ -49,8 +49,6 @@
49
49
  "url": "https://github.com/api-client/core/issues"
50
50
  },
51
51
  "dependencies": {
52
- "@adonisjs/transmit-client": "^1.0.0",
53
- "@api-client/graph": "^0.2.0",
54
52
  "@api-client/json": "^0.2.0",
55
53
  "@esm-bundle/chai": "^4.3.4-fix.0",
56
54
  "@material/web": "^2.2.0",
@@ -60,12 +58,6 @@
60
58
  "@xmldom/xmldom": "^0.9.7",
61
59
  "amf-json-ld-lib": "^0.0.15",
62
60
  "console-table-printer": "^2.11.2",
63
- "dompurify": "^3.1.5",
64
- "idb-keyval": "^6.2.1",
65
- "lit": "^3.1.4",
66
- "marked": "^15.0.7",
67
- "monaco-editor": "^0.52.2",
68
- "prismjs": "^1.29.0",
69
61
  "ws": "^8.12.0",
70
62
  "xpath": "^0.0.34"
71
63
  },
@@ -78,21 +70,16 @@
78
70
  "@japa/browser-client": "^2.1.1",
79
71
  "@japa/expect-type": "^2.0.3",
80
72
  "@japa/runner": "^4.2.0",
81
- "@open-wc/semantic-dom-diff": "^0.20.1",
82
- "@open-wc/testing": "^4.0.0",
83
73
  "@rollup/plugin-typescript": "^12.1.2",
84
74
  "@types/cors": "^2.8.12",
85
- "@types/dompurify": "^3.0.5",
86
75
  "@types/express-ntlm": "^2.3.3",
87
76
  "@types/jsdom": "^21.1.7",
88
77
  "@types/mocha": "^10.0.10",
89
78
  "@types/node": "^22.13.4",
90
- "@types/prismjs": "^1.26.4",
91
79
  "@types/sinon": "^17.0.1",
92
80
  "@web/dev-server": "^0.4.6",
93
81
  "@web/dev-server-rollup": "^0.6.4",
94
82
  "@web/test-runner": "^0.20.0",
95
- "@web/test-runner-commands": "^0.9.0",
96
83
  "@web/test-runner-playwright": "^0.11.0",
97
84
  "amf-client-js": "^5.7.0",
98
85
  "c8": "^10.1.3",
@@ -113,7 +100,6 @@
113
100
  "playwright": "^1.50.1",
114
101
  "prettier": "^3.5.1",
115
102
  "sinon": "^20.0.0",
116
- "ssl-root-cas": "^1.3.1",
117
103
  "ts-lit-plugin": "^2.0.2",
118
104
  "ts-node-maintained": "^10.9.5",
119
105
  "typescript": "^5.5.2",
@@ -133,7 +119,8 @@
133
119
  "test:browser": "node --import ts-node-maintained/register/esm --enable-source-maps bin/test-web.ts --playwright --browsers chromium",
134
120
  "test:browser:watch": "node --import ts-node-maintained/register/esm --enable-source-maps bin/test-web.ts --watch --playwright --browsers chromium",
135
121
  "test": "wireit",
136
- "test:node": "node --import ts-node-maintained/register/esm --enable-source-maps bin/test.ts",
122
+ "test:coverage": "wireit",
123
+ "test:node": "node --import ts-node-maintained/register/esm bin/test.ts",
137
124
  "test:node:coverage": "c8 --reporter lcov --reporter text node --import ts-node-maintained/register/esm --enable-source-maps bin/test.ts",
138
125
  "test:node:watch": "node --import ts-node-maintained/register/esm --enable-source-maps bin/test.ts --watch",
139
126
  "build:api-models": "node data/model.js",
@@ -143,6 +130,9 @@
143
130
  },
144
131
  "wireit": {
145
132
  "test": {
133
+ "command": "npm run test:node && npm run test:browser"
134
+ },
135
+ "test:coverage": {
146
136
  "command": "npm run test:node:coverage && npm run test:browser"
147
137
  },
148
138
  "tsc:watch": {
@@ -68,7 +68,7 @@ export interface IApiAssociationShape {
68
68
  * - anyOf - To validate against `anyOf`, the given data must be valid against
69
69
  * any (one or more) of the given sub-schemas. When generation a schema, it takes first union schema.
70
70
  * - oneOf - To validate against `oneOf`, the given data must be valid against
71
- * exactly one of the given sub-schemas. It behaves the same as `oneOf` when generating a schema
71
+ * exactly one of the given sub-schemas. It behaves the same as `anyOf` when generating a schema
72
72
  * - not - The `not` keyword declares that an instance validates if it doesn’t
73
73
  * validate against the given sub-schema. It has no use when generating a schema.
74
74
  *
@@ -402,6 +402,19 @@ export class DataAssociation {
402
402
  namespace = typed.root.key
403
403
  }
404
404
  }
405
+ if (this.targets.some((i) => i.key === key)) {
406
+ const message = `Target ${key} already exists.`
407
+ throw new ValidationError(
408
+ [
409
+ {
410
+ field: 'targets',
411
+ message,
412
+ rule: 'unique',
413
+ },
414
+ ],
415
+ { message }
416
+ )
417
+ }
405
418
  if (namespace && namespace !== this.root.key) {
406
419
  const foreignNamespace = this.root.foreign.find((ns) => ns.key === namespace)
407
420
  if (!foreignNamespace) {
@@ -480,9 +493,9 @@ export class DataAssociation {
480
493
  }
481
494
 
482
495
  /**
483
- * Checks whether the passed value is one of the supported data proprty attributes.
496
+ * Checks whether the passed value is one of the supported data property attributes.
484
497
  * @param value The value to test
485
- * @returns True when the passed value is one of the supported data proprty attributes.
498
+ * @returns True when the passed value is one of the supported data property attributes.
486
499
  */
487
500
  static isValidAttribute(value: unknown): value is DataAttributeAttribute {
488
501
  if (typeof value !== 'string') {
@@ -615,7 +615,7 @@ export class DataEntity {
615
615
  /**
616
616
  * @deprecated Use the `getParentInstance()` method instead.
617
617
  */
618
- // This method name colides with the `getParents()` method.
618
+ // This method name collides with the `getParents()` method.
619
619
  getParent(): DataModel | undefined {
620
620
  return this.getParentInstance()
621
621
  }
@@ -685,7 +685,7 @@ export class DataEntity {
685
685
  {
686
686
  field: 'parents',
687
687
  message,
688
- rule: 'exists',
688
+ rule: 'unique',
689
689
  },
690
690
  ],
691
691
  { message }
@@ -695,6 +695,33 @@ export class DataEntity {
695
695
  return this
696
696
  }
697
697
 
698
+ /**
699
+ * Removes a parent reference from this entity.
700
+ * It keeps the parent as is.
701
+ *
702
+ * @param key The key of the parent entity to remove.
703
+ * @throws ValidationError when the parent is not found.
704
+ * @returns Self for chaining.
705
+ */
706
+ removeParent(key: string): this {
707
+ const index = this.parents.findIndex((i) => i === key)
708
+ if (index < 0) {
709
+ const message = `Parent ${key} not found.`
710
+ throw new ValidationError(
711
+ [
712
+ {
713
+ field: 'parents',
714
+ message,
715
+ rule: 'not-found',
716
+ },
717
+ ],
718
+ { message }
719
+ )
720
+ }
721
+ this.parents.splice(index, 1)
722
+ return this
723
+ }
724
+
698
725
  /**
699
726
  * Checks if the entity has a circular parent relationship when attempting to add a new parent.
700
727
  * @param key The key of the parent being added.
@@ -28,5 +28,6 @@
28
28
  "resolveJsonModule": true,
29
29
  "skipLibCheck": true
30
30
  },
31
- "include": ["src/**/*", "test/**/*"]
31
+ "include": ["src/**/*", "test/**/*"],
32
+ "exclude": ["node_modules", "build", "coverage", ".tmp", ".wireit", "amf-models", "bin", "data", "docs", "scripts"],
32
33
  }