1 | import { ObservableObjectAdministration, isFunction } from "../internal"
|
2 |
|
3 | export const enum MakeResult {
|
4 | Cancel,
|
5 | Break,
|
6 | Continue
|
7 | }
|
8 |
|
9 | export type Annotation = {
|
10 | annotationType_: string
|
11 | make_(
|
12 | adm: ObservableObjectAdministration,
|
13 | key: PropertyKey,
|
14 | descriptor: PropertyDescriptor,
|
15 | source: object
|
16 | ): MakeResult
|
17 | extend_(
|
18 | adm: ObservableObjectAdministration,
|
19 | key: PropertyKey,
|
20 | descriptor: PropertyDescriptor,
|
21 | proxyTrap: boolean
|
22 | ): boolean | null
|
23 | options_?: any
|
24 | }
|
25 |
|
26 | export type AnnotationMapEntry =
|
27 | | Annotation
|
28 | | true
|
29 | | false
|
30 |
|
31 |
|
32 |
|
33 | export type AnnotationsMap<T, AdditionalFields extends PropertyKey> = {
|
34 | [P in Exclude<keyof T, "toString">]?: AnnotationMapEntry
|
35 | } &
|
36 | Record<AdditionalFields, AnnotationMapEntry>
|
37 |
|
38 | export function isAnnotation(thing: any) {
|
39 | return (
|
40 |
|
41 | thing instanceof Object &&
|
42 | typeof thing.annotationType_ === "string" &&
|
43 | isFunction(thing.make_) &&
|
44 | isFunction(thing.extend_)
|
45 | )
|
46 | }
|
47 |
|
48 | export function isAnnotationMapEntry(thing: any) {
|
49 | return typeof thing === "boolean" || isAnnotation(thing)
|
50 | }
|