@shaclmate/compiler 4.0.99 → 4.0.101

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 (27) hide show
  1. package/dist/generators/ts/AbstractBuiltinType.d.ts +23 -0
  2. package/dist/generators/ts/AbstractBuiltinType.js +18 -0
  3. package/dist/generators/ts/AbstractUserDefinedType.d.ts +71 -0
  4. package/dist/generators/ts/AbstractUserDefinedType.js +285 -0
  5. package/dist/generators/ts/BuiltinCallable.d.ts +14 -0
  6. package/dist/generators/ts/BuiltinCallable.js +16 -0
  7. package/dist/generators/ts/Imports.d.ts +1 -0
  8. package/dist/generators/ts/Imports.js +1 -0
  9. package/dist/generators/ts/SchemaObject.d.ts +98 -0
  10. package/dist/generators/ts/SchemaObject.js +143 -0
  11. package/dist/generators/ts/Snippets.d.ts +0 -1
  12. package/dist/generators/ts/Snippets.js +0 -7
  13. package/dist/generators/ts/_ObjectType/ObjectType_jsonObjectType.d.ts +4 -0
  14. package/dist/generators/ts/_ObjectType/ObjectType_jsonObjectType.js +26 -0
  15. package/dist/generators/ts/_snippets/snippets_LazySchema.d.ts +3 -0
  16. package/dist/generators/ts/_snippets/snippets_LazySchema.js +7 -0
  17. package/dist/generators/ts/_snippets/snippets_convertToIdentifier.js +1 -1
  18. package/dist/generators/ts/_snippets/snippets_convertToIdentifierProperty.js +1 -1
  19. package/dist/generators/ts/_snippets/snippets_convertToIri.js +1 -1
  20. package/dist/generators/ts/_snippets/snippets_convertToIriIdentifierProperty.js +1 -1
  21. package/dist/generators/ts/_snippets/snippets_iriFromJsonString.js +1 -1
  22. package/dist/input/ShapesGraph.js +2 -2
  23. package/dist/input/input.shaclmate.d.ts +642 -616
  24. package/dist/input/input.shaclmate.js +155 -147
  25. package/package.json +22 -22
  26. package/dist/generators/ts/_snippets/snippets_iriFromString.d.ts +0 -3
  27. package/dist/generators/ts/_snippets/snippets_iriFromString.js +0 -76
@@ -0,0 +1,23 @@
1
+ import { AbstractType } from "./AbstractType.js";
2
+ import type { SchemaObject } from "./SchemaObject.js";
3
+ /**
4
+ * Abstract base class for built-in types (container types, term types, et al.) -- anything that is not user-defined.
5
+ */
6
+ export declare abstract class AbstractBuiltinType extends AbstractType {
7
+ get schema(): SchemaObject<SchemaObject.AbstractType | SchemaObject.BuiltinType>;
8
+ }
9
+ export declare namespace AbstractBuiltinType {
10
+ type ConversionFunction = AbstractType.ConversionFunction;
11
+ namespace ConversionFunction {
12
+ const SourceType: typeof import("./_AbstractType/AbstractType_ConversionFunction.js").AbstractType_ConversionFunction.SourceType;
13
+ type SourceType = AbstractType.ConversionFunction.SourceType;
14
+ }
15
+ type DiscriminatedType = AbstractType.DiscriminatedType;
16
+ const GraphqlType: typeof import("./_AbstractType/AbstractType_GraphqlType.js").AbstractType_GraphqlType;
17
+ type GraphqlType = AbstractType.GraphqlType;
18
+ type JsType = AbstractType.JsType;
19
+ const JsType: typeof import("./_AbstractType/AbstractType_JsType.js").AbstractType_JsType;
20
+ type JsonType = AbstractType.JsonType;
21
+ type JsonTypeFactory = AbstractType.JsonTypeFactory;
22
+ }
23
+ //# sourceMappingURL=AbstractBuiltinType.d.ts.map
@@ -0,0 +1,18 @@
1
+ import { AbstractType } from "./AbstractType.js";
2
+ /**
3
+ * Abstract base class for built-in types (container types, term types, et al.) -- anything that is not user-defined.
4
+ */
5
+ export class AbstractBuiltinType extends AbstractType {
6
+ get schema() {
7
+ return super.schema;
8
+ }
9
+ }
10
+ (function (AbstractBuiltinType) {
11
+ let ConversionFunction;
12
+ (function (ConversionFunction) {
13
+ ConversionFunction.SourceType = AbstractType.ConversionFunction.SourceType;
14
+ })(ConversionFunction = AbstractBuiltinType.ConversionFunction || (AbstractBuiltinType.ConversionFunction = {}));
15
+ AbstractBuiltinType.GraphqlType = AbstractType.GraphqlType;
16
+ AbstractBuiltinType.JsType = AbstractType.JsType;
17
+ })(AbstractBuiltinType || (AbstractBuiltinType = {}));
18
+ //# sourceMappingURL=AbstractBuiltinType.js.map
@@ -0,0 +1,71 @@
1
+ import { AbstractType } from "./AbstractType.js";
2
+ import type { Callable } from "./Callable.js";
3
+ import type { CodeThunk } from "./CodeThunk.js";
4
+ import { SchemaObject } from "./SchemaObject.js";
5
+ import { type Code } from "./ts-poet-wrapper.js";
6
+ /**
7
+ * Abstract base class for user-defined types (compound types, object types).
8
+ */
9
+ export declare abstract class AbstractUserDefinedType extends AbstractType {
10
+ get equalsFunction(): Callable;
11
+ get filterFunction(): Callable;
12
+ get schema(): SchemaObject<SchemaObject.UserDefinedType>;
13
+ get filterType(): Code;
14
+ get fromJsonValueFunction(): Callable;
15
+ get fromJsonObjectFunction(): Callable;
16
+ get fromRdfResourceValuesFunction(): Callable;
17
+ get hashFunction(): Callable;
18
+ get toJsonValueFunction(): Callable;
19
+ get toJsonObjectFunction(): Callable;
20
+ get toLoggableFunction(): Callable;
21
+ get toRdfResourceValuesFunction(): Callable;
22
+ get toStringFunction(): Callable;
23
+ get valueSparqlConstructTriplesFunction(): Callable;
24
+ get valueSparqlWherePatternsFunction(): Callable;
25
+ protected get toRdfResourceValueTypesExpression(): Code;
26
+ graphqlResolveExpression({ variables, }: {
27
+ variables: {
28
+ value: Code;
29
+ };
30
+ }): Code;
31
+ toLoggableExpression({ variables, }: Parameters<AbstractType["toLoggableExpression"]>[0]): Code;
32
+ toRdfResourceValuesExpression({ variables, }: Parameters<AbstractType["toRdfResourceValuesExpression"]>[0]): Code;
33
+ toStringExpression({ variables, }: Parameters<AbstractType["toStringExpression"]>[0]): Code;
34
+ protected _function({ type, unannotatedExpression, unqualifiedName, }: {
35
+ type: CodeThunk;
36
+ unannotatedExpression: CodeThunk;
37
+ unqualifiedName: string;
38
+ }): Callable;
39
+ protected abstract equalsFunctionExpression(): Code;
40
+ protected equalsFunctionType(): Code;
41
+ protected abstract filterFunctionExpression(): Code;
42
+ protected filterFunctionType(): Code;
43
+ protected abstract filterTypeExpression(): Code;
44
+ protected abstract fromJsonObjectFunctionExpression(): Code;
45
+ protected fromJsonObjectFunctionType(): Code;
46
+ protected abstract fromRdfResourceValuesFunctionExpression(): Code;
47
+ protected fromRdfResourceValuesFunctionType(): Code;
48
+ protected abstract hashFunctionExpression(): Code;
49
+ protected hashFunctionType(): Code;
50
+ protected staticModuleDeclarations(name: string): Record<string, Code>;
51
+ protected abstract toJsonObjectFunctionExpression(): Code;
52
+ protected toJsonObjectFunctionType(): Code;
53
+ protected abstract toLoggableFunctionExpression(): Code;
54
+ protected toLoggableFunctionType(): Code;
55
+ protected abstract toRdfResourceValuesFunctionExpression(): Code;
56
+ protected toRdfResourceValuesFunctionType(): Code;
57
+ protected abstract toStringFunctionExpression(): Code;
58
+ protected toStringFunctionType(): Code;
59
+ protected abstract valueSparqlConstructTriplesFunctionExpression(): Code;
60
+ protected valueSparqlConstructTriplesType(): Code;
61
+ protected abstract valueSparqlWherePatternsFunctionExpression(): Code;
62
+ protected valueSparqlWherePatternsFunctionType(): Code;
63
+ }
64
+ export declare namespace AbstractUserDefinedType {
65
+ type ConversionFunction = AbstractType.ConversionFunction;
66
+ type DiscriminatedType = AbstractType.DiscriminatedType;
67
+ type GraphqlType = AbstractType.GraphqlType;
68
+ type JsonType = AbstractType.JsonType;
69
+ type JsType = AbstractType.JsType;
70
+ }
71
+ //# sourceMappingURL=AbstractUserDefinedType.d.ts.map
@@ -0,0 +1,285 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { invariant } from "ts-invariant";
8
+ import { Memoize } from "typescript-memoize";
9
+ import { AbstractType } from "./AbstractType.js";
10
+ import { DeclaredCallable } from "./DeclaredCallable.js";
11
+ import { InlineCallable } from "./InlineCallable.js";
12
+ import { SchemaObject } from "./SchemaObject.js";
13
+ import { code, joinCode, literalOf } from "./ts-poet-wrapper.js";
14
+ /**
15
+ * Abstract base class for user-defined types (compound types, object types).
16
+ */
17
+ export class AbstractUserDefinedType extends AbstractType {
18
+ get equalsFunction() {
19
+ return this._function({
20
+ type: () => this.equalsFunctionType(),
21
+ unannotatedExpression: () => this.equalsFunctionExpression(),
22
+ unqualifiedName: "equals",
23
+ });
24
+ }
25
+ get filterFunction() {
26
+ return this._function({
27
+ type: () => this.filterFunctionType(),
28
+ unannotatedExpression: () => this.filterFunctionExpression(),
29
+ unqualifiedName: "filter",
30
+ });
31
+ }
32
+ get schema() {
33
+ return new SchemaObject({
34
+ properties: super.schema.properties,
35
+ type: new SchemaObject.UserDefinedType({
36
+ members: { kind: code `kind: ${literalOf(this.kind)}` },
37
+ name: this.name.map((name) => code `${name}.Schema`),
38
+ }),
39
+ variable: this.name.map((name) => code `${name}.schema`),
40
+ });
41
+ }
42
+ get filterType() {
43
+ return this.name
44
+ .map((name) => code `${name}.Filter`)
45
+ .orDefaultLazy(() => this.filterTypeExpression());
46
+ }
47
+ get fromJsonValueFunction() {
48
+ return this.fromJsonObjectFunction;
49
+ }
50
+ get fromJsonObjectFunction() {
51
+ return this._function({
52
+ type: () => this.fromJsonObjectFunctionType(),
53
+ unannotatedExpression: () => this.fromJsonObjectFunctionExpression(),
54
+ unqualifiedName: "fromJson",
55
+ });
56
+ }
57
+ get fromRdfResourceValuesFunction() {
58
+ return this._function({
59
+ type: () => this.fromRdfResourceValuesFunctionType(),
60
+ unannotatedExpression: () => this.fromRdfResourceValuesFunctionExpression(),
61
+ unqualifiedName: "fromRdfResourceValues",
62
+ });
63
+ }
64
+ get hashFunction() {
65
+ return this._function({
66
+ type: () => this.hashFunctionType(),
67
+ unannotatedExpression: () => this.hashFunctionExpression(),
68
+ unqualifiedName: "hash",
69
+ });
70
+ }
71
+ get toJsonValueFunction() {
72
+ return this.toJsonObjectFunction;
73
+ }
74
+ get toJsonObjectFunction() {
75
+ return this._function({
76
+ type: () => this.toJsonObjectFunctionType(),
77
+ unannotatedExpression: () => this.toJsonObjectFunctionExpression(),
78
+ unqualifiedName: "toJson",
79
+ });
80
+ }
81
+ get toLoggableFunction() {
82
+ return this._function({
83
+ type: () => this.toLoggableFunctionType(),
84
+ unannotatedExpression: () => this.toLoggableFunctionExpression(),
85
+ unqualifiedName: "toLoggable",
86
+ });
87
+ }
88
+ get toRdfResourceValuesFunction() {
89
+ return this._function({
90
+ type: () => this.toRdfResourceValuesFunctionType(),
91
+ unannotatedExpression: () => this.toRdfResourceValuesFunctionExpression(),
92
+ unqualifiedName: "toRdfResourceValues",
93
+ });
94
+ }
95
+ get toStringFunction() {
96
+ return this._function({
97
+ type: () => this.toStringFunctionType(),
98
+ unannotatedExpression: () => this.toStringFunctionExpression(),
99
+ unqualifiedName: `${this.configuration.syntheticNamePrefix}toString`,
100
+ });
101
+ }
102
+ get valueSparqlConstructTriplesFunction() {
103
+ return this._function({
104
+ type: () => this.valueSparqlConstructTriplesType(),
105
+ unannotatedExpression: () => this.valueSparqlConstructTriplesFunctionExpression(),
106
+ unqualifiedName: "valueSparqlConstructTriples",
107
+ });
108
+ }
109
+ get valueSparqlWherePatternsFunction() {
110
+ return this._function({
111
+ type: () => this.valueSparqlWherePatternsFunctionType(),
112
+ unannotatedExpression: () => this.valueSparqlWherePatternsFunctionExpression(),
113
+ unqualifiedName: "valueSparqlWherePatterns",
114
+ });
115
+ }
116
+ get toRdfResourceValueTypesExpression() {
117
+ return joinCode([...this.toRdfResourceValueTypes].map((toRdfResourceValueType) => {
118
+ switch (toRdfResourceValueType) {
119
+ case "BlankNode":
120
+ return code `${this.reusables.imports.BlankNode}`;
121
+ case "Literal":
122
+ return code `${this.reusables.imports.Literal}`;
123
+ case "NamedNode":
124
+ return code `${this.reusables.imports.NamedNode}`;
125
+ default:
126
+ toRdfResourceValueType;
127
+ throw new Error();
128
+ }
129
+ }), { on: " | " });
130
+ }
131
+ graphqlResolveExpression({ variables, }) {
132
+ return variables.value;
133
+ }
134
+ toLoggableExpression({ variables, }) {
135
+ return code `${this.toLoggableFunction.unannotatedUsage}(${variables.value})`;
136
+ }
137
+ toRdfResourceValuesExpression({ variables, }) {
138
+ const { value: valueVariable, ...otherVariables } = variables;
139
+ return code `${this.toRdfResourceValuesFunction.unannotatedUsage}(${valueVariable}, ${otherVariables})`;
140
+ }
141
+ toStringExpression({ variables, }) {
142
+ return code `${this.toStringFunction.unannotatedUsage}(${variables.value})`;
143
+ }
144
+ _function({ type, unannotatedExpression, unqualifiedName, }) {
145
+ return this.name
146
+ .map((name) => new DeclaredCallable({
147
+ qualifiedName: [name, unqualifiedName],
148
+ type,
149
+ unannotatedExpression,
150
+ }))
151
+ .orDefault(new InlineCallable(unannotatedExpression, { type }));
152
+ }
153
+ equalsFunctionType() {
154
+ return code `${this.reusables.snippets.EqualsFunction}<${this.expression}>`;
155
+ }
156
+ filterFunctionType() {
157
+ return code `${this.reusables.snippets.FilterFunction}<${this.filterType}, ${this.expression}>`;
158
+ }
159
+ fromJsonObjectFunctionType() {
160
+ return code `${this.reusables.snippets.FromJsonFunction}<${this.jsonObjectType.expression}, ${this.expression}, undefined>`;
161
+ }
162
+ fromRdfResourceValuesFunctionType() {
163
+ return code `${this.reusables.snippets.FromRdfResourceValuesFunction}<${this.expression}, ${this.schema.type.expression}>`;
164
+ }
165
+ hashFunctionType() {
166
+ return code `${this.reusables.snippets.HashFunction}<${this.expression}>`;
167
+ }
168
+ staticModuleDeclarations(name) {
169
+ const staticModuleDeclarations = {
170
+ ...super.staticModuleDeclarations(name),
171
+ };
172
+ function addFunctionDeclaration(function_) {
173
+ invariant(function_ instanceof DeclaredCallable);
174
+ staticModuleDeclarations[function_.unqualifiedName] =
175
+ code `export ${function_.declaration}`;
176
+ }
177
+ if (this.configuration.features.has("Object.equals")) {
178
+ addFunctionDeclaration(this.equalsFunction);
179
+ }
180
+ if (this.configuration.features.has("Object.filter")) {
181
+ staticModuleDeclarations["Filter"] =
182
+ code `export type Filter = ${this.filterTypeExpression()};`;
183
+ addFunctionDeclaration(this.filterFunction);
184
+ }
185
+ if (this.configuration.features.has("Object.hash")) {
186
+ // Hash functions take a generic parameter and const declaration like this can't have type parameters.
187
+ addFunctionDeclaration(this.hashFunction);
188
+ }
189
+ if (this.configuration.features.has("Object.JSON.type")) {
190
+ this.jsonObjectType.declaration.ifJust((jsonTypeDeclaration) => {
191
+ staticModuleDeclarations["JSON"] = jsonTypeDeclaration;
192
+ });
193
+ }
194
+ if (this.configuration.features.has("Object.fromJson")) {
195
+ addFunctionDeclaration(this.fromJsonObjectFunction);
196
+ }
197
+ if (this.configuration.features.has("Object.fromRdf")) {
198
+ addFunctionDeclaration(this.fromRdfResourceValuesFunction);
199
+ }
200
+ if (this.configuration.features.has("Object.schema")) {
201
+ staticModuleDeclarations["schema"] =
202
+ code `export const schema = ${this.schema.literalExpression};`;
203
+ staticModuleDeclarations["Schema"] =
204
+ code `export type Schema = typeof schema;`;
205
+ }
206
+ if (this.configuration.features.has("Object.SPARQL")) {
207
+ addFunctionDeclaration(this.valueSparqlConstructTriplesFunction);
208
+ addFunctionDeclaration(this.valueSparqlWherePatternsFunction);
209
+ }
210
+ if (this.configuration.features.has("Object.toJson")) {
211
+ addFunctionDeclaration(this.toJsonObjectFunction);
212
+ }
213
+ if (this.configuration.features.has("Object.toLoggable")) {
214
+ addFunctionDeclaration(this.toLoggableFunction);
215
+ }
216
+ if (this.configuration.features.has("Object.toRdf")) {
217
+ addFunctionDeclaration(this.toRdfResourceValuesFunction);
218
+ }
219
+ if (this.configuration.features.has("Object.toString")) {
220
+ addFunctionDeclaration(this.toStringFunction);
221
+ }
222
+ return staticModuleDeclarations;
223
+ }
224
+ toJsonObjectFunctionType() {
225
+ return code `${this.reusables.snippets.ToJsonFunction}<${this.expression}, ${this.jsonObjectType.expression}>`;
226
+ }
227
+ toLoggableFunctionType() {
228
+ return code `${this.reusables.snippets.ToLoggableFunction}<${this.expression}>`;
229
+ }
230
+ toRdfResourceValuesFunctionType() {
231
+ return code `${this.reusables.snippets.ToRdfResourceValuesFunction}<${this.expression}, ${this.toRdfResourceValueTypesExpression}>`;
232
+ }
233
+ toStringFunctionType() {
234
+ return code `${this.reusables.snippets.ToStringFunction}<${this.expression}>`;
235
+ }
236
+ valueSparqlConstructTriplesType() {
237
+ return code `${this.reusables.snippets.ValueSparqlConstructTriplesFunction}<${this.filterType}, ${this.schema.type.expression}>`;
238
+ }
239
+ valueSparqlWherePatternsFunctionType() {
240
+ return code `${this.reusables.snippets.ValueSparqlWherePatternsFunction}<${this.filterType}, ${this.schema.type.expression}>`;
241
+ }
242
+ }
243
+ __decorate([
244
+ Memoize()
245
+ ], AbstractUserDefinedType.prototype, "equalsFunction", null);
246
+ __decorate([
247
+ Memoize()
248
+ ], AbstractUserDefinedType.prototype, "filterFunction", null);
249
+ __decorate([
250
+ Memoize()
251
+ ], AbstractUserDefinedType.prototype, "schema", null);
252
+ __decorate([
253
+ Memoize()
254
+ ], AbstractUserDefinedType.prototype, "filterType", null);
255
+ __decorate([
256
+ Memoize()
257
+ ], AbstractUserDefinedType.prototype, "fromJsonObjectFunction", null);
258
+ __decorate([
259
+ Memoize()
260
+ ], AbstractUserDefinedType.prototype, "fromRdfResourceValuesFunction", null);
261
+ __decorate([
262
+ Memoize()
263
+ ], AbstractUserDefinedType.prototype, "hashFunction", null);
264
+ __decorate([
265
+ Memoize()
266
+ ], AbstractUserDefinedType.prototype, "toJsonObjectFunction", null);
267
+ __decorate([
268
+ Memoize()
269
+ ], AbstractUserDefinedType.prototype, "toLoggableFunction", null);
270
+ __decorate([
271
+ Memoize()
272
+ ], AbstractUserDefinedType.prototype, "toRdfResourceValuesFunction", null);
273
+ __decorate([
274
+ Memoize()
275
+ ], AbstractUserDefinedType.prototype, "toStringFunction", null);
276
+ __decorate([
277
+ Memoize()
278
+ ], AbstractUserDefinedType.prototype, "valueSparqlConstructTriplesFunction", null);
279
+ __decorate([
280
+ Memoize()
281
+ ], AbstractUserDefinedType.prototype, "valueSparqlWherePatternsFunction", null);
282
+ __decorate([
283
+ Memoize()
284
+ ], AbstractUserDefinedType.prototype, "toRdfResourceValueTypesExpression", null);
285
+ //# sourceMappingURL=AbstractUserDefinedType.js.map
@@ -0,0 +1,14 @@
1
+ import { AbstractCallable } from "./AbstractCallable.js";
2
+ import type { Snippet } from "./Snippet.js";
3
+ import { type Code } from "./ts-poet-wrapper.js";
4
+ /**
5
+ * A callable that's a reference to a built-in snippet, an import, or a global function.
6
+ *
7
+ * Callers assume the referent carries its own type annotations, so there's no distinction between annotated and unannotated usage.
8
+ */
9
+ export declare class BuiltinCallable extends AbstractCallable {
10
+ readonly annotatedUsage: Code;
11
+ readonly unannotatedUsage: Code;
12
+ constructor(reference: Code | Snippet);
13
+ }
14
+ //# sourceMappingURL=BuiltinCallable.d.ts.map
@@ -0,0 +1,16 @@
1
+ import { AbstractCallable } from "./AbstractCallable.js";
2
+ import { code } from "./ts-poet-wrapper.js";
3
+ /**
4
+ * A callable that's a reference to a built-in snippet, an import, or a global function.
5
+ *
6
+ * Callers assume the referent carries its own type annotations, so there's no distinction between annotated and unannotated usage.
7
+ */
8
+ export class BuiltinCallable extends AbstractCallable {
9
+ annotatedUsage;
10
+ unannotatedUsage;
11
+ constructor(reference) {
12
+ super();
13
+ this.annotatedUsage = this.unannotatedUsage = code `${reference}`;
14
+ }
15
+ }
16
+ //# sourceMappingURL=BuiltinCallable.js.map
@@ -6,6 +6,7 @@ export declare class Imports {
6
6
  readonly datasetFactory: import("ts-poet/build/Import.js").Import;
7
7
  readonly Either: import("ts-poet/build/Import.js").Import;
8
8
  readonly EitherAsync: import("ts-poet/build/Import.js").Import;
9
+ readonly expandIri: import("ts-poet/build/Import.js").Import;
9
10
  readonly GraphQLBigInt: import("ts-poet/build/Import.js").Import;
10
11
  readonly GraphQLBoolean: import("ts-poet/build/Import.js").Import;
11
12
  readonly GraphQLDate: import("ts-poet/build/Import.js").Import;
@@ -7,6 +7,7 @@ export class Imports {
7
7
  datasetFactory = imp("datasetFactory@@rdfx/collection");
8
8
  Either = imp("Either@purify-ts");
9
9
  EitherAsync = imp("EitherAsync@purify-ts");
10
+ expandIri = imp("expandIri@@rdfx/curie");
10
11
  GraphQLBigInt = imp("BigInt:GraphQLBigInt@graphql-scalars");
11
12
  GraphQLBoolean = imp("GraphQLBoolean@graphql");
12
13
  GraphQLDate = imp("Date:GraphQLDate@graphql-scalars");
@@ -0,0 +1,98 @@
1
+ import type { Maybe } from "purify-ts";
2
+ import { CodeThunk } from "./CodeThunk.js";
3
+ import type { Snippet } from "./Snippet.js";
4
+ import { type Code } from "./ts-poet-wrapper.js";
5
+ /**
6
+ * Runtime schema/metadata objects for types and properties.
7
+ */
8
+ export declare class SchemaObject<TypeT extends SchemaObject.Type> {
9
+ /**
10
+ * Object literal properties, usually property assignments like name: value
11
+ * without a terminating comma.
12
+ *
13
+ * Note the name is repeated between the key and the value:
14
+ * { name: code`name: value` }
15
+ * Only the value is incorporated into generated code. The keys are used to sort properties.
16
+ *
17
+ * This enables overwriting in the *Type tree while also supporting non-property assignments such as
18
+ * { name: code`get name() { return value; }` }
19
+ * or
20
+ * { shorthand: code `shorthand` }
21
+ */
22
+ readonly properties: Readonly<Record<string, CodeThunk>>;
23
+ /**
24
+ * Type of the schema object.
25
+ */
26
+ readonly type: TypeT;
27
+ /**
28
+ * Variable pointing to the schema object.
29
+ */
30
+ readonly variable: Maybe<Code>;
31
+ constructor({ properties, type, variable, }: {
32
+ properties: Readonly<Record<string, CodeThunk>>;
33
+ type: TypeT;
34
+ variable: Maybe<Code>;
35
+ });
36
+ /**
37
+ * Expression for this schema object, either the variable or a literal expression.
38
+ */
39
+ get expression(): Code;
40
+ /**
41
+ * Literal expression of the schema object e.g., { name1: value1, name2: value2 }
42
+ */
43
+ get literalExpression(): Code;
44
+ toString(): string;
45
+ }
46
+ export declare namespace SchemaObject {
47
+ /**
48
+ * Placeholder for abstract base classes.
49
+ */
50
+ class AbstractType {
51
+ private readonly ownerKind;
52
+ constructor(ownerKind: string);
53
+ get expression(): Code;
54
+ toString(): string;
55
+ }
56
+ /**
57
+ * A built-in schema object type from a snippet or import.
58
+ */
59
+ class BuiltinType {
60
+ readonly expression: Code;
61
+ constructor(expression: Code | Snippet);
62
+ toString(): string;
63
+ }
64
+ /**
65
+ * A user-defined schema object type, typically corresponding to user-defined types.
66
+ */
67
+ class UserDefinedType {
68
+ /**
69
+ * Members of the schema object type, usually property signatures like name: string.
70
+ *
71
+ * Note the name is repeated between the key and the value:
72
+ * { name: code`name: string` }
73
+ * This enables overwriting in the *Type tree. Unlike property assignments (above),
74
+ * we don't really need to support other member types (index signatures, methods, et al.).
75
+ * Rather, the name is repeated here for consistency with property assignments.
76
+ */
77
+ readonly members: Readonly<Record<string, CodeThunk>>;
78
+ /**
79
+ * Name of the type, can be used in type annotations.
80
+ */
81
+ readonly name: Maybe<Code>;
82
+ constructor({ members, name, }: {
83
+ members: Readonly<Record<string, CodeThunk>>;
84
+ name: Maybe<Code>;
85
+ });
86
+ /**
87
+ * Expression of the schema object type, either the name or a literal expression.
88
+ */
89
+ get expression(): Code;
90
+ /**
91
+ * Literal expression of the schema object type e.g., { name1: string, name2: string }.
92
+ */
93
+ get literalExpression(): Code;
94
+ toString(): string;
95
+ }
96
+ type Type = AbstractType | BuiltinType | UserDefinedType;
97
+ }
98
+ //# sourceMappingURL=SchemaObject.d.ts.map