@shaclmate/compiler 4.0.36 → 4.0.37

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 (42) hide show
  1. package/dist/ShapesGraphToAstTransformer.js +10 -0
  2. package/dist/ast/Ast.d.ts +1 -0
  3. package/dist/generators/ts/AbstractNamedUnionType.js +6 -2
  4. package/dist/generators/ts/AbstractObjectSetType.d.ts +35 -0
  5. package/dist/generators/ts/AbstractObjectSetType.js +44 -0
  6. package/dist/generators/ts/GraphqlSchema.d.ts +22 -0
  7. package/dist/generators/ts/GraphqlSchema.js +87 -0
  8. package/dist/generators/ts/NamedObjectType.js +6 -2
  9. package/dist/generators/ts/ObjectSetType.d.ts +6 -0
  10. package/dist/generators/ts/ObjectSetType.js +36 -0
  11. package/dist/generators/ts/RdfjsDatasetObjectSetType.d.ts +6 -0
  12. package/dist/generators/ts/{rdfjsDatasetObjectSetClassDeclaration.js → RdfjsDatasetObjectSetType.js} +73 -63
  13. package/dist/generators/ts/Snippets.d.ts +1 -0
  14. package/dist/generators/ts/Snippets.js +7 -0
  15. package/dist/generators/ts/SparqlObjectSetType.d.ts +6 -0
  16. package/dist/generators/ts/{sparqlObjectSetClassDeclaration.js → SparqlObjectSetType.js} +40 -29
  17. package/dist/generators/ts/TsGenerator.d.ts +7 -8
  18. package/dist/generators/ts/TsGenerator.js +108 -77
  19. package/dist/generators/ts/ZodGenerator.d.ts +1 -2
  20. package/dist/generators/ts/ZodGenerator.js +12 -12
  21. package/dist/generators/ts/_NamedObjectType/NamedObjectType_createFunctionDeclaration.js +17 -11
  22. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionDeclaration.js +2 -1
  23. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionDeclarations.js +2 -4
  24. package/dist/generators/ts/_snippets/snippets_FromRdfResourceFunction.js +2 -2
  25. package/dist/generators/ts/_snippets/snippets_FromRdfResourceValuesFunction.js +2 -2
  26. package/dist/generators/ts/_snippets/snippets__FromRdfResourceFunction.js +2 -2
  27. package/dist/generators/ts/_snippets/snippets_monkeyPatchObject.d.ts +3 -0
  28. package/dist/generators/ts/_snippets/snippets_monkeyPatchObject.js +16 -0
  29. package/dist/generators/ts/_snippets/snippets_wrap_FromRdfResourceFunction.js +3 -4
  30. package/dist/input/generated.d.ts +1 -286
  31. package/dist/input/generated.js +26 -1015
  32. package/package.json +2 -2
  33. package/dist/generators/ts/graphqlSchemaVariableStatement.d.ts +0 -10
  34. package/dist/generators/ts/graphqlSchemaVariableStatement.js +0 -84
  35. package/dist/generators/ts/objectSetDeclarations.d.ts +0 -9
  36. package/dist/generators/ts/objectSetDeclarations.js +0 -27
  37. package/dist/generators/ts/objectSetInterfaceDeclaration.d.ts +0 -9
  38. package/dist/generators/ts/objectSetInterfaceDeclaration.js +0 -26
  39. package/dist/generators/ts/objectSetMethodSignatures.d.ts +0 -18
  40. package/dist/generators/ts/objectSetMethodSignatures.js +0 -31
  41. package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.d.ts +0 -9
  42. package/dist/generators/ts/sparqlObjectSetClassDeclaration.d.ts +0 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "dependencies": {
3
- "@shaclmate/shacl-ast": "4.0.36",
3
+ "@shaclmate/shacl-ast": "4.0.37",
4
4
  "@rdfjs/dataset": "~2.0.2",
5
5
  "@rdfjs/prefix-map": "~0.1.2",
6
6
  "@rdfjs/term-map": "~2.0.2",
@@ -68,5 +68,5 @@
68
68
  },
69
69
  "type": "module",
70
70
  "types": "./dist/index.d.ts",
71
- "version": "4.0.36"
71
+ "version": "4.0.37"
72
72
  }
@@ -1,10 +0,0 @@
1
- import { Maybe } from "purify-ts";
2
- import type { NamedObjectType } from "./NamedObjectType.js";
3
- import type { NamedObjectUnionType } from "./NamedObjectUnionType.js";
4
- import type { TsGenerator } from "./TsGenerator.js";
5
- import { type Code } from "./ts-poet-wrapper.js";
6
- export declare function graphqlSchemaVariableStatement(this: TsGenerator, { namedObjectTypes, namedObjectUnionTypes, }: {
7
- namedObjectTypes: readonly NamedObjectType[];
8
- namedObjectUnionTypes: NamedObjectUnionType[];
9
- }): Maybe<Code>;
10
- //# sourceMappingURL=graphqlSchemaVariableStatement.d.ts.map
@@ -1,84 +0,0 @@
1
- import { Maybe } from "purify-ts";
2
- import { code } from "./ts-poet-wrapper.js";
3
- function graphqlQueryObjectType({ namedObjectTypes, namedObjectUnionTypes, }) {
4
- const syntheticNamePrefix = this.configuration.syntheticNamePrefix;
5
- return code `new ${this.reusables.imports.GraphQLObjectType}<null, { objectSet: ${syntheticNamePrefix}ObjectSet }>({ name: "Query", fields: ${[
6
- ...namedObjectTypes,
7
- ...namedObjectUnionTypes,
8
- ].reduce((fields, namedObjectType) => {
9
- fields[namedObjectType.objectSetMethodNames.object] = {
10
- args: {
11
- identifier: {
12
- type: code `new ${this.reusables.imports.GraphQLNonNull}(${this.reusables.imports.GraphQLID})`,
13
- },
14
- },
15
- resolve: code `\
16
- async (_source, args: { identifier: string }, { objectSet }): Promise<${namedObjectType.name}> =>
17
- (await ${this.reusables.imports.EitherAsync}<Error, ${namedObjectType.name}>(async ({ liftEither }) =>
18
- liftEither(await objectSet.${namedObjectType.objectSetMethodNames.object}(await liftEither(${namedObjectType.identifierTypeAlias}.parse(args.identifier))))
19
- )).unsafeCoerce()`,
20
- type: namedObjectType.graphqlType.name,
21
- };
22
- fields[namedObjectType.objectSetMethodNames.objectIdentifiers] = {
23
- args: {
24
- limit: {
25
- type: code `${this.reusables.imports.GraphQLInt}`,
26
- },
27
- offset: {
28
- type: code `${this.reusables.imports.GraphQLInt}`,
29
- },
30
- },
31
- resolve: code `\
32
- async (_source, args: { limit: number | null; offset: number | null; }, { objectSet }): Promise<readonly string[]> =>
33
- (await objectSet.${namedObjectType.objectSetMethodNames.objectIdentifiers}({ limit: args.limit !== null ? args.limit : undefined, offset: args.offset !== null ? args.offset : undefined })).unsafeCoerce().map(${namedObjectType.identifierTypeAlias}.stringify)`,
34
- type: code `new ${this.reusables.imports.GraphQLNonNull}(new ${this.reusables.imports.GraphQLList}(${this.reusables.imports.GraphQLString}))`,
35
- };
36
- fields[namedObjectType.objectSetMethodNames.objects] = {
37
- args: {
38
- identifiers: {
39
- type: code `new ${this.reusables.imports.GraphQLList}(new ${this.reusables.imports.GraphQLNonNull}(${this.reusables.imports.GraphQLID}))`,
40
- },
41
- limit: {
42
- type: code `${this.reusables.imports.GraphQLInt}`,
43
- },
44
- offset: {
45
- type: code `${this.reusables.imports.GraphQLInt}`,
46
- },
47
- },
48
- resolve: code `\
49
- async (_source, args: { identifiers: readonly string[] | null; limit: number | null; offset: number | null; }, { objectSet }): Promise<readonly ${namedObjectType.name}[]> =>
50
- (await ${this.reusables.imports.EitherAsync}<Error, readonly ${namedObjectType.name}[]>(async ({ liftEither }) => {
51
- let filter: ${namedObjectType.filterType} | undefined;
52
- if (args.identifiers) {
53
- const identifiers: ${namedObjectType.identifierTypeAlias}[] = [];
54
- for (const identifierArg of args.identifiers) {
55
- identifiers.push(await liftEither(${namedObjectType.identifierTypeAlias}.parse(identifierArg)));
56
- }
57
- filter = { ${syntheticNamePrefix}identifier: { in: identifiers } };
58
- }
59
- return await liftEither(await objectSet.${namedObjectType.objectSetMethodNames.objects}({ filter, limit: args.limit !== null ? args.limit : undefined, offset: args.offset !== null ? args.offset : undefined }));
60
- })).unsafeCoerce()`,
61
- type: code `new ${this.reusables.imports.GraphQLNonNull}(new ${this.reusables.imports.GraphQLList}(${namedObjectType.graphqlType.name}))`,
62
- };
63
- fields[namedObjectType.objectSetMethodNames.objectCount] = {
64
- resolve: code `\
65
- async (_source, _args, { objectSet }): Promise<number> => (await objectSet.${namedObjectType.objectSetMethodNames.objectCount}()).unsafeCoerce()`,
66
- type: code `new ${this.reusables.imports.GraphQLNonNull}(${this.reusables.imports.GraphQLInt})`,
67
- };
68
- return fields;
69
- }, {})} })`;
70
- }
71
- export function graphqlSchemaVariableStatement({ namedObjectTypes, namedObjectUnionTypes, }) {
72
- if (!this.configuration.features.has("GraphQL")) {
73
- return Maybe.empty();
74
- }
75
- namedObjectTypes = namedObjectTypes.filter((namedObjectType) => !namedObjectType.synthetic);
76
- if (namedObjectTypes.length === 0) {
77
- return Maybe.empty();
78
- }
79
- namedObjectUnionTypes = namedObjectUnionTypes.filter((namedObjectUnionType) => !namedObjectUnionType.synthetic);
80
- return Maybe.of(code `\
81
- export const graphqlSchema = new ${this.reusables.imports.GraphQLSchema}({ query: ${graphqlQueryObjectType.call(this, { namedObjectTypes: namedObjectTypes, namedObjectUnionTypes })} });
82
- `);
83
- }
84
- //# sourceMappingURL=graphqlSchemaVariableStatement.js.map
@@ -1,9 +0,0 @@
1
- import type { NamedObjectType } from "./NamedObjectType.js";
2
- import type { NamedObjectUnionType } from "./NamedObjectUnionType.js";
3
- import type { TsGenerator } from "./TsGenerator.js";
4
- import type { Code } from "./ts-poet-wrapper.js";
5
- export declare function objectSetDeclarations(this: TsGenerator, { namedObjectUnionTypes, ...parameters }: {
6
- namedObjectTypes: readonly NamedObjectType[];
7
- namedObjectUnionTypes: readonly NamedObjectUnionType[];
8
- }): readonly Code[];
9
- //# sourceMappingURL=objectSetDeclarations.d.ts.map
@@ -1,27 +0,0 @@
1
- import { objectSetInterfaceDeclaration } from "./objectSetInterfaceDeclaration.js";
2
- import { rdfjsDatasetObjectSetClassDeclaration } from "./rdfjsDatasetObjectSetClassDeclaration.js";
3
- import { sparqlObjectSetClassDeclaration } from "./sparqlObjectSetClassDeclaration.js";
4
- export function objectSetDeclarations({ namedObjectUnionTypes, ...parameters }) {
5
- const namedObjectTypes = parameters.namedObjectTypes.filter((namedObjectType) => !namedObjectType.extern && !namedObjectType.synthetic);
6
- const declarations = [];
7
- if (this.configuration.features.has("ObjectSet")) {
8
- declarations.push(objectSetInterfaceDeclaration.call(this, {
9
- namedObjectTypes: namedObjectTypes,
10
- namedObjectUnionTypes,
11
- }));
12
- }
13
- if (this.configuration.features.has("RdfjsDatasetObjectSet")) {
14
- declarations.push(rdfjsDatasetObjectSetClassDeclaration.call(this, {
15
- namedObjectTypes: namedObjectTypes,
16
- namedObjectUnionTypes,
17
- }));
18
- }
19
- if (this.configuration.features.has("SparqlObjectSet")) {
20
- declarations.push(sparqlObjectSetClassDeclaration.call(this, {
21
- namedObjectTypes: namedObjectTypes,
22
- namedObjectUnionTypes,
23
- }));
24
- }
25
- return declarations;
26
- }
27
- //# sourceMappingURL=objectSetDeclarations.js.map
@@ -1,9 +0,0 @@
1
- import type { NamedObjectType } from "./NamedObjectType.js";
2
- import type { NamedObjectUnionType } from "./NamedObjectUnionType.js";
3
- import type { TsGenerator } from "./TsGenerator.js";
4
- import { type Code } from "./ts-poet-wrapper.js";
5
- export declare function objectSetInterfaceDeclaration(this: TsGenerator, { namedObjectTypes, namedObjectUnionTypes, }: {
6
- namedObjectTypes: readonly NamedObjectType[];
7
- namedObjectUnionTypes: readonly NamedObjectUnionType[];
8
- }): Code;
9
- //# sourceMappingURL=objectSetInterfaceDeclaration.d.ts.map
@@ -1,26 +0,0 @@
1
- import { objectSetMethodSignatures } from "./objectSetMethodSignatures.js";
2
- import { code, joinCode } from "./ts-poet-wrapper.js";
3
- export function objectSetInterfaceDeclaration({ namedObjectTypes, namedObjectUnionTypes, }) {
4
- const syntheticNamePrefix = this.configuration.syntheticNamePrefix;
5
- return code `\
6
- export interface ${syntheticNamePrefix}ObjectSet {
7
- ${joinCode(namedObjectTypes
8
- .flatMap((namedObjectType) => Object.values(objectSetMethodSignatures.call(this, { namedObjectType })))
9
- .concat(namedObjectUnionTypes.flatMap((namedObjectUnionType) => Object.values(objectSetMethodSignatures.call(this, {
10
- namedObjectType: namedObjectUnionType,
11
- }))))
12
- .map((methodSignature) => code `${methodSignature.name}(${methodSignature.parameters}): ${methodSignature.returnType};`), { on: "\n\n" })}
13
- }
14
-
15
- export namespace ${syntheticNamePrefix}ObjectSet {
16
- export interface Query<ObjectFilterT, ObjectIdentifierT extends ${this.reusables.imports.BlankNode} | ${this.reusables.imports.NamedNode}> {
17
- readonly filter?: ObjectFilterT;
18
- readonly graph?: Exclude<${this.reusables.imports.Quad_Graph}, ${this.reusables.imports.Variable}>;
19
- readonly identifiers?: readonly ObjectIdentifierT[];
20
- readonly limit?: number;
21
- readonly offset?: number;
22
- readonly preferredLanguages?: readonly string[];
23
- }
24
- }`;
25
- }
26
- //# sourceMappingURL=objectSetInterfaceDeclaration.js.map
@@ -1,18 +0,0 @@
1
- import type { NamedObjectType } from "./NamedObjectType.js";
2
- import type { TsGenerator } from "./TsGenerator.js";
3
- import { type Code } from "./ts-poet-wrapper.js";
4
- export declare function objectSetMethodSignatures(this: TsGenerator, parameters: {
5
- namedObjectType: {
6
- readonly filterType: Code;
7
- readonly identifierTypeAlias: Code;
8
- readonly objectSetMethodNames: NamedObjectType.ObjectSetMethodNames;
9
- readonly name: string;
10
- };
11
- parameterNamePrefix?: string;
12
- queryT?: string;
13
- }): Readonly<Record<keyof NamedObjectType.ObjectSetMethodNames, {
14
- readonly name: string;
15
- readonly parameters: Code;
16
- readonly returnType: Code;
17
- }>>;
18
- //# sourceMappingURL=objectSetMethodSignatures.d.ts.map
@@ -1,31 +0,0 @@
1
- import { code } from "./ts-poet-wrapper.js";
2
- export function objectSetMethodSignatures(parameters) {
3
- const { namedObjectType } = parameters;
4
- const parameterNamePrefix = parameters?.parameterNamePrefix ?? "";
5
- const queryT = parameters.queryT ??
6
- `${this.configuration.syntheticNamePrefix}ObjectSet.Query`;
7
- const methodNames = namedObjectType.objectSetMethodNames;
8
- return {
9
- object: {
10
- name: methodNames.object,
11
- parameters: code `${parameterNamePrefix}identifier: ${namedObjectType.identifierTypeAlias}, options?: { preferredLanguages?: readonly string[]; }`,
12
- returnType: code `Promise<${this.reusables.imports.Either}<Error, ${namedObjectType.name}>>`,
13
- },
14
- objectCount: {
15
- name: methodNames.objectCount,
16
- parameters: code `${parameterNamePrefix}query?: Pick<${queryT}<${namedObjectType.filterType}, ${namedObjectType.identifierTypeAlias}>, "filter">`,
17
- returnType: code `Promise<${this.reusables.imports.Either}<Error, number>>`,
18
- },
19
- objectIdentifiers: {
20
- name: methodNames.objectIdentifiers,
21
- parameters: code `${parameterNamePrefix}query?: ${queryT}<${namedObjectType.filterType}, ${namedObjectType.identifierTypeAlias}>`,
22
- returnType: code `Promise<${this.reusables.imports.Either}<Error, readonly ${namedObjectType.identifierTypeAlias}[]>>`,
23
- },
24
- objects: {
25
- name: methodNames.objects,
26
- parameters: code `${parameterNamePrefix}query?: ${queryT}<${namedObjectType.filterType}, ${namedObjectType.identifierTypeAlias}>`,
27
- returnType: code `Promise<${this.reusables.imports.Either}<Error, readonly ${namedObjectType.name}[]>>`,
28
- },
29
- };
30
- }
31
- //# sourceMappingURL=objectSetMethodSignatures.js.map
@@ -1,9 +0,0 @@
1
- import type { NamedObjectType } from "./NamedObjectType.js";
2
- import type { NamedObjectUnionType } from "./NamedObjectUnionType.js";
3
- import type { TsGenerator } from "./TsGenerator.js";
4
- import { type Code } from "./ts-poet-wrapper.js";
5
- export declare function rdfjsDatasetObjectSetClassDeclaration(this: TsGenerator, { namedObjectTypes, namedObjectUnionTypes, }: {
6
- namedObjectTypes: readonly NamedObjectType[];
7
- namedObjectUnionTypes: readonly NamedObjectUnionType[];
8
- }): Code;
9
- //# sourceMappingURL=rdfjsDatasetObjectSetClassDeclaration.d.ts.map
@@ -1,9 +0,0 @@
1
- import type { NamedObjectType } from "./NamedObjectType.js";
2
- import type { NamedObjectUnionType } from "./NamedObjectUnionType.js";
3
- import type { TsGenerator } from "./TsGenerator.js";
4
- import { type Code } from "./ts-poet-wrapper.js";
5
- export declare function sparqlObjectSetClassDeclaration(this: TsGenerator, { namedObjectTypes, namedObjectUnionTypes, }: {
6
- namedObjectTypes: readonly NamedObjectType[];
7
- namedObjectUnionTypes: readonly NamedObjectUnionType[];
8
- }): Code;
9
- //# sourceMappingURL=sparqlObjectSetClassDeclaration.d.ts.map