{{$pkg := .Package}} {{- if .Imports }} /** {{- range .Imports}} * @typedef {import('{{.Path}}/models').{{.Name -}} } {{.VarName}} {{- end}} */ {{end}} {{- range $enumindex, $enumdef := .Enums}} {{- range $commentindex, $commentdef := $enumdef.DocComments}} {{$commentdef -}} {{- end}} export const {{$enumdef.Name}} = { {{- range $constindex, $constdef := .Consts}} {{- if $constdef.DocComments}} {{- range $commentindex, $commentdef := $constdef.DocComments}} {{$commentdef -}} {{- end }} {{- end}} {{$constdef.Name}}: {{$constdef.Value}},{{end}} }; {{end}} {{- range $name, $def := .Models}} {{- if $def.DocComments}} {{- range $commentindex, $commentdef := $def.DocComments}} {{$commentdef -}} {{- end }} {{- end}} export const {{$def.Name}} = class { /** * Creates a new {{$def.Name}} instance. * @constructor * @param {Object} source - The source object to create the {{$def.Name}}. {{- range $field := $def.Fields}} * @param { {{- .JSDocType $pkg -}} } source.{{$field.Name}}{{end}} */ constructor(source = {}) { const { {{$def.DefaultValueList}} } = source; {{range $def.Fields}} this.{{.JSName}} = {{.JSName}};{{end}} } /** * Creates a new {{$def.Name}} instance from a string or object. * @param {string|object} source - The source data to create a {{$def.Name}} instance from. * @returns { {{- $def.Name -}} } A new {{$def.Name}} instance. */ static createFrom(source) { let parsedSource = typeof source === 'string' ? JSON.parse(source) : source; return new {{$def.Name}}(parsedSource); } }; {{end}}