@shaclmate/compiler 3.0.3 → 3.0.4

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.
@@ -1,6 +1,6 @@
1
- import type { TsFeature } from "enums/TsFeature.js";
2
1
  import { Either } from "purify-ts";
3
2
  import type * as ast from "../ast/index.js";
3
+ import type { TsFeature } from "../enums/TsFeature.js";
4
4
  import type * as input from "../input/index.js";
5
5
  export declare function flattenAstObjectCompositeTypeMemberTypes({ objectCompositeTypeKind, memberTypes, shape, }: {
6
6
  objectCompositeTypeKind: "ObjectIntersectionType" | "ObjectUnionType";
@@ -1,5 +1,5 @@
1
- import type { TsFeature } from "enums/TsFeature.js";
2
1
  import type { Maybe } from "purify-ts";
2
+ import type { TsFeature } from "../enums/TsFeature.js";
3
3
  import type { CompositeType } from "./CompositeType.js";
4
4
  import type { Name } from "./Name.js";
5
5
  import type { ObjectType } from "./ObjectType.js";
@@ -6,64 +6,60 @@ export var Import;
6
6
  (function (Import) {
7
7
  Import.DATA_FACTORY = {
8
8
  kind: StructureKind.ImportDeclaration,
9
- moduleSpecifier: "@shaclmate/runtime",
10
- namedImports: ["dataFactory"],
11
- };
12
- Import.DATASET_FACTORY = {
13
- kind: StructureKind.ImportDeclaration,
14
- moduleSpecifier: "@shaclmate/runtime",
15
- namedImports: ["datasetFactory"],
9
+ moduleSpecifier: "n3",
10
+ namedImports: [{ alias: "dataFactory", name: "DataFactory" }],
16
11
  };
12
+ Import.DATASET_FACTORY = "import { StoreFactory as _DatasetFactory } from 'n3'; const datasetFactory = new _DatasetFactory();";
17
13
  Import.GRAPHQL = {
18
14
  kind: StructureKind.ImportDeclaration,
19
- moduleSpecifier: "@shaclmate/runtime",
20
- namedImports: ["graphql"],
15
+ moduleSpecifier: "graphql",
16
+ namespaceImport: "graphql",
21
17
  };
22
18
  Import.GRAPHQL_SCALARS = {
23
19
  kind: StructureKind.ImportDeclaration,
24
- moduleSpecifier: "@shaclmate/runtime",
25
- namedImports: ["graphqlScalars"],
20
+ moduleSpecifier: "graphql-scalars",
21
+ namespaceImport: "graphqlScalars",
26
22
  };
27
23
  Import.PURIFY = {
28
24
  kind: StructureKind.ImportDeclaration,
29
- moduleSpecifier: "@shaclmate/runtime",
30
- namedImports: ["purify"],
25
+ moduleSpecifier: "purify-ts",
26
+ namespaceImport: "purify",
31
27
  };
32
28
  Import.RDF_LITERAL = {
33
29
  kind: StructureKind.ImportDeclaration,
34
- moduleSpecifier: "@shaclmate/runtime",
35
- namedImports: ["rdfLiteral"],
30
+ moduleSpecifier: "rdf-literal",
31
+ namespaceImport: "rdfLiteral",
36
32
  };
37
33
  Import.RDFJS_RESOURCE = {
38
34
  kind: StructureKind.ImportDeclaration,
39
- moduleSpecifier: "@shaclmate/runtime",
40
- namedImports: ["rdfjsResource"],
35
+ moduleSpecifier: "rdfjs-resource",
36
+ namespaceImport: "rdfjsResource",
41
37
  };
42
38
  Import.RDFJS_TYPES = {
43
39
  isTypeOnly: true,
44
40
  kind: StructureKind.ImportDeclaration,
45
- moduleSpecifier: "@shaclmate/runtime",
46
- namedImports: ["rdfjs"],
41
+ moduleSpecifier: "@rdfjs/types",
42
+ namespaceImport: "rdfjs",
47
43
  };
48
44
  Import.SHA256 = {
49
45
  kind: StructureKind.ImportDeclaration,
50
- moduleSpecifier: "@shaclmate/runtime",
46
+ moduleSpecifier: "js-sha256",
51
47
  namedImports: ["sha256"],
52
48
  };
53
49
  Import.SPARQLJS = {
54
50
  kind: StructureKind.ImportDeclaration,
55
- moduleSpecifier: "@shaclmate/runtime",
56
- namedImports: ["sparqljs"],
51
+ moduleSpecifier: "sparqljs",
52
+ namespaceImport: "sparqljs",
57
53
  };
58
54
  Import.UUID = {
59
55
  kind: StructureKind.ImportDeclaration,
60
- moduleSpecifier: "@shaclmate/runtime",
61
- namedImports: ["uuid"],
56
+ moduleSpecifier: "uuid",
57
+ namespaceImport: "uuid",
62
58
  };
63
59
  Import.ZOD = {
64
60
  kind: StructureKind.ImportDeclaration,
65
- moduleSpecifier: "@shaclmate/runtime",
66
- namedImports: ["zod"],
61
+ moduleSpecifier: "zod",
62
+ namedImports: [{ alias: "zod", name: "z" }],
67
63
  };
68
64
  })(Import || (Import = {}));
69
65
  //# sourceMappingURL=Import.js.map
@@ -1,4 +1,3 @@
1
- import { invariant } from "ts-invariant";
2
1
  import { Project, } from "ts-morph";
3
2
  import * as ast from "../../ast/index.js";
4
3
  import { Import } from "./Import.js";
@@ -40,32 +39,17 @@ export class TsGenerator {
40
39
  }
41
40
  // Deduplicate and add imports
42
41
  const stringImports = new Set();
43
- const structureImports = [];
42
+ const structureImportsByModuleSpecifier = {};
44
43
  for (const import_ of imports) {
45
44
  if (typeof import_ === "string") {
46
45
  stringImports.add(import_);
47
- continue;
48
46
  }
49
- const importWithSameModuleSpecifier = structureImports.find((structureImport) => structureImport.moduleSpecifier === import_.moduleSpecifier);
50
- if (!importWithSameModuleSpecifier) {
51
- structureImports.push(import_);
52
- continue;
53
- }
54
- // Merge named imports
55
- invariant(!import_.namespaceImport);
56
- invariant(Array.isArray(import_.namedImports) &&
57
- import_.namedImports.every((value) => typeof value === "string"));
58
- invariant(!importWithSameModuleSpecifier.namespaceImport);
59
- invariant(Array.isArray(importWithSameModuleSpecifier.namedImports) &&
60
- importWithSameModuleSpecifier.namedImports.every((value) => typeof value === "string"));
61
- for (const newNamedImport of import_.namedImports) {
62
- if (!importWithSameModuleSpecifier.namedImports.includes(newNamedImport)) {
63
- importWithSameModuleSpecifier.namedImports.push(newNamedImport);
64
- }
47
+ else {
48
+ structureImportsByModuleSpecifier[import_.moduleSpecifier] = import_;
65
49
  }
66
50
  }
67
51
  sourceFile.addStatements([...stringImports]);
68
- sourceFile.addStatements(structureImports);
52
+ sourceFile.addStatements(Object.values(structureImportsByModuleSpecifier));
69
53
  // Deduplicate and add snippet declarations
70
54
  const addedSnippetDeclarations = new Set();
71
55
  for (const declaredType of declaredTypes) {
@@ -1,7 +1,7 @@
1
1
  import { StructureKind } from "ts-morph";
2
2
  import { objectSetMethodSignatures } from "./objectSetMethodSignatures.js";
3
3
  export function unsupportedObjectSetMethodDeclarations({ objectType, }) {
4
- return Object.entries(objectSetMethodSignatures({ objectType })).map(([methodName, methodSignature]) => ({
4
+ return Object.values(objectSetMethodSignatures({ objectType })).map((methodSignature) => ({
5
5
  ...methodSignature,
6
6
  kind: StructureKind.Method,
7
7
  parameters: methodSignature.parameters
@@ -11,9 +11,9 @@ export function unsupportedObjectSetMethodDeclarations({ objectType, }) {
11
11
  }))
12
12
  : methodSignature.parameters,
13
13
  isAsync: true,
14
- statements: methodName === "objects"
15
- ? [`return [purify.Left(new Error("${methodName}: not supported"))];`]
16
- : [`return purify.Left(new Error("${methodName}: not supported"));`],
14
+ statements: [
15
+ `return purify.Left(new Error("${methodSignature.name}: not supported")) satisfies Awaited<${methodSignature.returnType}>;`,
16
+ ],
17
17
  }));
18
18
  }
19
19
  //# sourceMappingURL=unsupportedObjectSetMethodDeclarations.js.map
@@ -1,4 +1,6 @@
1
- import { purify, type rdfjs, rdfjsResource } from "@shaclmate/runtime";
1
+ import type * as rdfjs from "@rdfjs/types";
2
+ import * as purify from "purify-ts";
3
+ import * as rdfjsResource from "rdfjs-resource";
2
4
  import { PropertyPath } from "./PropertyPath.js";
3
5
  export declare namespace $RdfVocabularies {
4
6
  namespace rdf {
@@ -1,4 +1,8 @@
1
- import { dataFactory, datasetFactory, purify, rdfjsResource, } from "@shaclmate/runtime";
1
+ import { StoreFactory as _DatasetFactory } from "n3";
2
+ const datasetFactory = new _DatasetFactory();
3
+ import { DataFactory as dataFactory } from "n3";
4
+ import * as purify from "purify-ts";
5
+ import * as rdfjsResource from "rdfjs-resource";
2
6
  import { PropertyPath } from "./PropertyPath.js";
3
7
  export var $RdfVocabularies;
4
8
  (function ($RdfVocabularies) {
package/package.json CHANGED
@@ -1,21 +1,24 @@
1
1
  {
2
2
  "dependencies": {
3
- "@shaclmate/runtime": "3.0.3",
4
- "@shaclmate/shacl-ast": "3.0.3",
3
+ "@shaclmate/shacl-ast": "3.0.4",
5
4
  "@rdfjs/prefix-map": "^0.1.2",
6
5
  "@rdfjs/term-map": "^2.0.2",
7
6
  "@rdfjs/term-set": "^2.0.3",
8
7
  "@rdfjs/types": "^1.1.0",
9
8
  "@sindresorhus/base62": "^0.1.0",
10
9
  "@tpluscode/rdf-ns-builders": "^4.3.0",
10
+ "@types/n3": "^1.26.0",
11
11
  "@types/rdfjs__prefix-map": "^0.1.5",
12
12
  "@types/rdfjs__term-map": "^2.0.10",
13
13
  "@types/rdfjs__term-set": "^2.0.9",
14
14
  "@types/toposort": "2.0.7",
15
15
  "change-case": "^5.4.4",
16
+ "n3": "^1.26.0",
16
17
  "pino": "^9.1.0",
17
18
  "plur": "^5.1.0",
18
19
  "purify-ts": "^2.1.0",
20
+ "rdf-literal": "^1.3.2",
21
+ "rdfjs-resource": "1.0.24",
19
22
  "reserved-identifiers": "^1.0.0",
20
23
  "toposort": "2.0.2",
21
24
  "ts-invariant": "^0.10.3",
@@ -23,10 +26,18 @@
23
26
  "typescript-memoize": "^1.1.1"
24
27
  },
25
28
  "devDependencies": {
26
- "@shaclmate/kitchen-sink-example": "3.0.3",
27
- "@shaclmate/runtime": "3.0.3",
28
- "@kos-kit/sparql-client": "2.0.115",
29
- "oxigraph": "0.4.11"
29
+ "@shaclmate/kitchen-sink-example": "3.0.4",
30
+ "@kos-kit/sparql-client": "2.0.116",
31
+ "oxigraph": "0.4.11",
32
+ "@biomejs/biome": "1.9.4",
33
+ "@tsconfig/node18": "^18.2.4",
34
+ "@tsconfig/strictest": "^2.0.5",
35
+ "@types/node": "^22",
36
+ "depcheck": "^1.4.7",
37
+ "rimraf": "^6.0.1",
38
+ "typescript": "5.8.2",
39
+ "vitest": "^3.2.4",
40
+ "@vitest/coverage-v8": "^3.2.4"
30
41
  },
31
42
  "files": [
32
43
  "dist/*.d.ts",
@@ -63,6 +74,7 @@
63
74
  "check:write": "biome check --write",
64
75
  "check:write:unsafe": "biome check --write --unsafe",
65
76
  "clean": "rimraf dist",
77
+ "depcheck": "depcheck .",
66
78
  "dev": "tsc -w --preserveWatchOutput",
67
79
  "dev:noEmit": "tsc --noEmit -w --preserveWatchOutput",
68
80
  "link-dependencies": "npm link rdfjs-resource",
@@ -73,5 +85,5 @@
73
85
  },
74
86
  "type": "module",
75
87
  "types": "./dist/index.d.ts",
76
- "version": "3.0.3"
88
+ "version": "3.0.4"
77
89
  }