@shaclmate/compiler 4.0.95 → 4.0.96

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.
@@ -23,23 +23,23 @@ export declare abstract class AbstractLazyType<PartialTypeT extends AbstractLazy
23
23
  partialType: PartialTypeT;
24
24
  resolveType: ResolveTypeT;
25
25
  } & ConstructorParameters<typeof AbstractType>[0]);
26
- get jsonValueType(): AbstractType["jsonValueType"];
27
26
  get equalsFunction(): Callable;
28
- get jsonObjectType(): AbstractType["jsonObjectType"];
29
27
  get filterFunction(): Callable;
30
28
  get filterType(): Code;
31
- get fromJsonValueFunction(): AbstractType["fromJsonValueFunction"];
32
29
  get fromJsonObjectFunction(): AbstractType["fromJsonObjectFunction"];
30
+ get fromJsonValueFunction(): AbstractType["fromJsonValueFunction"];
33
31
  get fromRdfResourceValuesFunction(): Callable;
34
32
  get graphqlType(): AbstractType.GraphqlType;
35
33
  get hashFunction(): Callable;
36
34
  get inlineExpression(): Code;
37
35
  get jsTypes(): readonly AbstractType.JsType[];
36
+ get jsonObjectType(): AbstractType["jsonObjectType"];
37
+ get jsonValueType(): AbstractType["jsonValueType"];
38
38
  get recursive(): boolean;
39
39
  get referencesNamedType(): boolean;
40
40
  get schemaType(): Code;
41
- get toJsonValueFunction(): AbstractType["toJsonValueFunction"];
42
41
  get toJsonObjectFunction(): AbstractType["toJsonObjectFunction"];
42
+ get toJsonValueFunction(): AbstractType["toJsonValueFunction"];
43
43
  get toRdfResourceValueTypes(): AbstractType["toRdfResourceValueTypes"];
44
44
  get valueSparqlConstructTriplesFunction(): Callable;
45
45
  get valueSparqlWherePatternsFunction(): Callable;
@@ -47,9 +47,11 @@ export declare abstract class AbstractLazyType<PartialTypeT extends AbstractLazy
47
47
  toLoggableExpression({ variables, }: Parameters<AbstractType["toLoggableExpression"]>[0]): Code;
48
48
  toRdfResourceValuesExpression({ variables, }: Parameters<AbstractType["toRdfResourceValuesExpression"]>[0]): Code;
49
49
  toStringExpression({ variables, }: Parameters<AbstractType["toStringExpression"]>[0]): Code;
50
- protected abstract objectSetResolverFunctionExpressions(parameters: {
50
+ protected abstract objectSetResolveExpression(parameters: {
51
51
  variables: {
52
52
  objectSet: Code;
53
+ partial: Code;
54
+ resolverOptions: Code;
53
55
  };
54
56
  }): Code;
55
57
  protected resolveToPartialFunction<ObjectTypeT extends AbstractLazyType.ItemTypeConstraint>({ partialType, resolveType, }: {
@@ -63,6 +65,11 @@ export declare abstract class AbstractLazyType<PartialTypeT extends AbstractLazy
63
65
  resolvedObjectDiscriminatedUnion: Code;
64
66
  };
65
67
  }): Code;
68
+ protected resolverFunctionExpression({ variables, }: {
69
+ variables: {
70
+ factoryFunctionOptions: Code;
71
+ };
72
+ }): Code;
66
73
  }
67
74
  export declare namespace AbstractLazyType {
68
75
  type ItemTypeConstraint = ObjectType | ObjectDiscriminatedUnionType;
@@ -21,17 +21,11 @@ export class AbstractLazyType extends AbstractType {
21
21
  this.partialType = partialType;
22
22
  this.resolveType = resolveType;
23
23
  }
24
- get jsonValueType() {
25
- return this.partialType.jsonValueType;
26
- }
27
24
  get equalsFunction() {
28
25
  return new InlineCallable(code `(left, right) => ${this.partialType.equalsFunction.annotatedUsage}(left.${this.runtimeClass.partialPropertyName}, right.${this.runtimeClass.partialPropertyName})`, {
29
26
  type: code `${this.reusables.snippets.EqualsFunction}<${this.expression}>`,
30
27
  });
31
28
  }
32
- get jsonObjectType() {
33
- return this.partialType.jsonObjectType;
34
- }
35
29
  get filterFunction() {
36
30
  return new InlineCallable(code `(filter, value) => ${this.partialType.filterFunction.annotatedUsage}(filter, value.${this.runtimeClass.partialPropertyName})`, {
37
31
  type: code `${this.reusables.snippets.FilterFunction}<${this.filterType}, ${this.expression}>`,
@@ -40,23 +34,23 @@ export class AbstractLazyType extends AbstractType {
40
34
  get filterType() {
41
35
  return this.partialType.filterType;
42
36
  }
43
- get fromJsonValueFunction() {
44
- return new InlineCallable(code `(jsonValue, { objectSet, schema, ...otherOptions }) => ${this.partialType.fromJsonValueFunction.annotatedUsage}(jsonValue, { objectSet, schema: schema.partialType, ...otherOptions })
45
- .map(${this.runtimeClass.partialPropertyName} => new ${this.runtimeClass.name}({ ${this.runtimeClass.partialPropertyName}, resolver: objectSet ? ${this.objectSetResolverFunctionExpressions({ variables: { objectSet: code `objectSet` } })} : ${this.reusables.snippets.missingResolver} }))`, {
46
- type: code `${this.reusables.snippets.FromJsonValueFunction}<${this.jsonValueType.expression}, ${this.expression}, ${this.schema}>`,
47
- });
48
- }
49
37
  get fromJsonObjectFunction() {
50
- return new InlineCallable(code `(jsonObject, { objectSet, schema, ...otherOptions }) => ${this.partialType.fromJsonObjectFunction.annotatedUsage}(jsonObject, { objectSet, schema: schema.partialType, ...otherOptions })
51
- .map(${this.runtimeClass.partialPropertyName} => new ${this.runtimeClass.name}({ ${this.runtimeClass.partialPropertyName}, resolver: objectSet ? ${this.objectSetResolverFunctionExpressions({ variables: { objectSet: code `objectSet` } })} : ${this.reusables.snippets.missingResolver} }))`, {
38
+ return new InlineCallable(code `(jsonObject, fromJsonObjectOptions) => ${this.partialType.fromJsonObjectFunction.annotatedUsage}(jsonObject, { ...fromJsonObjectOptions, schema: fromJsonObjectOptions.schema.partialType })
39
+ .map(${this.runtimeClass.partialPropertyName} => new ${this.runtimeClass.name}({ ${this.runtimeClass.partialPropertyName}, resolver: ${this.resolverFunctionExpression({ variables: { factoryFunctionOptions: code `fromJsonObjectOptions` } })} }))`, {
52
40
  type: code `${this.reusables.snippets.FromJsonObjectFunction}<${this.jsonObjectType.expression}, ${this.expression}, ${this.schema}>`,
53
41
  });
54
42
  }
43
+ get fromJsonValueFunction() {
44
+ return new InlineCallable(code `(jsonValue, fromJsonValueOptions) => ${this.partialType.fromJsonValueFunction.annotatedUsage}(jsonValue, { ...fromJsonValueOptions, schema: fromJsonValueOptions.schema.partialType })
45
+ .map(${this.runtimeClass.partialPropertyName} => new ${this.runtimeClass.name}({ ${this.runtimeClass.partialPropertyName}, resolver: ${this.resolverFunctionExpression({ variables: { factoryFunctionOptions: code `fromJsonValueOptions` } })} }))`, {
46
+ type: code `${this.reusables.snippets.FromJsonValueFunction}<${this.jsonValueType.expression}, ${this.expression}, ${this.schema}>`,
47
+ });
48
+ }
55
49
  get fromRdfResourceValuesFunction() {
56
50
  return new InlineCallable(code `\
57
- (values, { objectSet, schema, ...otherOptions }) =>
58
- ${this.partialType.fromRdfResourceValuesFunction.annotatedUsage}(values, { objectSet, schema: schema.partialType, ...otherOptions })
59
- .map(values => values.map(${this.runtimeClass.partialPropertyName} => new ${this.runtimeClass.name}({ ${this.runtimeClass.partialPropertyName}, resolver: ${this.objectSetResolverFunctionExpressions({ variables: { objectSet: code `objectSet` } })} })))`, {
51
+ (values, fromRdfResourceValuesOptions) =>
52
+ ${this.partialType.fromRdfResourceValuesFunction.annotatedUsage}(values, { ...fromRdfResourceValuesOptions, schema: fromRdfResourceValuesOptions.schema.partialType })
53
+ .map(values => values.map(${this.runtimeClass.partialPropertyName} => new ${this.runtimeClass.name}({ ${this.runtimeClass.partialPropertyName}, resolver: ${this.resolverFunctionExpression({ variables: { factoryFunctionOptions: code `fromRdfResourceValuesOptions` } })} })))`, {
60
54
  type: code `${this.reusables.snippets.FromRdfResourceValuesFunction}<${this.expression}, ${this.schemaType}>`,
61
55
  });
62
56
  }
@@ -78,6 +72,12 @@ export class AbstractLazyType extends AbstractType {
78
72
  },
79
73
  ];
80
74
  }
75
+ get jsonObjectType() {
76
+ return this.partialType.jsonObjectType;
77
+ }
78
+ get jsonValueType() {
79
+ return this.partialType.jsonValueType;
80
+ }
81
81
  get recursive() {
82
82
  return this.partialType.recursive;
83
83
  }
@@ -90,16 +90,16 @@ export class AbstractLazyType extends AbstractType {
90
90
  partialType: this.partialType.schemaType,
91
91
  }}`;
92
92
  }
93
- get toJsonValueFunction() {
94
- return new InlineCallable(code `(value) => ${this.partialType.toJsonValueFunction.unannotatedUsage}(value.${this.runtimeClass.partialPropertyName})`, {
95
- type: code `${this.reusables.snippets.ToJsonValueFunction}<${this.expression}, ${this.jsonValueType.expression}>`,
96
- });
97
- }
98
93
  get toJsonObjectFunction() {
99
94
  return new InlineCallable(code `(value) => ${this.partialType.toJsonObjectFunction.unannotatedUsage}(value.${this.runtimeClass.partialPropertyName})`, {
100
95
  type: code `${this.reusables.snippets.ToJsonObjectFunction}<${this.expression}, ${this.jsonValueType.expression}>`,
101
96
  });
102
97
  }
98
+ get toJsonValueFunction() {
99
+ return new InlineCallable(code `(value) => ${this.partialType.toJsonValueFunction.unannotatedUsage}(value.${this.runtimeClass.partialPropertyName})`, {
100
+ type: code `${this.reusables.snippets.ToJsonValueFunction}<${this.expression}, ${this.jsonValueType.expression}>`,
101
+ });
102
+ }
103
103
  get toRdfResourceValueTypes() {
104
104
  return this.partialType.toRdfResourceValueTypes;
105
105
  }
@@ -160,6 +160,19 @@ export class AbstractLazyType extends AbstractType {
160
160
  caseBlocks.push(code `default: ${variables.resolvedObjectDiscriminatedUnion} satisfies never; throw new Error("unrecognized type");`);
161
161
  return code `switch (${variables.resolvedObjectDiscriminatedUnion}.${resolvedObjectDiscriminatedUnionType.discriminatedType.unsafeCoerce().discriminantProperty.name}) { ${joinCode(caseBlocks)} }`;
162
162
  }
163
+ resolverFunctionExpression({ variables, }) {
164
+ if (!this.configuration.features.has("ObjectSet")) {
165
+ return code `${this.reusables.snippets.missingResolver}`;
166
+ }
167
+ return code `\
168
+ (partial, resolverOptions) => {
169
+ const objectSet = ${variables.factoryFunctionOptions}?.objectSet;
170
+ if (!objectSet) {
171
+ return ${this.reusables.snippets.missingResolver}();
172
+ }
173
+ return ${this.objectSetResolveExpression({ variables: { objectSet: code `objectSet`, partial: code `partial`, resolverOptions: code `resolverOptions` } })};
174
+ }`;
175
+ }
163
176
  }
164
177
  __decorate([
165
178
  Memoize()
@@ -5,7 +5,7 @@ import { type Code } from "./ts-poet-wrapper.js";
5
5
  export declare class LazyOptionType extends AbstractLazyType<OptionType<AbstractLazyType.ItemTypeConstraint>, OptionType<AbstractLazyType.ItemTypeConstraint>> {
6
6
  protected readonly partialItemType: AbstractLazyType.ItemTypeConstraint;
7
7
  protected readonly resolveItemType: AbstractLazyType.ItemTypeConstraint;
8
- readonly graphqlArgs: AbstractLazyType<OptionType<AbstractLazyType.ItemTypeConstraint>, OptionType<AbstractLazyType.ItemTypeConstraint>>["graphqlArgs"];
8
+ readonly graphqlArgs: Super["graphqlArgs"];
9
9
  readonly kind = "LazyOption";
10
10
  get conversionFunction(): Maybe<AbstractLazyType.ConversionFunction>;
11
11
  protected get runtimeClass(): {
@@ -13,11 +13,9 @@ export declare class LazyOptionType extends AbstractLazyType<OptionType<Abstract
13
13
  partialPropertyName: string;
14
14
  rawName: Code;
15
15
  };
16
- protected objectSetResolverFunctionExpressions({ variables, }: {
17
- variables: {
18
- objectSet: Code;
19
- };
20
- }): Code;
21
- graphqlResolveExpression({ variables, }: Parameters<AbstractLazyType<OptionType<AbstractLazyType.ItemTypeConstraint>, OptionType<AbstractLazyType.ItemTypeConstraint>>["graphqlResolveExpression"]>[0]): Code;
16
+ protected objectSetResolveExpression({ variables, }: Parameters<Super["objectSetResolveExpression"]>[0]): Code;
17
+ graphqlResolveExpression({ variables, }: Parameters<Super["graphqlResolveExpression"]>[0]): Code;
22
18
  }
19
+ type Super = AbstractLazyType<OptionType<AbstractLazyType.ItemTypeConstraint>, OptionType<AbstractLazyType.ItemTypeConstraint>>;
20
+ export {};
23
21
  //# sourceMappingURL=LazyOptionType.d.ts.map
@@ -53,8 +53,8 @@ ${this.reusables.snippets.convertToLazyOption}<
53
53
  rawName: code `${this.reusables.snippets.LazyOption}`,
54
54
  };
55
55
  }
56
- objectSetResolverFunctionExpressions({ variables, }) {
57
- return code `(partial, options) => ${variables.objectSet}.${this.resolveItemType.objectSetMethodNames.object}(partial.${this.partialItemType.identifierProperty.unsafeCoerce().name}(), options)`;
56
+ objectSetResolveExpression({ variables, }) {
57
+ return code `${variables.objectSet}.${this.resolveItemType.objectSetMethodNames.object}(${variables.partial}.${this.partialItemType.identifierProperty.unsafeCoerce().name}(), ${variables.resolverOptions})`;
58
58
  }
59
59
  graphqlResolveExpression({ variables, }) {
60
60
  return code `${variables.value}.resolve().then(either => either.unsafeCoerce().extractNullable())`;
@@ -8,11 +8,7 @@ export declare class LazySetType extends AbstractLazyType<SetType<AbstractLazyTy
8
8
  readonly graphqlArgs: Super["graphqlArgs"];
9
9
  readonly kind = "LazySet";
10
10
  get conversionFunction(): Maybe<AbstractLazyType.ConversionFunction>;
11
- protected objectSetResolverFunctionExpressions({ variables, }: {
12
- variables: {
13
- objectSet: Code;
14
- };
15
- }): Code;
11
+ protected objectSetResolveExpression({ variables, }: Parameters<Super["objectSetResolveExpression"]>[0]): Code;
16
12
  protected get runtimeClass(): {
17
13
  name: Code;
18
14
  partialPropertyName: string;
@@ -52,8 +52,8 @@ ${this.reusables.snippets.convertToLazySet}<
52
52
  ],
53
53
  });
54
54
  }
55
- objectSetResolverFunctionExpressions({ variables, }) {
56
- return code `(partials, options) => ${variables.objectSet}.${this.resolveType.itemType.objectSetMethodNames.objects}({ identifiers: partials.map(partial => partial.${this.partialItemType.identifierProperty.unsafeCoerce().name}()), ...options })`;
55
+ objectSetResolveExpression({ variables, }) {
56
+ return code `${variables.objectSet}.${this.resolveType.itemType.objectSetMethodNames.objects}({ identifiers: ${variables.partial}.map(partial => partial.${this.partialItemType.identifierProperty.unsafeCoerce().name}()), ...${variables.resolverOptions} })`;
57
57
  }
58
58
  get runtimeClass() {
59
59
  return {
@@ -13,11 +13,7 @@ export declare class LazyType extends AbstractLazyType<AbstractLazyType.ItemType
13
13
  rawName: Code;
14
14
  };
15
15
  graphqlResolveExpression({ variables, }: Parameters<Super["graphqlResolveExpression"]>[0]): Code;
16
- protected objectSetResolverFunctionExpressions({ variables, }: {
17
- variables: {
18
- objectSet: Code;
19
- };
20
- }): Code;
16
+ protected objectSetResolveExpression({ variables, }: Parameters<Super["objectSetResolveExpression"]>[0]): Code;
21
17
  }
22
18
  type Super = AbstractLazyType<AbstractLazyType.ItemTypeConstraint, AbstractLazyType.ItemTypeConstraint>;
23
19
  export {};
@@ -47,8 +47,8 @@ ${this.reusables.snippets.convertToLazy}<
47
47
  graphqlResolveExpression({ variables, }) {
48
48
  return code `${variables.value}.resolve().then(either => either.unsafeCoerce())`;
49
49
  }
50
- objectSetResolverFunctionExpressions({ variables, }) {
51
- return code `(partial, options) => ${variables.objectSet}.${this.resolveItemType.objectSetMethodNames.object}(partial.${this.partialItemType.identifierProperty.unsafeCoerce().name}(), options)`;
50
+ objectSetResolveExpression({ variables, }) {
51
+ return code `${variables.objectSet}.${this.resolveItemType.objectSetMethodNames.object}(${variables.partial}.${this.partialItemType.identifierProperty.unsafeCoerce().name}(), ${variables.resolverOptions})`;
52
52
  }
53
53
  }
54
54
  __decorate([
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "dependencies": {
3
- "@shaclmate/shacl-ast": "4.0.95",
3
+ "@shaclmate/shacl-ast": "4.0.96",
4
4
  "@rdfjs/types": "~2.0.1",
5
5
  "@rdfx/collection": "0.0.59",
6
6
  "@rdfx/curie": "0.0.59",
@@ -972,5 +972,5 @@
972
972
  },
973
973
  "type": "module",
974
974
  "types": "./dist/index.d.ts",
975
- "version": "4.0.95"
975
+ "version": "4.0.96"
976
976
  }