|
| 1 | +/* |
| 2 | + * Copyright 2021-Present The Serverless Workflow Specification Authors |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +/***************************************************************************************** |
| 18 | + * |
| 19 | + * /!\ This file is computer generated. Any manual modification can and will be lost. /!\ |
| 20 | + * |
| 21 | + *****************************************************************************************/ |
| 22 | + |
| 23 | +import { _Endpoint } from './endpoint'; |
| 24 | +import { ObjectHydrator } from '../../hydrator'; |
| 25 | +import { Specification } from '../definitions'; |
| 26 | +import { getLifecycleHooks } from '../../lifecycle-hooks'; |
| 27 | +import { validate } from '../../validation'; |
| 28 | +import { isObject } from '../../utils'; |
| 29 | + |
| 30 | +/** |
| 31 | + * Represents the intersection between the Catalog class and type |
| 32 | + */ |
| 33 | +export type CatalogIntersection = Catalog & Specification.Catalog; |
| 34 | + |
| 35 | +/** |
| 36 | + * Represents a constructor for the intersection of the Catalog class and type |
| 37 | + */ |
| 38 | +export interface CatalogConstructor { |
| 39 | + new (model?: Partial<Specification.Catalog>): CatalogIntersection; |
| 40 | +} |
| 41 | + |
| 42 | +/** |
| 43 | + * Represents a Catalog with methods for validation and normalization. |
| 44 | + * Inherits from ObjectHydrator which provides functionality for hydrating the state based on a model. |
| 45 | + */ |
| 46 | +export class Catalog extends ObjectHydrator<Specification.Catalog> { |
| 47 | + /** |
| 48 | + * Instanciates a new instance of the Catalog class. |
| 49 | + * Initializes properties based on the provided model if it is an object. |
| 50 | + * |
| 51 | + * @param model - Optional partial model object to initialize the Catalog. |
| 52 | + */ |
| 53 | + constructor(model?: Partial<Specification.Catalog>) { |
| 54 | + super(model); |
| 55 | + const self = this as unknown as Specification.Catalog & object; |
| 56 | + if (isObject(model)) { |
| 57 | + if (typeof model.endpoint === 'object') self.endpoint = new _Endpoint(model.endpoint); |
| 58 | + } |
| 59 | + getLifecycleHooks('Catalog')?.constructor?.(this); |
| 60 | + } |
| 61 | + |
| 62 | + /** |
| 63 | + * Validates the current instance of the Catalog. |
| 64 | + * Throws if invalid. |
| 65 | + */ |
| 66 | + validate(workflow?: Partial<Specification.Workflow>) { |
| 67 | + const copy = new Catalog(this as any) as CatalogIntersection; |
| 68 | + validate('Catalog', copy, workflow); |
| 69 | + } |
| 70 | + |
| 71 | + /** |
| 72 | + * Normalizes the current instance of the Catalog. |
| 73 | + * Creates a copy of the Catalog, invokes normalization hooks if available, and returns the normalized copy. |
| 74 | + * |
| 75 | + * @returns A normalized version of the Catalog instance. |
| 76 | + */ |
| 77 | + normalize(): Catalog & Specification.Catalog { |
| 78 | + const copy = new Catalog(this as any) as CatalogIntersection; |
| 79 | + return getLifecycleHooks('Catalog')?.normalize?.(copy) || copy; |
| 80 | + } |
| 81 | +} |
| 82 | + |
| 83 | +export const _Catalog = Catalog as CatalogConstructor; |
0 commit comments