/
options.ts
107 lines (97 loc) · 3.47 KB
/
options.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import { Serializable, SerializableObjectOptions, MemberOptionsBase, DataObject } from '@openhps/core';
import { Quad_Object } from 'n3';
import { IriString, Thing } from '../rdf/types';
import { RDFIdentifierOptions, RDFLiteralOptions } from './types';
export type { SerializableObjectOptions, MemberOptionsBase, DataObject };
export type RDFMetadata = {
/**
* Serialized or deserialized URI of the data object
*/
uri?: IriString;
/**
* Path relative to base URI
*/
path?: string;
/**
* Unresolved predicates
*/
predicates?: {
[predicate: string]: (Quad_Object | Thing)[];
};
};
declare module '@openhps/core/dist/types/data/object/DataObject' {
export interface DataObject {
rdf?: RDFMetadata;
}
}
declare module '@openhps/core/dist/types/data/DataFrame' {
export interface DataFrame {
rdf?: RDFMetadata;
}
}
declare module '@openhps/core/dist/types/data/decorators/options' {
export interface SerializableObjectOptions<T> {
/**
* Resource Description Framework serialization options
* @see {@link https://www.w3.org/RDF/}
*/
rdf?: {
/**
* RDF type of this class. This will be automatically added as a static predicate.
* @see {@link https://www.w3.org/TR/rdf-schema/#ch_type}
*/
type?: IriString | IriString[];
/**
* Additional static predicates to add to this object that are not based
* on any properties inside the object.
*/
predicates?: Record<IriString, IriString[]>;
/**
* Custom (partial) serializer for this object.
*/
serializer?: (object: T, baseUri?: IriString) => Partial<Thing> | Quad_Object;
/**
* Custom (partial) deserializer for this object.
*/
deserializer?: (thing: Thing, instance?: T) => T;
/**
* Type resolver for deserialized thing. Return true
* if the type matches and false if the type does not match.
*/
typeResolver?: (thing: Thing) => boolean;
};
}
export interface MemberOptionsBase {
/**
* Resource Description Framework serialization options
* @see {@link https://www.w3.org/RDF/}
*/
rdf?: {
/**
* Specify if the member is an identifier
*/
identifier?: boolean;
/**
* Custom (partial) serializer for this member.
*/
serializer?: (value: any, object?: any, options?: MemberSerializerOptions) => Partial<Thing | Quad_Object>;
/**
* Custom (partial) deserializer for this member.
*/
deserializer?: (thing: Thing, targetObject?: any, options?: MemberDeserializerOptions) => any;
} & (RDFLiteralOptions | RDFIdentifierOptions);
}
}
export interface MemberSerializerOptions {
thing: Thing;
dataType?: Serializable<any>;
baseUri?: IriString;
parent?: MemberSerializerOptionsParent;
}
export type MemberSerializerOptionsParent = { thing: Thing; parent: MemberSerializerOptionsParent };
export type MemberDeserializerOptionsParent = { thing: Thing; object: any; parent: MemberDeserializerOptionsParent };
export interface MemberDeserializerOptions {
thing: Thing;
dataType?: Serializable<any>;
parent?: MemberDeserializerOptionsParent;
}