• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

panates / opra / 28585340608

02 Jul 2026 09:58AM UTC coverage: 82.799% (-0.3%) from 83.077%
28585340608

push

github

erayhanoglu
Feat: Added bundle support for HTTP protocol
Refactor: Renamed HttpIncoming to HttpRequest, HttpOutgoing to HttpResponse
Refactor: Refactored MultipartReader to support multipart/mixed

3763 of 4860 branches covered (77.43%)

Branch coverage included in aggregate %.

1755 of 1981 new or added lines in 54 files covered. (88.59%)

94 existing lines in 4 files now uncovered.

33673 of 40353 relevant lines covered (83.45%)

220.83 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

85.87
/packages/common/src/document/data-type/utils/create-mapped-class.ts
1
import type { Type } from 'ts-gems';
1✔
2
import {
1✔
3
  inheritPropertyInitializers,
1✔
4
  mergePrototype,
1✔
5
} from '../../../helpers/index.js';
1✔
6
import { OpraSchema } from '../../../schema/index.js';
1✔
7
import { DATATYPE_METADATA } from '../../constants.js';
1✔
8
import type { DataType } from '../data-type.js';
1✔
9
import { MappedType } from '../mapped-type.js';
1✔
10
import { getIsInheritedPredicateFn } from './get-is-inherited-predicate-fn.js';
1✔
11

1✔
12
export function createMappedClass(
1✔
13
  source: string | Type,
25✔
14
  config: any,
25✔
15
  options?: DataType.Options,
25✔
16
) {
25✔
17
  const isInheritedPredicate = getIsInheritedPredicateFn(
25✔
18
    config.pick as any,
25✔
19
    config.omit as any,
25✔
20
  );
25✔
21
  const sourceName =
25✔
22
    typeof source === 'string'
25✔
23
      ? source.charAt(0).toUpperCase() + source.substring(1)
4✔
24
      : source.name;
25✔
25
  const className = options?.name || sourceName + 'Mapped';
25✔
26
  const MappedClass = {
25✔
27
    [className]: class {
25✔
28
      constructor() {
25✔
29
        if (typeof source === 'function')
×
30
          inheritPropertyInitializers(this, source, isInheritedPredicate);
×
31
      }
×
32
    },
25✔
33
  }[className];
25✔
34

25✔
35
  if (typeof source === 'function')
25✔
36
    mergePrototype(MappedClass.prototype, source.prototype);
25✔
37

25✔
38
  if (typeof source === 'function') {
25✔
39
    const m = Reflect.getOwnMetadata(
21✔
40
      DATATYPE_METADATA,
21✔
41
      source,
21✔
42
    ) as OpraSchema.DataType;
21✔
43
    if (!m)
21✔
44
      throw new TypeError(
21!
45
        `Class "${source}" doesn't have datatype metadata information`,
×
46
      );
21✔
47
    if (!(
21✔
48
      m.kind === OpraSchema.ComplexType.Kind ||
21!
49
      m.kind === OpraSchema.MappedType.Kind ||
21!
NEW
50
      m.kind === OpraSchema.MixinType.Kind
×
51
    )) {
21!
52
      throw new TypeError(
×
53
        `Class "${source}" is not a ${OpraSchema.ComplexType.Kind}`,
×
54
      );
×
55
    }
×
56
  }
21✔
57

25✔
58
  const metadata: MappedType.Metadata = {
25✔
59
    ...options,
25✔
60
    kind: 'MappedType',
25✔
61
    base: source,
25✔
62
  };
25✔
63
  if (config.pick) metadata.pick = config.pick as any;
25✔
64
  if (config.omit) metadata.omit = config.omit as any;
25✔
65
  if (config.partial) metadata.partial = config.partial as any;
25✔
66
  if (config.required) metadata.required = config.required as any;
25✔
67
  Reflect.defineMetadata(DATATYPE_METADATA, metadata, MappedClass);
25✔
68

25✔
69
  if (typeof source === 'function') {
25✔
70
    MappedType._applyMixin(MappedClass, source, {
21✔
71
      ...config,
21✔
72
      isInheritedPredicate,
21✔
73
    });
21✔
74
  }
21✔
75
  return MappedClass as any;
25✔
76
}
25✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc