@shaclmate/compiler 4.0.51 → 4.0.53

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.
Files changed (55) hide show
  1. package/dist/generators/ts/AbstractContainerType.d.ts +2 -1
  2. package/dist/generators/ts/AbstractContainerType.js +1 -0
  3. package/dist/generators/ts/AbstractDateType.d.ts +8 -8
  4. package/dist/generators/ts/AbstractDateType.js +7 -16
  5. package/dist/generators/ts/AbstractLiteralType.d.ts +3 -4
  6. package/dist/generators/ts/AbstractLiteralType.js +3 -5
  7. package/dist/generators/ts/AbstractNumericType.d.ts +0 -2
  8. package/dist/generators/ts/AbstractNumericType.js +1 -20
  9. package/dist/generators/ts/AbstractPrimitiveType.d.ts +8 -13
  10. package/dist/generators/ts/AbstractPrimitiveType.js +22 -19
  11. package/dist/generators/ts/AbstractTypedLiteralType.d.ts +32 -0
  12. package/dist/generators/ts/AbstractTypedLiteralType.js +36 -0
  13. package/dist/generators/ts/BigDecimalType.d.ts +4 -2
  14. package/dist/generators/ts/BigDecimalType.js +6 -11
  15. package/dist/generators/ts/BigIntType.js +20 -9
  16. package/dist/generators/ts/BooleanType.d.ts +0 -2
  17. package/dist/generators/ts/BooleanType.js +0 -15
  18. package/dist/generators/ts/DateTimeType.d.ts +1 -1
  19. package/dist/generators/ts/DateTimeType.js +4 -4
  20. package/dist/generators/ts/DateType.d.ts +1 -2
  21. package/dist/generators/ts/DateType.js +4 -4
  22. package/dist/generators/ts/DefaultValueType.d.ts +3 -0
  23. package/dist/generators/ts/LangStringType.d.ts +31 -0
  24. package/dist/generators/ts/LangStringType.js +67 -0
  25. package/dist/generators/ts/ListType.d.ts +2 -1
  26. package/dist/generators/ts/ListType.js +1 -0
  27. package/dist/generators/ts/LiteralType.d.ts +4 -0
  28. package/dist/generators/ts/LiteralType.js +5 -0
  29. package/dist/generators/ts/Snippets.d.ts +4 -1
  30. package/dist/generators/ts/Snippets.js +28 -7
  31. package/dist/generators/ts/StringType.d.ts +5 -2
  32. package/dist/generators/ts/StringType.js +9 -17
  33. package/dist/generators/ts/Type.d.ts +2 -1
  34. package/dist/generators/ts/TypeFactory.js +32 -81
  35. package/dist/generators/ts/UnionType.d.ts +1 -1
  36. package/dist/generators/ts/_snippets/snippets_LangStringSchema.d.ts +3 -0
  37. package/dist/generators/ts/_snippets/snippets_LangStringSchema.js +4 -0
  38. package/dist/generators/ts/_snippets/snippets_RdfVocabularies.js +1 -0
  39. package/dist/generators/ts/_snippets/snippets_bigDecimalFromRdfResourceValues.js +1 -1
  40. package/dist/generators/ts/_snippets/snippets_convertToLangString.d.ts +3 -0
  41. package/dist/generators/ts/_snippets/snippets_convertToLangString.js +15 -0
  42. package/dist/generators/ts/_snippets/snippets_langStringFromRdfResourceValues.d.ts +3 -0
  43. package/dist/generators/ts/_snippets/snippets_langStringFromRdfResourceValues.js +6 -0
  44. package/dist/generators/ts/_snippets/snippets_langStringSparqlWherePatterns.d.ts +3 -0
  45. package/dist/generators/ts/_snippets/snippets_langStringSparqlWherePatterns.js +5 -0
  46. package/dist/generators/ts/_snippets/snippets_literalFromRdfResourceValues.js +1 -1
  47. package/dist/generators/ts/_snippets/snippets_literalSparqlWherePatterns.js +1 -1
  48. package/dist/generators/ts/_snippets/snippets_sparqlValueInPattern.js +4 -1
  49. package/dist/generators/ts/_snippets/snippets_termFromRdfResourceValues.js +2 -2
  50. package/dist/generators/ts/_snippets/snippets_termLikeFromRdfResourceValues.js +1 -1
  51. package/dist/generators/ts/rdfjsTermExpression.js +1 -0
  52. package/dist/input/input.shaclmate.js +3 -3
  53. package/package.json +19 -8
  54. package/dist/generators/ts/_snippets/snippets_decodeBigDecimalLiteral.d.ts +0 -3
  55. package/dist/generators/ts/_snippets/snippets_decodeBigDecimalLiteral.js +0 -9
@@ -0,0 +1,3 @@
1
+ import type { SnippetFactory } from "../SnippetFactory.js";
2
+ export declare const snippets_langStringSparqlWherePatterns: SnippetFactory;
3
+ //# sourceMappingURL=snippets_langStringSparqlWherePatterns.d.ts.map
@@ -0,0 +1,5 @@
1
+ import { code, conditionalOutput } from "../ts-poet-wrapper.js";
2
+ export const snippets_langStringSparqlWherePatterns = ({ snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}langStringSparqlWherePatterns`, code `\
3
+ const ${syntheticNamePrefix}langStringSparqlWherePatterns: ${snippets.ValueSparqlWherePatternsFunction}<${snippets.LiteralFilter}, ${snippets.LangStringSchema}> =
4
+ (parameters) => ${snippets.literalSchemaSparqlPatterns}({ filterPatterns: ${snippets.termFilterSparqlPatterns}(parameters), ...parameters });`);
5
+ //# sourceMappingURL=snippets_langStringSparqlWherePatterns.js.map
@@ -1,6 +1,6 @@
1
1
  import { code, conditionalOutput } from "../ts-poet-wrapper.js";
2
2
  export const snippets_literalFromRdfResourceValues = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}literalFromRdfResourceValues`, code `\
3
3
  function ${syntheticNamePrefix}literalFromRdfResourceValues(values: ${imports.Resource}.Values, options: Parameters<${snippets.FromRdfResourceValuesFunction}<${imports.Literal}, ${snippets.LiteralSchema}>>[1]): ${imports.Either}<Error, ${imports.Resource}.Values<${imports.Literal}>> {
4
- return ${snippets.termLikeFromRdfResourceValues}(values, options).chain(values => values.chainMap(value => value.toLiteral()));
4
+ return ${snippets.termLikeFromRdfResourceValues}(values, options).chain(values => values.chainMap(value => value.toLiteral(options.schema.in)));
5
5
  }`);
6
6
  //# sourceMappingURL=snippets_literalFromRdfResourceValues.js.map
@@ -1,5 +1,5 @@
1
1
  import { code, conditionalOutput } from "../ts-poet-wrapper.js";
2
2
  export const snippets_literalSparqlWherePatterns = ({ snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}literalSparqlWherePatterns`, code `\
3
3
  const ${syntheticNamePrefix}literalSparqlWherePatterns: ${snippets.ValueSparqlWherePatternsFunction}<${snippets.LiteralFilter}, ${snippets.LiteralSchema}> =
4
- (parameters) => ${syntheticNamePrefix}literalSchemaSparqlPatterns({ filterPatterns: ${snippets.termFilterSparqlPatterns}(parameters), ...parameters });`);
4
+ (parameters) => ${snippets.literalSchemaSparqlPatterns}({ filterPatterns: ${snippets.termFilterSparqlPatterns}(parameters), ...parameters });`);
5
5
  //# sourceMappingURL=snippets_literalSparqlWherePatterns.js.map
@@ -8,9 +8,12 @@ function ${syntheticNamePrefix}sparqlValueInPattern({ lift, valueIn, valueVariab
8
8
  return {
9
9
  expression: {
10
10
  args: [valueVariable, valueIn.map(inValue => {
11
- if (typeof inValue !== "object" || inValue instanceof Date) {
11
+ if (typeof inValue !== "object") {
12
12
  return ${snippets.literalFactory}.primitive(inValue);
13
13
  }
14
+ if (inValue instanceof Date) {
15
+ return ${snippets.literalFactory}.date(inValue);
16
+ }
14
17
  return inValue;
15
18
  })],
16
19
  operator: "in",
@@ -4,11 +4,11 @@ function ${syntheticNamePrefix}termFromRdfResourceValues<TermT extends ${imports
4
4
  const { focusResource, propertyPath, schema } = options;
5
5
  return ${snippets.termLikeFromRdfResourceValues}(values, options).chain(values => values.chainMap(value => value.toTerm().chain(term => {
6
6
  if (schema.in && schema.in.length > 0 && !schema.in.some(in_ => in_.equals(term))) {
7
- return ${imports.Left}(new ${imports.Resource}.MistypedTermValueError({ actualValue: term, expectedValueType: "Term in", focusResource, propertyPath }));
7
+ return ${imports.Left}(new ${imports.Resource}.MistypedValueError({ actualValue: term, expectedValueType: "Term in", focusResource, propertyPath }));
8
8
  }
9
9
 
10
10
  if (!schema.types.some(type => term.termType === type)) {
11
- return ${imports.Left}(new ${imports.Resource}.MistypedTermValueError({ actualValue: term, expectedValueType: "Term types", focusResource, propertyPath }));
11
+ return ${imports.Left}(new ${imports.Resource}.MistypedValueError({ actualValue: term, expectedValueType: "BlankNode | Literal | NamedNode", focusResource, propertyPath }));
12
12
  }
13
13
 
14
14
  return ${imports.Right}(term as TermT);
@@ -15,7 +15,7 @@ const ${syntheticNamePrefix}termLikeFromRdfResourceValues:
15
15
  chain = chain.chain(values => values.chainMap(value => value.toLiteral().chain(literal =>
16
16
  languageIn.includes(literal.language) ?
17
17
  ${imports.Right}(value) :
18
- ${imports.Left}(new ${imports.Resource}.MistypedTermValueError(${{
18
+ ${imports.Left}(new ${imports.Resource}.MistypedValueError(${{
19
19
  actualValue: code `literal`,
20
20
  expectedValueType: "Literal",
21
21
  focusResource: code `value.focusResource`,
@@ -17,6 +17,7 @@ export function rdfjsTermExpression(rdfjsTerm) {
17
17
  const unqualifiedName = rdfjsTerm.value.substring(rdf[""].value.length);
18
18
  switch (unqualifiedName) {
19
19
  case "first":
20
+ case "langString":
20
21
  case "nil":
21
22
  case "rest":
22
23
  case "subject":
@@ -314,7 +314,7 @@ function $termFromRdfResourceValues(values, options) {
314
314
  if (schema.in &&
315
315
  schema.in.length > 0 &&
316
316
  !schema.in.some((in_) => in_.equals(term))) {
317
- return Left(new Resource.MistypedTermValueError({
317
+ return Left(new Resource.MistypedValueError({
318
318
  actualValue: term,
319
319
  expectedValueType: "Term in",
320
320
  focusResource,
@@ -322,7 +322,7 @@ function $termFromRdfResourceValues(values, options) {
322
322
  }));
323
323
  }
324
324
  if (!schema.types.some((type) => term.termType === type)) {
325
- return Left(new Resource.MistypedTermValueError({
325
+ return Left(new Resource.MistypedValueError({
326
326
  actualValue: term,
327
327
  expectedValueType: "Term types",
328
328
  focusResource,
@@ -340,7 +340,7 @@ const $termLikeFromRdfResourceValues = (values, { preferredLanguages, schema: {
340
340
  if (languageIn && languageIn.length > 0) {
341
341
  chain = chain.chain((values) => values.chainMap((value) => value.toLiteral().chain((literal) => languageIn.includes(literal.language)
342
342
  ? Right(value)
343
- : Left(new Resource.MistypedTermValueError({
343
+ : Left(new Resource.MistypedValueError({
344
344
  actualValue: literal,
345
345
  expectedValueType: "Literal",
346
346
  focusResource: value.focusResource,
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "dependencies": {
3
- "@shaclmate/shacl-ast": "4.0.51",
3
+ "@shaclmate/shacl-ast": "4.0.53",
4
4
  "@rdfjs/dataset": "~2.0.2",
5
5
  "@rdfjs/prefix-map": "~0.1.2",
6
6
  "@rdfjs/term-map": "~2.0.2",
7
7
  "@rdfjs/term-set": "~2.0.3",
8
8
  "@rdfjs/types": "~2.0.1",
9
- "@rdfx/data-factory": "0.0.19",
10
- "@rdfx/literal": "0.0.19",
11
- "@rdfx/resource": "0.0.19",
12
- "@rdfx/string": "0.0.19",
9
+ "@rdfx/data-factory": "0.0.24",
10
+ "@rdfx/literal": "0.0.24",
11
+ "@rdfx/resource": "0.0.24",
12
+ "@rdfx/string": "0.0.24",
13
13
  "@sindresorhus/base62": "~0.1.0",
14
14
  "@tpluscode/rdf-ns-builders": "~4.3.0",
15
15
  "@types/rdfjs__dataset": "~2.0.7",
@@ -17,6 +17,7 @@
17
17
  "@types/rdfjs__term-map": "~2.0.10",
18
18
  "@types/rdfjs__term-set": "~2.0.9",
19
19
  "change-case": "~5.4.4",
20
+ "decimal.js": "~10.6.0",
20
21
  "plur": "~5.1.0",
21
22
  "purify-ts": "~2.1.4",
22
23
  "reserved-identifiers": "~1.0.0",
@@ -147,6 +148,8 @@
147
148
  "dist/generators/ts/AbstractTermType.js",
148
149
  "dist/generators/ts/AbstractType.d.ts",
149
150
  "dist/generators/ts/AbstractType.js",
151
+ "dist/generators/ts/AbstractTypedLiteralType.d.ts",
152
+ "dist/generators/ts/AbstractTypedLiteralType.js",
150
153
  "dist/generators/ts/BigDecimalType.d.ts",
151
154
  "dist/generators/ts/BigDecimalType.js",
152
155
  "dist/generators/ts/BigIntType.d.ts",
@@ -173,6 +176,8 @@
173
176
  "dist/generators/ts/IntType.js",
174
177
  "dist/generators/ts/IriType.d.ts",
175
178
  "dist/generators/ts/IriType.js",
179
+ "dist/generators/ts/LangStringType.d.ts",
180
+ "dist/generators/ts/LangStringType.js",
176
181
  "dist/generators/ts/LazyOptionType.d.ts",
177
182
  "dist/generators/ts/LazyOptionType.js",
178
183
  "dist/generators/ts/LazySetType.d.ts",
@@ -333,6 +338,8 @@
333
338
  "dist/generators/ts/_snippets/snippets_IriFilter.js",
334
339
  "dist/generators/ts/_snippets/snippets_IriSchema.d.ts",
335
340
  "dist/generators/ts/_snippets/snippets_IriSchema.js",
341
+ "dist/generators/ts/_snippets/snippets_LangStringSchema.d.ts",
342
+ "dist/generators/ts/_snippets/snippets_LangStringSchema.js",
336
343
  "dist/generators/ts/_snippets/snippets_Lazy.d.ts",
337
344
  "dist/generators/ts/_snippets/snippets_Lazy.js",
338
345
  "dist/generators/ts/_snippets/snippets_LazyOption.d.ts",
@@ -425,6 +432,8 @@
425
432
  "dist/generators/ts/_snippets/snippets_convertToIri.js",
426
433
  "dist/generators/ts/_snippets/snippets_convertToIriIdentifierProperty.d.ts",
427
434
  "dist/generators/ts/_snippets/snippets_convertToIriIdentifierProperty.js",
435
+ "dist/generators/ts/_snippets/snippets_convertToLangString.d.ts",
436
+ "dist/generators/ts/_snippets/snippets_convertToLangString.js",
428
437
  "dist/generators/ts/_snippets/snippets_convertToLazy.d.ts",
429
438
  "dist/generators/ts/_snippets/snippets_convertToLazy.js",
430
439
  "dist/generators/ts/_snippets/snippets_convertToLazyOption.d.ts",
@@ -449,8 +458,6 @@
449
458
  "dist/generators/ts/_snippets/snippets_dateSparqlWherePatterns.js",
450
459
  "dist/generators/ts/_snippets/snippets_dateTimeFromRdfResourceValues.d.ts",
451
460
  "dist/generators/ts/_snippets/snippets_dateTimeFromRdfResourceValues.js",
452
- "dist/generators/ts/_snippets/snippets_decodeBigDecimalLiteral.d.ts",
453
- "dist/generators/ts/_snippets/snippets_decodeBigDecimalLiteral.js",
454
461
  "dist/generators/ts/_snippets/snippets_deduplicateSparqlPatterns.d.ts",
455
462
  "dist/generators/ts/_snippets/snippets_deduplicateSparqlPatterns.js",
456
463
  "dist/generators/ts/_snippets/snippets_defaultValueFromRdfResourceValues.d.ts",
@@ -517,6 +524,10 @@
517
524
  "dist/generators/ts/_snippets/snippets_iriFromRdfResourceValues.js",
518
525
  "dist/generators/ts/_snippets/snippets_iriSparqlWherePatterns.d.ts",
519
526
  "dist/generators/ts/_snippets/snippets_iriSparqlWherePatterns.js",
527
+ "dist/generators/ts/_snippets/snippets_langStringFromRdfResourceValues.d.ts",
528
+ "dist/generators/ts/_snippets/snippets_langStringFromRdfResourceValues.js",
529
+ "dist/generators/ts/_snippets/snippets_langStringSparqlWherePatterns.d.ts",
530
+ "dist/generators/ts/_snippets/snippets_langStringSparqlWherePatterns.js",
520
531
  "dist/generators/ts/_snippets/snippets_liftSparqlPatterns.d.ts",
521
532
  "dist/generators/ts/_snippets/snippets_liftSparqlPatterns.js",
522
533
  "dist/generators/ts/_snippets/snippets_listFromRdfResourceValues.d.ts",
@@ -649,5 +660,5 @@
649
660
  },
650
661
  "type": "module",
651
662
  "types": "./dist/index.d.ts",
652
- "version": "4.0.51"
663
+ "version": "4.0.53"
653
664
  }
@@ -1,3 +0,0 @@
1
- import type { SnippetFactory } from "../SnippetFactory.js";
2
- export declare const snippets_decodeBigDecimalLiteral: SnippetFactory;
3
- //# sourceMappingURL=snippets_decodeBigDecimalLiteral.d.ts.map
@@ -1,9 +0,0 @@
1
- import { code, conditionalOutput } from "../ts-poet-wrapper.js";
2
- export const snippets_decodeBigDecimalLiteral = ({ imports, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}decodeBigDecimalLiteral`, code `\
3
- /**
4
- * Decidoe a BigDecimal from a Literal.
5
- */
6
- function ${syntheticNamePrefix}decodeBigDecimalLiteral(literal: ${imports.Literal}): ${imports.Either}<Error, ${imports.BigDecimal}> {
7
- return ${imports.Either}.encase(() => new ${imports.BigDecimal}(literal.value));
8
- }`);
9
- //# sourceMappingURL=snippets_decodeBigDecimalLiteral.js.map