@fedify/vocab-tools 2.1.0-dev.403 → 2.1.0-dev.406
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/deno.json +1 -1
- package/dist/mod.cjs +25 -8
- package/dist/mod.d.cts +100 -100
- package/dist/mod.d.ts +100 -100
- package/dist/mod.js +25 -8
- package/package.json +1 -1
- package/src/__snapshots__/class.test.ts.deno.snap +858 -594
- package/src/__snapshots__/class.test.ts.node.snap +858 -594
- package/src/__snapshots__/class.test.ts.snap +858 -594
- package/src/class.ts +4 -1
- package/src/generate.ts +1 -1
- package/src/inspector.ts +26 -6
- package/tsdown.config.ts +1 -1
package/deno.json
CHANGED
package/dist/mod.cjs
CHANGED
|
@@ -31,7 +31,7 @@ const es_toolkit = __toESM(require("es-toolkit"));
|
|
|
31
31
|
|
|
32
32
|
//#region deno.json
|
|
33
33
|
var name = "@fedify/vocab-tools";
|
|
34
|
-
var version = "2.1.0-dev.
|
|
34
|
+
var version = "2.1.0-dev.406+61a21e4e";
|
|
35
35
|
var license = "MIT";
|
|
36
36
|
var exports$1 = { ".": "./src/mod.ts" };
|
|
37
37
|
var author = {
|
|
@@ -1413,25 +1413,41 @@ async function* generateInspector(typeUri, types) {
|
|
|
1413
1413
|
yield `
|
|
1414
1414
|
return proxy;
|
|
1415
1415
|
}
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1416
|
+
`;
|
|
1417
|
+
}
|
|
1418
|
+
/**
|
|
1419
|
+
* Generates code that must appear *after* the class closing brace: prototype
|
|
1420
|
+
* assignments for the Deno and Node.js custom-inspect hooks.
|
|
1421
|
+
*
|
|
1422
|
+
* These are emitted outside the class body because computed property names
|
|
1423
|
+
* using `Symbol.for()` are incompatible with `isolatedDeclarations` mode.
|
|
1424
|
+
*/
|
|
1425
|
+
async function* generateInspectorPostClass(typeUri, types) {
|
|
1426
|
+
const type = types[typeUri];
|
|
1427
|
+
const className = type.name;
|
|
1428
|
+
yield `
|
|
1429
|
+
// deno-lint-ignore no-explicit-any
|
|
1430
|
+
(${className}.prototype as any)[Symbol.for("Deno.customInspect")] =
|
|
1431
|
+
function (
|
|
1432
|
+
this: ${className},
|
|
1419
1433
|
inspect: typeof Deno.inspect,
|
|
1420
1434
|
options: Deno.InspectOptions,
|
|
1421
1435
|
): string {
|
|
1422
1436
|
const proxy = this._getCustomInspectProxy();
|
|
1423
1437
|
return ${JSON.stringify(type.name + " ")} + inspect(proxy, options);
|
|
1424
|
-
}
|
|
1438
|
+
};
|
|
1425
1439
|
|
|
1426
|
-
|
|
1427
|
-
|
|
1440
|
+
// deno-lint-ignore no-explicit-any
|
|
1441
|
+
(${className}.prototype as any)[Symbol.for("nodejs.util.inspect.custom")] =
|
|
1442
|
+
function (
|
|
1443
|
+
this: ${className},
|
|
1428
1444
|
_depth: number,
|
|
1429
1445
|
options: unknown,
|
|
1430
1446
|
inspect: (value: unknown, options: unknown) => string,
|
|
1431
1447
|
): string {
|
|
1432
1448
|
const proxy = this._getCustomInspectProxy();
|
|
1433
1449
|
return ${JSON.stringify(type.name + " ")} + inspect(proxy, options);
|
|
1434
|
-
}
|
|
1450
|
+
};
|
|
1435
1451
|
`;
|
|
1436
1452
|
}
|
|
1437
1453
|
|
|
@@ -1890,6 +1906,7 @@ async function* generateClass(typeUri, types) {
|
|
|
1890
1906
|
for await (const code of generateDecoder(typeUri, types)) yield code;
|
|
1891
1907
|
for await (const code of generateInspector(typeUri, types)) yield code;
|
|
1892
1908
|
yield "}\n\n";
|
|
1909
|
+
for await (const code of generateInspectorPostClass(typeUri, types)) yield code;
|
|
1893
1910
|
}
|
|
1894
1911
|
/**
|
|
1895
1912
|
* Generates the TypeScript classes from the given types.
|
package/dist/mod.d.cts
CHANGED
|
@@ -3,185 +3,185 @@ declare function generateVocab(schemaDir: string, generatedPath: string): Promis
|
|
|
3
3
|
//#endregion
|
|
4
4
|
//#region src/schema.d.ts
|
|
5
5
|
/**
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
* The qualified URI of a type. It is used as the range of a property.
|
|
7
|
+
*/
|
|
8
8
|
type TypeUri = `https://${string}` | `http://${string}` | `fedify:${string}`;
|
|
9
9
|
/**
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
* The schema of a type. It is used to generate a class.
|
|
11
|
+
*/
|
|
12
12
|
interface TypeSchema {
|
|
13
13
|
/**
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
* The type name. It is used as the name of the generated class.
|
|
15
|
+
*/
|
|
16
16
|
name: string;
|
|
17
17
|
/**
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
* The qualified URI of the type.
|
|
19
|
+
*/
|
|
20
20
|
uri: TypeUri;
|
|
21
21
|
/**
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
* The qualified URIs of the base type of the type (if any).
|
|
23
|
+
*/
|
|
24
24
|
extends?: TypeUri;
|
|
25
25
|
/**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
* The type name used in the compacted JSON-LD document. It is used as the
|
|
27
|
+
* value of the `type` field.
|
|
28
|
+
*/
|
|
29
29
|
compactName?: string;
|
|
30
30
|
/**
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
* Marks the type an entity type rather than a value type. Turning on this
|
|
32
|
+
* flag will make property accessors for the type asynchronous, so that they
|
|
33
|
+
* can load the values of the properties from the remote server.
|
|
34
|
+
*
|
|
35
|
+
* The extended subtypes must have the consistent value of this flag.
|
|
36
|
+
*/
|
|
37
37
|
entity: boolean;
|
|
38
38
|
/**
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
* The description of the type. It is used as the doc comment of
|
|
40
|
+
* the generated class.
|
|
41
|
+
*/
|
|
42
42
|
description: string;
|
|
43
43
|
/**
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
* The possible properties of the type.
|
|
45
|
+
*/
|
|
46
46
|
properties: PropertySchema[];
|
|
47
47
|
/**
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
* The default JSON-LD context of the type. It is used as the default
|
|
49
|
+
* context of the generated `toJsonLd()` method.
|
|
50
|
+
*/
|
|
51
51
|
defaultContext: Context;
|
|
52
52
|
}
|
|
53
53
|
interface PropertySchemaBase {
|
|
54
54
|
/**
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
* The singular form of the property name. It is used as the name of the
|
|
56
|
+
* generated property accessors.
|
|
57
|
+
*/
|
|
58
58
|
singularName: string;
|
|
59
59
|
/**
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
* The qualified URI of the property.
|
|
61
|
+
*/
|
|
62
62
|
uri: string;
|
|
63
63
|
/**
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
* The property name used in the compacted JSON-LD document. It is used as
|
|
65
|
+
* the key of the property.
|
|
66
|
+
*/
|
|
67
67
|
compactName?: string;
|
|
68
68
|
/**
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
* The qualified URI of the superproperty of the property (if any).
|
|
70
|
+
* It means that the property is a specialization of the referenced property.
|
|
71
|
+
*/
|
|
72
72
|
subpropertyOf?: string;
|
|
73
73
|
/**
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
* The description of the property. It is used as the doc comment of
|
|
75
|
+
* the generated property accessors.
|
|
76
|
+
*/
|
|
77
77
|
description: string;
|
|
78
78
|
/**
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
* Whether the enclosed object should have its own context when the document
|
|
80
|
+
* is compacted.
|
|
81
|
+
*/
|
|
82
82
|
embedContext?: {
|
|
83
83
|
/**
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
* The compact name of the property that contains the context.
|
|
85
|
+
*/
|
|
86
86
|
compactName: string;
|
|
87
87
|
/**
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
* Whether the embedded context should be the same as the context of
|
|
89
|
+
* the enclosing document.
|
|
90
|
+
*/
|
|
91
91
|
inherit: true;
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
94
|
type PropertySchemaTyping = {
|
|
95
95
|
/**
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
96
|
+
* Whether the property value has `@type` field. If `true`, the `range` must
|
|
97
|
+
* have only one element.
|
|
98
|
+
*/
|
|
99
99
|
untyped?: false;
|
|
100
100
|
/**
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
* The qualified URIs of all possible types of the property values.
|
|
102
|
+
*/
|
|
103
103
|
range: [TypeUri] | [TypeUri, ...TypeUri[]];
|
|
104
104
|
} | {
|
|
105
105
|
/**
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
* Whether the property value has `@type` field. If `true`, the `range` must
|
|
107
|
+
* have only one element.
|
|
108
|
+
*/
|
|
109
109
|
untyped: true;
|
|
110
110
|
/**
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
* The qualified URIs of all possible types of the property values.
|
|
112
|
+
*/
|
|
113
113
|
range: [TypeUri];
|
|
114
114
|
};
|
|
115
115
|
/**
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
116
|
+
* The schema of a property. It is used to generate property accessors of
|
|
117
|
+
* a class.
|
|
118
|
+
*/
|
|
119
119
|
type PropertySchema = PropertySchemaBase & PropertySchemaTyping & {
|
|
120
120
|
/**
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
121
|
+
* Marks the property that it can have only one value. Turning on this
|
|
122
|
+
* flag will generate only singular property accessors, so `pluralName`
|
|
123
|
+
* and `singularAccessor` should not be specified.
|
|
124
|
+
*/
|
|
125
125
|
functional?: false;
|
|
126
126
|
/**
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
127
|
+
* The plural form of the property name. It is used as the name of the
|
|
128
|
+
* generated property accessors.
|
|
129
|
+
*/
|
|
130
130
|
pluralName: string;
|
|
131
131
|
/**
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
132
|
+
* Whether to generate singular property accessors. Regardless of this
|
|
133
|
+
* flag, plural property accessors are generated (unless `functional` is
|
|
134
|
+
* turned on).
|
|
135
|
+
*/
|
|
136
136
|
singularAccessor?: boolean;
|
|
137
137
|
/**
|
|
138
|
-
|
|
139
|
-
|
|
138
|
+
* The container type of the property values. It can be unspecified.
|
|
139
|
+
*/
|
|
140
140
|
container?: "graph" | "list";
|
|
141
141
|
} | PropertySchemaBase & PropertySchemaTyping & {
|
|
142
142
|
/**
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
143
|
+
* Marks the property that it can have only one value. Turning on this
|
|
144
|
+
* flag will generate only singular property accessors, so `pluralName`
|
|
145
|
+
* and `singularAccessor` should not be specified.
|
|
146
|
+
*/
|
|
147
147
|
functional: true;
|
|
148
148
|
/**
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
149
|
+
* If it's present, those redundant properties are also filled with
|
|
150
|
+
* the same value altogether when the object is serialized into
|
|
151
|
+
* JSON-LD. When it's deserialized from JSON-LD, it tries to
|
|
152
|
+
* parse the values of the specified properties in order.
|
|
153
|
+
*/
|
|
154
154
|
redundantProperties?: {
|
|
155
155
|
/**
|
|
156
|
-
|
|
157
|
-
|
|
156
|
+
* The qualified URI of the property.
|
|
157
|
+
*/
|
|
158
158
|
uri: string;
|
|
159
159
|
/**
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
160
|
+
* The property name used in the compacted JSON-LD document. It is used
|
|
161
|
+
* as the key of the property.
|
|
162
|
+
*/
|
|
163
163
|
compactName?: string;
|
|
164
164
|
}[];
|
|
165
165
|
};
|
|
166
166
|
/**
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
167
|
+
* A JSON-LD context, which is placed in the `@context` property of a JSON-LD
|
|
168
|
+
* document.
|
|
169
|
+
*/
|
|
170
170
|
type Context = Uri | EmbeddedContext | (Uri | EmbeddedContext)[];
|
|
171
171
|
type Uri = "http://{string}" | "https://{string}";
|
|
172
172
|
type EmbeddedContext = Record<string, TermDefinition>;
|
|
173
173
|
type TermDefinition = Uri | Record<string, Uri | "@id">;
|
|
174
174
|
/**
|
|
175
|
-
|
|
176
|
-
|
|
175
|
+
* Type guard to check if a property is not functional (has pluralName).
|
|
176
|
+
*/
|
|
177
177
|
|
|
178
178
|
/**
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
179
|
+
* Loads all schema files in the directory.
|
|
180
|
+
* @param dir The path of the directory to load schema files from.
|
|
181
|
+
* @returns A map from the qualified URI of a type to its {@link TypeSchema}.
|
|
182
|
+
* @throws {@link AggregateError} if any schema file is invalid. It contains
|
|
183
|
+
* all {@link SchemaError}s of the invalid schema files.
|
|
184
|
+
*/
|
|
185
185
|
declare function loadSchemaFiles(dir: string): Promise<Record<string, TypeSchema>>;
|
|
186
186
|
//#endregion
|
|
187
187
|
//#region src/type.d.ts
|
package/dist/mod.d.ts
CHANGED
|
@@ -3,185 +3,185 @@ declare function generateVocab(schemaDir: string, generatedPath: string): Promis
|
|
|
3
3
|
//#endregion
|
|
4
4
|
//#region src/schema.d.ts
|
|
5
5
|
/**
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
* The qualified URI of a type. It is used as the range of a property.
|
|
7
|
+
*/
|
|
8
8
|
type TypeUri = `https://${string}` | `http://${string}` | `fedify:${string}`;
|
|
9
9
|
/**
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
* The schema of a type. It is used to generate a class.
|
|
11
|
+
*/
|
|
12
12
|
interface TypeSchema {
|
|
13
13
|
/**
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
* The type name. It is used as the name of the generated class.
|
|
15
|
+
*/
|
|
16
16
|
name: string;
|
|
17
17
|
/**
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
* The qualified URI of the type.
|
|
19
|
+
*/
|
|
20
20
|
uri: TypeUri;
|
|
21
21
|
/**
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
* The qualified URIs of the base type of the type (if any).
|
|
23
|
+
*/
|
|
24
24
|
extends?: TypeUri;
|
|
25
25
|
/**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
* The type name used in the compacted JSON-LD document. It is used as the
|
|
27
|
+
* value of the `type` field.
|
|
28
|
+
*/
|
|
29
29
|
compactName?: string;
|
|
30
30
|
/**
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
* Marks the type an entity type rather than a value type. Turning on this
|
|
32
|
+
* flag will make property accessors for the type asynchronous, so that they
|
|
33
|
+
* can load the values of the properties from the remote server.
|
|
34
|
+
*
|
|
35
|
+
* The extended subtypes must have the consistent value of this flag.
|
|
36
|
+
*/
|
|
37
37
|
entity: boolean;
|
|
38
38
|
/**
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
* The description of the type. It is used as the doc comment of
|
|
40
|
+
* the generated class.
|
|
41
|
+
*/
|
|
42
42
|
description: string;
|
|
43
43
|
/**
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
* The possible properties of the type.
|
|
45
|
+
*/
|
|
46
46
|
properties: PropertySchema[];
|
|
47
47
|
/**
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
* The default JSON-LD context of the type. It is used as the default
|
|
49
|
+
* context of the generated `toJsonLd()` method.
|
|
50
|
+
*/
|
|
51
51
|
defaultContext: Context;
|
|
52
52
|
}
|
|
53
53
|
interface PropertySchemaBase {
|
|
54
54
|
/**
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
* The singular form of the property name. It is used as the name of the
|
|
56
|
+
* generated property accessors.
|
|
57
|
+
*/
|
|
58
58
|
singularName: string;
|
|
59
59
|
/**
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
* The qualified URI of the property.
|
|
61
|
+
*/
|
|
62
62
|
uri: string;
|
|
63
63
|
/**
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
* The property name used in the compacted JSON-LD document. It is used as
|
|
65
|
+
* the key of the property.
|
|
66
|
+
*/
|
|
67
67
|
compactName?: string;
|
|
68
68
|
/**
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
* The qualified URI of the superproperty of the property (if any).
|
|
70
|
+
* It means that the property is a specialization of the referenced property.
|
|
71
|
+
*/
|
|
72
72
|
subpropertyOf?: string;
|
|
73
73
|
/**
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
* The description of the property. It is used as the doc comment of
|
|
75
|
+
* the generated property accessors.
|
|
76
|
+
*/
|
|
77
77
|
description: string;
|
|
78
78
|
/**
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
* Whether the enclosed object should have its own context when the document
|
|
80
|
+
* is compacted.
|
|
81
|
+
*/
|
|
82
82
|
embedContext?: {
|
|
83
83
|
/**
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
* The compact name of the property that contains the context.
|
|
85
|
+
*/
|
|
86
86
|
compactName: string;
|
|
87
87
|
/**
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
* Whether the embedded context should be the same as the context of
|
|
89
|
+
* the enclosing document.
|
|
90
|
+
*/
|
|
91
91
|
inherit: true;
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
94
|
type PropertySchemaTyping = {
|
|
95
95
|
/**
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
96
|
+
* Whether the property value has `@type` field. If `true`, the `range` must
|
|
97
|
+
* have only one element.
|
|
98
|
+
*/
|
|
99
99
|
untyped?: false;
|
|
100
100
|
/**
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
* The qualified URIs of all possible types of the property values.
|
|
102
|
+
*/
|
|
103
103
|
range: [TypeUri] | [TypeUri, ...TypeUri[]];
|
|
104
104
|
} | {
|
|
105
105
|
/**
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
* Whether the property value has `@type` field. If `true`, the `range` must
|
|
107
|
+
* have only one element.
|
|
108
|
+
*/
|
|
109
109
|
untyped: true;
|
|
110
110
|
/**
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
* The qualified URIs of all possible types of the property values.
|
|
112
|
+
*/
|
|
113
113
|
range: [TypeUri];
|
|
114
114
|
};
|
|
115
115
|
/**
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
116
|
+
* The schema of a property. It is used to generate property accessors of
|
|
117
|
+
* a class.
|
|
118
|
+
*/
|
|
119
119
|
type PropertySchema = PropertySchemaBase & PropertySchemaTyping & {
|
|
120
120
|
/**
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
121
|
+
* Marks the property that it can have only one value. Turning on this
|
|
122
|
+
* flag will generate only singular property accessors, so `pluralName`
|
|
123
|
+
* and `singularAccessor` should not be specified.
|
|
124
|
+
*/
|
|
125
125
|
functional?: false;
|
|
126
126
|
/**
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
127
|
+
* The plural form of the property name. It is used as the name of the
|
|
128
|
+
* generated property accessors.
|
|
129
|
+
*/
|
|
130
130
|
pluralName: string;
|
|
131
131
|
/**
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
132
|
+
* Whether to generate singular property accessors. Regardless of this
|
|
133
|
+
* flag, plural property accessors are generated (unless `functional` is
|
|
134
|
+
* turned on).
|
|
135
|
+
*/
|
|
136
136
|
singularAccessor?: boolean;
|
|
137
137
|
/**
|
|
138
|
-
|
|
139
|
-
|
|
138
|
+
* The container type of the property values. It can be unspecified.
|
|
139
|
+
*/
|
|
140
140
|
container?: "graph" | "list";
|
|
141
141
|
} | PropertySchemaBase & PropertySchemaTyping & {
|
|
142
142
|
/**
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
143
|
+
* Marks the property that it can have only one value. Turning on this
|
|
144
|
+
* flag will generate only singular property accessors, so `pluralName`
|
|
145
|
+
* and `singularAccessor` should not be specified.
|
|
146
|
+
*/
|
|
147
147
|
functional: true;
|
|
148
148
|
/**
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
149
|
+
* If it's present, those redundant properties are also filled with
|
|
150
|
+
* the same value altogether when the object is serialized into
|
|
151
|
+
* JSON-LD. When it's deserialized from JSON-LD, it tries to
|
|
152
|
+
* parse the values of the specified properties in order.
|
|
153
|
+
*/
|
|
154
154
|
redundantProperties?: {
|
|
155
155
|
/**
|
|
156
|
-
|
|
157
|
-
|
|
156
|
+
* The qualified URI of the property.
|
|
157
|
+
*/
|
|
158
158
|
uri: string;
|
|
159
159
|
/**
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
160
|
+
* The property name used in the compacted JSON-LD document. It is used
|
|
161
|
+
* as the key of the property.
|
|
162
|
+
*/
|
|
163
163
|
compactName?: string;
|
|
164
164
|
}[];
|
|
165
165
|
};
|
|
166
166
|
/**
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
167
|
+
* A JSON-LD context, which is placed in the `@context` property of a JSON-LD
|
|
168
|
+
* document.
|
|
169
|
+
*/
|
|
170
170
|
type Context = Uri | EmbeddedContext | (Uri | EmbeddedContext)[];
|
|
171
171
|
type Uri = "http://{string}" | "https://{string}";
|
|
172
172
|
type EmbeddedContext = Record<string, TermDefinition>;
|
|
173
173
|
type TermDefinition = Uri | Record<string, Uri | "@id">;
|
|
174
174
|
/**
|
|
175
|
-
|
|
176
|
-
|
|
175
|
+
* Type guard to check if a property is not functional (has pluralName).
|
|
176
|
+
*/
|
|
177
177
|
|
|
178
178
|
/**
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
179
|
+
* Loads all schema files in the directory.
|
|
180
|
+
* @param dir The path of the directory to load schema files from.
|
|
181
|
+
* @returns A map from the qualified URI of a type to its {@link TypeSchema}.
|
|
182
|
+
* @throws {@link AggregateError} if any schema file is invalid. It contains
|
|
183
|
+
* all {@link SchemaError}s of the invalid schema files.
|
|
184
|
+
*/
|
|
185
185
|
declare function loadSchemaFiles(dir: string): Promise<Record<string, TypeSchema>>;
|
|
186
186
|
//#endregion
|
|
187
187
|
//#region src/type.d.ts
|