@rdfx/resource 0.0.21 → 0.0.22
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/dist/MistypedValueError.d.ts +3 -4
- package/dist/MistypedValueError.js +3 -2
- package/dist/Resource.d.ts +0 -3
- package/dist/Resource.js +3 -4
- package/dist/Value.d.ts +5 -0
- package/dist/Value.js +24 -7
- package/package.json +5 -4
- package/dist/MistypedDateValueError.d.ts +0 -12
- package/dist/MistypedDateValueError.js +0 -14
- package/dist/MistypedPrimitiveValueError.d.ts +0 -13
- package/dist/MistypedPrimitiveValueError.js +0 -14
- package/dist/MistypedTermValueError.d.ts +0 -13
- package/dist/MistypedTermValueError.js +0 -14
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { PropertyPath } from "./PropertyPath.js";
|
|
2
2
|
import type { Resource } from "./Resource.js";
|
|
3
3
|
import { ValueError } from "./ValueError.js";
|
|
4
|
-
export declare
|
|
4
|
+
export declare class MistypedValueError<T> extends ValueError {
|
|
5
5
|
readonly actualValue: T;
|
|
6
6
|
readonly expectedValueType: string;
|
|
7
|
-
constructor({ actualValue, expectedValueType, focusResource,
|
|
7
|
+
constructor({ actualValue, expectedValueType, focusResource, propertyPath, }: {
|
|
8
8
|
actualValue: T;
|
|
9
9
|
expectedValueType: string;
|
|
10
|
-
message: string;
|
|
11
10
|
focusResource: Resource;
|
|
12
11
|
propertyPath: PropertyPath;
|
|
13
12
|
});
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { PropertyPath } from "./PropertyPath.js";
|
|
1
2
|
import { ValueError } from "./ValueError.js";
|
|
2
3
|
export class MistypedValueError extends ValueError {
|
|
3
4
|
actualValue;
|
|
4
5
|
expectedValueType;
|
|
5
|
-
constructor({ actualValue, expectedValueType, focusResource,
|
|
6
|
+
constructor({ actualValue, expectedValueType, focusResource, propertyPath, }) {
|
|
6
7
|
super({
|
|
7
8
|
focusResource,
|
|
8
|
-
message,
|
|
9
|
+
message: `expected ${focusResource.identifier} ${PropertyPath.toString(propertyPath)} to be a ${expectedValueType}, was ${actualValue}`,
|
|
9
10
|
propertyPath,
|
|
10
11
|
});
|
|
11
12
|
this.actualValue = actualValue;
|
package/dist/Resource.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import type { BlankNode, DataFactory, DatasetCore, Literal, NamedNode, Quad_Grap
|
|
|
2
2
|
import { Either } from "purify-ts";
|
|
3
3
|
import type { Identifier as _Identifier, Identifier } from "./Identifier.js";
|
|
4
4
|
import { ListStructureError as _ListStructureError } from "./ListStructureError.js";
|
|
5
|
-
import { MistypedTermValueError as _MistypedTermValueError } from "./MistypedTermValueError.js";
|
|
6
5
|
import type { PropertyPath } from "./PropertyPath.js";
|
|
7
6
|
import type { Term } from "./Term.js";
|
|
8
7
|
import { Value as _Value } from "./Value.js";
|
|
@@ -94,8 +93,6 @@ export declare namespace Resource {
|
|
|
94
93
|
type Identifier = _Identifier;
|
|
95
94
|
const ListStructureError: typeof _ListStructureError;
|
|
96
95
|
type ListStructureError = _ListStructureError;
|
|
97
|
-
const MistypedTermValueError: typeof _MistypedTermValueError;
|
|
98
|
-
type MistypedTermValueError = _MistypedTermValueError;
|
|
99
96
|
const ValueError: typeof _ValueError;
|
|
100
97
|
type ValueError = _ValueError;
|
|
101
98
|
const Value: typeof _Value;
|
package/dist/Resource.js
CHANGED
|
@@ -2,7 +2,7 @@ import TermSet from "@rdfjs/term-set";
|
|
|
2
2
|
import { Either, Left } from "purify-ts";
|
|
3
3
|
import { DatasetValues } from "./DatasetValues.js";
|
|
4
4
|
import { ListStructureError as _ListStructureError } from "./ListStructureError.js";
|
|
5
|
-
import {
|
|
5
|
+
import { MistypedValueError } from "./MistypedValueError.js";
|
|
6
6
|
import { Value as _Value } from "./Value.js";
|
|
7
7
|
import { ValueError as _ValueError } from "./ValueError.js";
|
|
8
8
|
import { Values as _Values } from "./Values.js";
|
|
@@ -253,7 +253,7 @@ export class Resource {
|
|
|
253
253
|
case "NamedNode":
|
|
254
254
|
break;
|
|
255
255
|
default:
|
|
256
|
-
return Left(new
|
|
256
|
+
return Left(new MistypedValueError({
|
|
257
257
|
actualValue: firstObject,
|
|
258
258
|
expectedValueType: "BlankNode | Literal | NamedNode",
|
|
259
259
|
focusResource: this,
|
|
@@ -283,7 +283,7 @@ export class Resource {
|
|
|
283
283
|
case "NamedNode":
|
|
284
284
|
break;
|
|
285
285
|
default:
|
|
286
|
-
return Left(new
|
|
286
|
+
return Left(new MistypedValueError({
|
|
287
287
|
actualValue: restObject,
|
|
288
288
|
expectedValueType: "BlankNode | NamedNode",
|
|
289
289
|
focusResource: this,
|
|
@@ -324,7 +324,6 @@ export class Resource {
|
|
|
324
324
|
}
|
|
325
325
|
(function (Resource) {
|
|
326
326
|
Resource.ListStructureError = _ListStructureError;
|
|
327
|
-
Resource.MistypedTermValueError = _MistypedTermValueError;
|
|
328
327
|
Resource.ValueError = _ValueError;
|
|
329
328
|
Resource.Value = _Value;
|
|
330
329
|
Resource.Values = _Values;
|
package/dist/Value.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { BlankNode, DataFactory, Literal, NamedNode, Quad_Graph, Variable } from "@rdfjs/types";
|
|
2
2
|
import { type Primitive } from "@rdfx/literal";
|
|
3
|
+
import type { Decimal } from "decimal.js";
|
|
3
4
|
import { Either } from "purify-ts";
|
|
4
5
|
import type { Identifier } from "./Identifier.js";
|
|
5
6
|
import type { PropertyPath } from "./PropertyPath.js";
|
|
@@ -17,6 +18,10 @@ export declare class Value<TermT extends Term = Term> {
|
|
|
17
18
|
propertyPath: PropertyPath;
|
|
18
19
|
term: TermT;
|
|
19
20
|
});
|
|
21
|
+
/**
|
|
22
|
+
* Try to convert this term to a bigint.
|
|
23
|
+
*/
|
|
24
|
+
toBigDecimal(in_?: readonly Decimal[]): Either<Error, Decimal>;
|
|
20
25
|
/**
|
|
21
26
|
* Try to convert this term to a bigint.
|
|
22
27
|
*/
|
package/dist/Value.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { LiteralDecoder } from "@rdfx/literal";
|
|
2
2
|
import { NTriplesTerm } from "@rdfx/string";
|
|
3
3
|
import { Either, Left } from "purify-ts";
|
|
4
|
-
import {
|
|
5
|
-
import { MistypedPrimitiveValueError } from "./MistypedPrimitiveValueError.js";
|
|
6
|
-
import { MistypedTermValueError } from "./MistypedTermValueError.js";
|
|
4
|
+
import { MistypedValueError } from "./MistypedValueError.js";
|
|
7
5
|
import { Resource } from "./Resource.js";
|
|
8
6
|
import { Values } from "./Values.js";
|
|
9
7
|
import { rdf } from "./vocabularies.js";
|
|
@@ -18,6 +16,25 @@ export class Value {
|
|
|
18
16
|
this.propertyPath = propertyPath;
|
|
19
17
|
this.term = term;
|
|
20
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Try to convert this term to a bigint.
|
|
21
|
+
*/
|
|
22
|
+
toBigDecimal(in_) {
|
|
23
|
+
return this.toLiteral()
|
|
24
|
+
.chain(LiteralDecoder.decodeBigDecimalLiteral)
|
|
25
|
+
.mapLeft(() => this.newMistypedTermValueError(in_ ? in_.map((_) => _.toString()).join(" | ") : "Decimal"))
|
|
26
|
+
.chain((value) => {
|
|
27
|
+
if (in_ && !in_.some((check) => value.equals(check))) {
|
|
28
|
+
return Left(new MistypedValueError({
|
|
29
|
+
actualValue: value,
|
|
30
|
+
expectedValueType: in_.map((_) => _.toString()).join(" | "),
|
|
31
|
+
focusResource: this.focusResource,
|
|
32
|
+
propertyPath: this.propertyPath,
|
|
33
|
+
}));
|
|
34
|
+
}
|
|
35
|
+
return Either.of(value);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
21
38
|
toBigInt(in_) {
|
|
22
39
|
return this.toLiteral()
|
|
23
40
|
.chain(LiteralDecoder.decodeBigIntLiteral)
|
|
@@ -152,7 +169,7 @@ export class Value {
|
|
|
152
169
|
}
|
|
153
170
|
constrainDate(value, in_) {
|
|
154
171
|
if (in_ && !in_.some((check) => value.getTime() === check.getTime())) {
|
|
155
|
-
return Left(new
|
|
172
|
+
return Left(new MistypedValueError({
|
|
156
173
|
actualValue: value,
|
|
157
174
|
expectedValueType: in_.map((_) => _.toISOString()).join(" | "),
|
|
158
175
|
focusResource: this.focusResource,
|
|
@@ -163,7 +180,7 @@ export class Value {
|
|
|
163
180
|
}
|
|
164
181
|
constrainPrimitive(value, in_) {
|
|
165
182
|
if (in_ && !in_.some((check) => value === check)) {
|
|
166
|
-
return Left(new
|
|
183
|
+
return Left(new MistypedValueError({
|
|
167
184
|
actualValue: value,
|
|
168
185
|
expectedValueType: in_.map((_) => _.toString()).join(" | "),
|
|
169
186
|
focusResource: this.focusResource,
|
|
@@ -174,7 +191,7 @@ export class Value {
|
|
|
174
191
|
}
|
|
175
192
|
constrainTerm(value, in_) {
|
|
176
193
|
if (in_ && !in_.some((check) => value.equals(check))) {
|
|
177
|
-
return Left(new
|
|
194
|
+
return Left(new MistypedValueError({
|
|
178
195
|
actualValue: value,
|
|
179
196
|
expectedValueType: in_.map(NTriplesTerm.stringify).join(" | "),
|
|
180
197
|
focusResource: this.focusResource,
|
|
@@ -184,7 +201,7 @@ export class Value {
|
|
|
184
201
|
return Either.of(value);
|
|
185
202
|
}
|
|
186
203
|
newMistypedTermValueError(expectedValueType) {
|
|
187
|
-
return new
|
|
204
|
+
return new MistypedValueError({
|
|
188
205
|
actualValue: this.term,
|
|
189
206
|
expectedValueType,
|
|
190
207
|
focusResource: this.focusResource,
|
package/package.json
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"dependencies": {
|
|
3
|
-
"@rdfx/literal": "0.0.
|
|
4
|
-
"@rdfx/string": "0.0.
|
|
3
|
+
"@rdfx/literal": "0.0.22",
|
|
4
|
+
"@rdfx/string": "0.0.22",
|
|
5
5
|
"@rdfjs/term-set": "~2.0.3",
|
|
6
6
|
"@rdfjs/types": "~2.0.1",
|
|
7
7
|
"@types/rdfjs__term-set": "~2.0.9",
|
|
8
|
+
"decimal.js": "~10.6.0",
|
|
8
9
|
"purify-ts": "~2.1.4"
|
|
9
10
|
},
|
|
10
11
|
"devDependencies": {
|
|
11
|
-
"@rdfx/data-factory": "0.0.
|
|
12
|
+
"@rdfx/data-factory": "0.0.22",
|
|
12
13
|
"@rdfjs/dataset": "~2.0.2",
|
|
13
14
|
"@tpluscode/rdf-ns-builders": "~4.3.0",
|
|
14
15
|
"@types/rdfjs__dataset": "~2.0.7",
|
|
@@ -40,5 +41,5 @@
|
|
|
40
41
|
},
|
|
41
42
|
"type": "module",
|
|
42
43
|
"types": "./dist/index.d.ts",
|
|
43
|
-
"version": "0.0.
|
|
44
|
+
"version": "0.0.22"
|
|
44
45
|
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { MistypedValueError } from "./MistypedValueError.js";
|
|
2
|
-
import { PropertyPath } from "./PropertyPath.js";
|
|
3
|
-
import type { Resource } from "./Resource.js";
|
|
4
|
-
export declare class MistypedDateValueError extends MistypedValueError<Date> {
|
|
5
|
-
constructor({ actualValue, expectedValueType, focusResource, propertyPath, }: {
|
|
6
|
-
actualValue: Date;
|
|
7
|
-
expectedValueType: string;
|
|
8
|
-
focusResource: Resource;
|
|
9
|
-
propertyPath: PropertyPath;
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=MistypedDateValueError.d.ts.map
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { MistypedValueError } from "./MistypedValueError.js";
|
|
2
|
-
import { PropertyPath } from "./PropertyPath.js";
|
|
3
|
-
export class MistypedDateValueError extends MistypedValueError {
|
|
4
|
-
constructor({ actualValue, expectedValueType, focusResource, propertyPath, }) {
|
|
5
|
-
super({
|
|
6
|
-
actualValue,
|
|
7
|
-
expectedValueType,
|
|
8
|
-
focusResource,
|
|
9
|
-
message: `expected ${focusResource.identifier} ${PropertyPath.toString(propertyPath)} to be a ${expectedValueType}, was ${typeof actualValue}`,
|
|
10
|
-
propertyPath,
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=MistypedDateValueError.js.map
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Primitive } from "@rdfx/literal";
|
|
2
|
-
import { MistypedValueError } from "./MistypedValueError.js";
|
|
3
|
-
import { PropertyPath } from "./PropertyPath.js";
|
|
4
|
-
import type { Resource } from "./Resource.js";
|
|
5
|
-
export declare class MistypedPrimitiveValueError extends MistypedValueError<Primitive> {
|
|
6
|
-
constructor({ actualValue, expectedValueType, focusResource, propertyPath, }: {
|
|
7
|
-
actualValue: Primitive;
|
|
8
|
-
expectedValueType: string;
|
|
9
|
-
focusResource: Resource;
|
|
10
|
-
propertyPath: PropertyPath;
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=MistypedPrimitiveValueError.d.ts.map
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { MistypedValueError } from "./MistypedValueError.js";
|
|
2
|
-
import { PropertyPath } from "./PropertyPath.js";
|
|
3
|
-
export class MistypedPrimitiveValueError extends MistypedValueError {
|
|
4
|
-
constructor({ actualValue, expectedValueType, focusResource, propertyPath, }) {
|
|
5
|
-
super({
|
|
6
|
-
actualValue,
|
|
7
|
-
expectedValueType,
|
|
8
|
-
focusResource,
|
|
9
|
-
message: `expected ${focusResource.identifier} ${PropertyPath.toString(propertyPath)} to be a ${expectedValueType}, was ${typeof actualValue}`,
|
|
10
|
-
propertyPath,
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=MistypedPrimitiveValueError.js.map
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { BlankNode, Literal, NamedNode, Quad, Variable } from "@rdfjs/types";
|
|
2
|
-
import { MistypedValueError } from "./MistypedValueError.js";
|
|
3
|
-
import { PropertyPath } from "./PropertyPath.js";
|
|
4
|
-
import type { Resource } from "./Resource.js";
|
|
5
|
-
export declare class MistypedTermValueError extends MistypedValueError<BlankNode | Literal | NamedNode | Quad | Variable> {
|
|
6
|
-
constructor({ actualValue, expectedValueType, focusResource, propertyPath, }: {
|
|
7
|
-
actualValue: BlankNode | Literal | NamedNode | Quad | Variable;
|
|
8
|
-
expectedValueType: string;
|
|
9
|
-
focusResource: Resource;
|
|
10
|
-
propertyPath: PropertyPath;
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=MistypedTermValueError.d.ts.map
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { MistypedValueError } from "./MistypedValueError.js";
|
|
2
|
-
import { PropertyPath } from "./PropertyPath.js";
|
|
3
|
-
export class MistypedTermValueError extends MistypedValueError {
|
|
4
|
-
constructor({ actualValue, expectedValueType, focusResource, propertyPath, }) {
|
|
5
|
-
super({
|
|
6
|
-
actualValue,
|
|
7
|
-
expectedValueType,
|
|
8
|
-
focusResource,
|
|
9
|
-
message: `expected ${focusResource.identifier} ${PropertyPath.toString(propertyPath)} to be a ${expectedValueType}, was ${actualValue.termType}`,
|
|
10
|
-
propertyPath,
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=MistypedTermValueError.js.map
|