@coasys/ad4m 0.12.0-rc1-dev.2 → 0.12.0-rc1-dev.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.
Files changed (153) hide show
  1. package/jest.config.js +10 -3
  2. package/lib/index.cjs +6893 -5884
  3. package/lib/index.js +6889 -5872
  4. package/lib/src/Ad4mClient.d.ts +9 -16
  5. package/lib/src/Ad4mClient.js +46 -25
  6. package/lib/src/Literal.d.ts +1 -2
  7. package/lib/src/Literal.js +38 -35
  8. package/lib/src/SmartLiteral.d.ts +1 -2
  9. package/lib/src/SmartLiteral.js +30 -15
  10. package/lib/src/agent/AgentClient.d.ts +1 -4
  11. package/lib/src/agent/AgentClient.js +79 -99
  12. package/lib/src/ai/AIClient.d.ts +1 -2
  13. package/lib/src/ai/AIClient.js +224 -220
  14. package/lib/src/expression/ExpressionClient.d.ts +1 -1
  15. package/lib/src/expression/ExpressionClient.js +73 -86
  16. package/lib/src/index.d.ts +1 -1
  17. package/lib/src/index.js +1 -1
  18. package/lib/src/language/LanguageClient.d.ts +1 -1
  19. package/lib/src/language/LanguageClient.js +52 -52
  20. package/lib/src/model/Ad4mModel.d.ts +1351 -144
  21. package/lib/src/model/Ad4mModel.js +3760 -228
  22. package/lib/src/model/Ad4mModel.test.js +522 -979
  23. package/lib/src/model/Subject.d.ts +3 -3
  24. package/lib/src/model/Subject.js +25 -25
  25. package/lib/src/model/decorators.d.ts +444 -100
  26. package/lib/src/model/decorators.js +686 -321
  27. package/lib/src/model/util.d.ts +6 -6
  28. package/lib/src/model/util.js +24 -24
  29. package/lib/src/neighbourhood/NeighbourhoodClient.d.ts +1 -5
  30. package/lib/src/neighbourhood/NeighbourhoodClient.js +179 -242
  31. package/lib/src/neighbourhood/NeighbourhoodProxy.d.ts +1 -2
  32. package/lib/src/neighbourhood/NeighbourhoodProxy.js +28 -13
  33. package/lib/src/neighbourhood/NeighbourhoodProxy.test.js +5 -1
  34. package/lib/src/perspectives/PerspectiveClient.d.ts +9 -9
  35. package/lib/src/perspectives/PerspectiveClient.js +240 -316
  36. package/lib/src/perspectives/PerspectiveProxy.d.ts +99 -61
  37. package/lib/src/perspectives/PerspectiveProxy.js +485 -832
  38. package/lib/src/runtime/RuntimeClient.d.ts +1 -5
  39. package/lib/src/runtime/RuntimeClient.js +238 -412
  40. package/lib/src/shacl/SHACLFlow.test.js +105 -164
  41. package/lib/src/shacl/SHACLShape.d.ts +12 -17
  42. package/lib/src/shacl/SHACLShape.js +115 -128
  43. package/lib/src/shacl/SHACLShape.test.js +176 -244
  44. package/lib/src/shims/reflect-metadata.d.ts +0 -0
  45. package/lib/src/shims/type-graphql.d.ts +32 -0
  46. package/lib/src/src/Ad4mClient.d.ts +28 -0
  47. package/lib/src/src/Address.d.ts +1 -0
  48. package/lib/src/src/DID.d.ts +1 -0
  49. package/lib/src/src/Exception.d.ts +7 -0
  50. package/lib/src/src/Literal.d.ts +7 -0
  51. package/lib/src/src/PubSub.d.ts +17 -0
  52. package/lib/src/src/SmartLiteral.d.ts +12 -0
  53. package/lib/src/src/agent/Agent.d.ts +110 -0
  54. package/lib/src/src/agent/AgentClient.d.ts +62 -0
  55. package/lib/src/src/agent/AgentResolver.d.ts +30 -0
  56. package/lib/src/src/agent/AgentStatus.d.ts +8 -0
  57. package/lib/src/src/ai/AIClient.d.ts +32 -0
  58. package/lib/src/src/ai/AIResolver.d.ts +75 -0
  59. package/lib/src/src/ai/Tasks.d.ts +37 -0
  60. package/lib/src/src/buildSchema.d.ts +1 -0
  61. package/lib/src/src/expression/Expression.d.ts +28 -0
  62. package/lib/src/src/expression/ExpressionClient.d.ts +13 -0
  63. package/lib/src/src/expression/ExpressionRef.d.ts +9 -0
  64. package/lib/src/src/expression/ExpressionResolver.d.ts +10 -0
  65. package/lib/src/src/index.d.ts +35 -0
  66. package/lib/src/src/jestSetup.d.ts +1 -0
  67. package/lib/src/src/language/Icon.d.ts +4 -0
  68. package/lib/src/src/language/Language.d.ts +206 -0
  69. package/lib/src/src/language/LanguageClient.d.ts +17 -0
  70. package/lib/src/src/language/LanguageContext.d.ts +37 -0
  71. package/lib/src/src/language/LanguageHandle.d.ts +9 -0
  72. package/lib/src/src/language/LanguageMeta.d.ts +35 -0
  73. package/lib/src/src/language/LanguageRef.d.ts +6 -0
  74. package/lib/src/src/language/LanguageResolver.d.ts +19 -0
  75. package/lib/src/src/links/Links.d.ts +39 -0
  76. package/lib/src/src/links/Links.test.d.ts +1 -0
  77. package/lib/src/src/model/Ad4mModel.d.ts +1438 -0
  78. package/lib/src/src/model/Ad4mModel.test.d.ts +1 -0
  79. package/lib/src/src/model/Subject.d.ts +25 -0
  80. package/lib/src/src/model/decorators.d.ts +545 -0
  81. package/lib/src/src/model/util.d.ts +12 -0
  82. package/lib/src/src/neighbourhood/Neighbourhood.d.ts +10 -0
  83. package/lib/src/src/neighbourhood/NeighbourhoodClient.d.ts +25 -0
  84. package/lib/src/src/neighbourhood/NeighbourhoodProxy.d.ts +19 -0
  85. package/lib/src/src/neighbourhood/NeighbourhoodProxy.test.d.ts +1 -0
  86. package/lib/src/src/neighbourhood/NeighbourhoodResolver.d.ts +24 -0
  87. package/lib/src/src/perspectives/LinkQuery.d.ts +11 -0
  88. package/lib/src/src/perspectives/Perspective.d.ts +38 -0
  89. package/lib/src/src/perspectives/Perspective.test.d.ts +1 -0
  90. package/lib/src/src/perspectives/PerspectiveClient.d.ts +97 -0
  91. package/lib/src/src/perspectives/PerspectiveDiff.d.ts +9 -0
  92. package/lib/src/src/perspectives/PerspectiveHandle.d.ts +18 -0
  93. package/lib/src/src/perspectives/PerspectiveProxy.d.ts +865 -0
  94. package/lib/src/src/perspectives/PerspectiveResolver.d.ts +57 -0
  95. package/lib/src/src/runtime/RuntimeClient.d.ts +56 -0
  96. package/lib/src/src/runtime/RuntimeResolver.d.ts +132 -0
  97. package/lib/src/src/shacl/SHACLFlow.d.ts +171 -0
  98. package/lib/src/src/shacl/SHACLFlow.test.d.ts +1 -0
  99. package/lib/src/src/shacl/SHACLShape.d.ts +117 -0
  100. package/lib/src/src/shacl/SHACLShape.test.d.ts +1 -0
  101. package/lib/src/src/typeDefs.d.ts +1 -0
  102. package/lib/src/src/unwrapApolloResult.d.ts +2 -0
  103. package/lib/src/src/utils.d.ts +25 -0
  104. package/lib/src/utils.d.ts +0 -8
  105. package/lib/src/utils.js +7 -21
  106. package/package.json +15 -14
  107. package/src/Ad4mClient.test.ts +1315 -1564
  108. package/src/Ad4mClient.ts +54 -55
  109. package/src/Literal.test.ts +26 -45
  110. package/src/Literal.ts +66 -82
  111. package/src/SmartLiteral.ts +58 -74
  112. package/src/agent/AgentClient.ts +99 -144
  113. package/src/ai/AIClient.ts +359 -409
  114. package/src/expression/ExpressionClient.ts +96 -142
  115. package/src/index.ts +1 -1
  116. package/src/language/LanguageClient.ts +113 -137
  117. package/src/model/Ad4mModel.test.ts +616 -1114
  118. package/src/model/Ad4mModel.ts +4386 -451
  119. package/src/model/Subject.ts +159 -0
  120. package/src/model/decorators.ts +1168 -667
  121. package/src/model/util.ts +54 -53
  122. package/src/neighbourhood/NeighbourhoodClient.ts +266 -392
  123. package/src/neighbourhood/NeighbourhoodProxy.test.ts +7 -3
  124. package/src/neighbourhood/NeighbourhoodProxy.ts +40 -58
  125. package/src/perspectives/PerspectiveClient.ts +540 -779
  126. package/src/perspectives/PerspectiveProxy.ts +2067 -2860
  127. package/src/runtime/RuntimeClient.ts +476 -775
  128. package/src/shacl/SHACLFlow.test.ts +129 -196
  129. package/src/shacl/SHACLShape.test.ts +190 -284
  130. package/src/shacl/SHACLShape.ts +200 -224
  131. package/src/utils.ts +17 -31
  132. package/tsconfig.json +10 -9
  133. package/src/model/IMPROVEMENTS.md +0 -482
  134. package/src/model/PREDICATE_COLLISION_FIX.md +0 -651
  135. package/src/model/README.md +0 -317
  136. package/src/model/SHACL_MUTATION_DECOUPLING.md +0 -356
  137. package/src/model/SUBSCRIPTION_STRATEGY.md +0 -317
  138. package/src/model/TC39_STAGE_3_DECORATORS.md +0 -609
  139. package/src/model/mutation.ts +0 -461
  140. package/src/model/parentUtils.ts +0 -91
  141. package/src/model/prolog/generatePrologFacts.ts +0 -176
  142. package/src/model/prolog/index.ts +0 -1
  143. package/src/model/query/ModelQueryBuilder.ts +0 -173
  144. package/src/model/query/fetchInstance.ts +0 -181
  145. package/src/model/query/hydration.ts +0 -273
  146. package/src/model/query/operations.ts +0 -510
  147. package/src/model/query/snapshot.ts +0 -126
  148. package/src/model/query/surrealCompiler.ts +0 -376
  149. package/src/model/schema/fromJSONSchema.ts +0 -411
  150. package/src/model/schema/metadata.ts +0 -148
  151. package/src/model/subscription.ts +0 -307
  152. package/src/model/transaction.ts +0 -60
  153. package/src/model/types.ts +0 -207
@@ -1,303 +1,265 @@
1
- import { SHACLShape } from "./SHACLShape";
2
- describe("SHACLShape", () => {
3
- describe("toLinks()", () => {
4
- it("creates basic shape links", () => {
5
- const shape = new SHACLShape("recipe://Recipe");
1
+ import { SHACLShape } from './SHACLShape';
2
+ describe('SHACLShape', () => {
3
+ describe('toLinks()', () => {
4
+ it('creates basic shape links', () => {
5
+ const shape = new SHACLShape('recipe://Recipe');
6
6
  const links = shape.toLinks();
7
7
  // Should have targetClass link
8
- const targetClassLink = links.find((l) => l.predicate === "sh://targetClass");
8
+ const targetClassLink = links.find(l => l.predicate === 'sh://targetClass');
9
9
  expect(targetClassLink).toBeDefined();
10
- expect(targetClassLink.source).toBe("recipe://RecipeShape");
11
- expect(targetClassLink.target).toBe("recipe://Recipe");
10
+ expect(targetClassLink.source).toBe('recipe://RecipeShape');
11
+ expect(targetClassLink.target).toBe('recipe://Recipe');
12
12
  });
13
- it("creates property shape links with named URIs", () => {
14
- const shape = new SHACLShape("recipe://Recipe");
13
+ it('creates property shape links with named URIs', () => {
14
+ const shape = new SHACLShape('recipe://Recipe');
15
15
  const prop = {
16
- name: "name",
17
- path: "recipe://name",
18
- datatype: "xsd:string",
16
+ name: 'name',
17
+ path: 'recipe://name',
18
+ datatype: 'xsd:string',
19
19
  minCount: 1,
20
20
  maxCount: 1,
21
21
  };
22
22
  shape.addProperty(prop);
23
23
  const links = shape.toLinks();
24
24
  // Property shape should use named URI
25
- const propLink = links.find((l) => l.predicate === "sh://property");
25
+ const propLink = links.find(l => l.predicate === 'sh://property');
26
26
  expect(propLink).toBeDefined();
27
- expect(propLink.target).toBe("recipe://Recipe.name"); // Named URI, not blank node
27
+ expect(propLink.target).toBe('recipe://Recipe.name'); // Named URI, not blank node
28
28
  // Path link
29
- const pathLink = links.find((l) => l.source === "recipe://Recipe.name" && l.predicate === "sh://path");
29
+ const pathLink = links.find(l => l.source === 'recipe://Recipe.name' && l.predicate === 'sh://path');
30
30
  expect(pathLink).toBeDefined();
31
- expect(pathLink.target).toBe("recipe://name");
31
+ expect(pathLink.target).toBe('recipe://name');
32
32
  // Datatype link
33
- const datatypeLink = links.find((l) => l.source === "recipe://Recipe.name" &&
34
- l.predicate === "sh://datatype");
33
+ const datatypeLink = links.find(l => l.source === 'recipe://Recipe.name' && l.predicate === 'sh://datatype');
35
34
  expect(datatypeLink).toBeDefined();
36
- expect(datatypeLink.target).toBe("xsd:string");
35
+ expect(datatypeLink.target).toBe('xsd:string');
37
36
  // Cardinality links
38
- const minCountLink = links.find((l) => l.source === "recipe://Recipe.name" &&
39
- l.predicate === "sh://minCount");
37
+ const minCountLink = links.find(l => l.source === 'recipe://Recipe.name' && l.predicate === 'sh://minCount');
40
38
  expect(minCountLink).toBeDefined();
41
- expect(minCountLink.target).toContain("1");
42
- const maxCountLink = links.find((l) => l.source === "recipe://Recipe.name" &&
43
- l.predicate === "sh://maxCount");
39
+ expect(minCountLink.target).toContain('1');
40
+ const maxCountLink = links.find(l => l.source === 'recipe://Recipe.name' && l.predicate === 'sh://maxCount');
44
41
  expect(maxCountLink).toBeDefined();
45
- expect(maxCountLink.target).toContain("1");
42
+ expect(maxCountLink.target).toContain('1');
46
43
  });
47
- it("creates action links", () => {
48
- const shape = new SHACLShape("recipe://Recipe");
44
+ it('creates action links', () => {
45
+ const shape = new SHACLShape('recipe://Recipe');
49
46
  const setterAction = {
50
- action: "addLink",
51
- source: "this",
52
- predicate: "recipe://name",
53
- target: "value",
47
+ action: 'addLink',
48
+ source: 'this',
49
+ predicate: 'recipe://name',
50
+ target: 'value',
54
51
  };
55
52
  const prop = {
56
- name: "title",
57
- path: "recipe://title",
53
+ name: 'title',
54
+ path: 'recipe://title',
58
55
  setter: [setterAction],
59
56
  };
60
57
  shape.addProperty(prop);
61
58
  const links = shape.toLinks();
62
59
  // Setter action link
63
- const setterLink = links.find((l) => l.source === "recipe://Recipe.title" &&
64
- l.predicate === "ad4m://setter");
60
+ const setterLink = links.find(l => l.source === 'recipe://Recipe.title' && l.predicate === 'ad4m://setter');
65
61
  expect(setterLink).toBeDefined();
66
- expect(setterLink.target).toContain("addLink");
62
+ expect(setterLink.target).toContain('addLink');
67
63
  });
68
- it("includes constructor and destructor actions", () => {
69
- const shape = new SHACLShape("recipe://Recipe");
70
- shape.constructor_actions = [
71
- {
72
- action: "addLink",
73
- source: "this",
74
- predicate: "ad4m://type",
75
- target: "recipe://Recipe",
76
- },
77
- ];
78
- shape.destructor_actions = [
79
- {
80
- action: "removeLink",
81
- source: "this",
82
- predicate: "ad4m://type",
83
- target: "recipe://Recipe",
84
- },
85
- ];
64
+ it('includes constructor and destructor actions', () => {
65
+ const shape = new SHACLShape('recipe://Recipe');
66
+ shape.constructor_actions = [{
67
+ action: 'addLink',
68
+ source: 'this',
69
+ predicate: 'ad4m://type',
70
+ target: 'recipe://Recipe',
71
+ }];
72
+ shape.destructor_actions = [{
73
+ action: 'removeLink',
74
+ source: 'this',
75
+ predicate: 'ad4m://type',
76
+ target: 'recipe://Recipe',
77
+ }];
86
78
  const links = shape.toLinks();
87
- const constructorLink = links.find((l) => l.predicate === "ad4m://constructor");
79
+ const constructorLink = links.find(l => l.predicate === 'ad4m://constructor');
88
80
  expect(constructorLink).toBeDefined();
89
- expect(constructorLink.target).toContain("addLink");
90
- const destructorLink = links.find((l) => l.predicate === "ad4m://destructor");
81
+ expect(constructorLink.target).toContain('addLink');
82
+ const destructorLink = links.find(l => l.predicate === 'ad4m://destructor');
91
83
  expect(destructorLink).toBeDefined();
92
- expect(destructorLink.target).toContain("removeLink");
84
+ expect(destructorLink.target).toContain('removeLink');
93
85
  });
94
86
  });
95
- describe("fromLinks()", () => {
96
- it("reconstructs shape from links", () => {
97
- const originalShape = new SHACLShape("recipe://Recipe");
87
+ describe('fromLinks()', () => {
88
+ it('reconstructs shape from links', () => {
89
+ const originalShape = new SHACLShape('recipe://Recipe');
98
90
  originalShape.addProperty({
99
- name: "name",
100
- path: "recipe://name",
101
- datatype: "xsd:string",
91
+ name: 'name',
92
+ path: 'recipe://name',
93
+ datatype: 'xsd:string',
102
94
  minCount: 1,
103
95
  });
104
96
  const links = originalShape.toLinks();
105
- const reconstructed = SHACLShape.fromLinks(links, "recipe://RecipeShape");
106
- expect(reconstructed.targetClass).toBe("recipe://Recipe");
97
+ const reconstructed = SHACLShape.fromLinks(links, 'recipe://RecipeShape');
98
+ expect(reconstructed.targetClass).toBe('recipe://Recipe');
107
99
  expect(reconstructed.properties.length).toBe(1);
108
- expect(reconstructed.properties[0].path).toBe("recipe://name");
109
- expect(reconstructed.properties[0].datatype).toBe("xsd:string");
100
+ expect(reconstructed.properties[0].path).toBe('recipe://name');
101
+ expect(reconstructed.properties[0].datatype).toBe('xsd:string');
110
102
  expect(reconstructed.properties[0].minCount).toBe(1);
111
103
  });
112
- it("handles multiple properties", () => {
113
- const originalShape = new SHACLShape("recipe://Recipe");
104
+ it('handles multiple properties', () => {
105
+ const originalShape = new SHACLShape('recipe://Recipe');
114
106
  originalShape.addProperty({
115
- name: "name",
116
- path: "recipe://name",
117
- datatype: "xsd:string",
107
+ name: 'name',
108
+ path: 'recipe://name',
109
+ datatype: 'xsd:string',
118
110
  });
119
111
  originalShape.addProperty({
120
- name: "servings",
121
- path: "recipe://servings",
122
- datatype: "xsd:integer",
112
+ name: 'servings',
113
+ path: 'recipe://servings',
114
+ datatype: 'xsd:integer',
123
115
  });
124
116
  const links = originalShape.toLinks();
125
- const reconstructed = SHACLShape.fromLinks(links, "recipe://RecipeShape");
117
+ const reconstructed = SHACLShape.fromLinks(links, 'recipe://RecipeShape');
126
118
  expect(reconstructed.properties.length).toBe(2);
127
- const nameProp = reconstructed.properties.find((p) => p.path === "recipe://name");
128
- const servingsProp = reconstructed.properties.find((p) => p.path === "recipe://servings");
119
+ const nameProp = reconstructed.properties.find(p => p.path === 'recipe://name');
120
+ const servingsProp = reconstructed.properties.find(p => p.path === 'recipe://servings');
129
121
  expect(nameProp).toBeDefined();
130
122
  expect(servingsProp).toBeDefined();
131
- expect(nameProp.datatype).toBe("xsd:string");
132
- expect(servingsProp.datatype).toBe("xsd:integer");
123
+ expect(nameProp.datatype).toBe('xsd:string');
124
+ expect(servingsProp.datatype).toBe('xsd:integer');
133
125
  });
134
- it("reconstructs action arrays", () => {
135
- const originalShape = new SHACLShape("recipe://Recipe");
126
+ it('reconstructs action arrays', () => {
127
+ const originalShape = new SHACLShape('recipe://Recipe');
136
128
  const setterAction = {
137
- action: "addLink",
138
- source: "this",
139
- predicate: "recipe://name",
140
- target: "value",
129
+ action: 'addLink',
130
+ source: 'this',
131
+ predicate: 'recipe://name',
132
+ target: 'value',
141
133
  };
142
134
  originalShape.addProperty({
143
- name: "name",
144
- path: "recipe://name",
135
+ name: 'name',
136
+ path: 'recipe://name',
145
137
  setter: [setterAction],
146
138
  });
147
139
  const links = originalShape.toLinks();
148
- const reconstructed = SHACLShape.fromLinks(links, "recipe://RecipeShape");
140
+ const reconstructed = SHACLShape.fromLinks(links, 'recipe://RecipeShape');
149
141
  expect(reconstructed.properties[0].setter).toBeDefined();
150
142
  expect(reconstructed.properties[0].setter.length).toBe(1);
151
- expect(reconstructed.properties[0].setter[0].action).toBe("addLink");
143
+ expect(reconstructed.properties[0].setter[0].action).toBe('addLink');
152
144
  });
153
145
  });
154
- describe("round-trip serialization", () => {
155
- it("preserves all property attributes", () => {
156
- const original = new SHACLShape("test://Model");
146
+ describe('round-trip serialization', () => {
147
+ it('preserves all property attributes', () => {
148
+ const original = new SHACLShape('test://Model');
157
149
  original.addProperty({
158
- name: "field",
159
- path: "test://field",
160
- datatype: "xsd:string",
161
- nodeKind: "Literal",
150
+ name: 'field',
151
+ path: 'test://field',
152
+ datatype: 'xsd:string',
153
+ nodeKind: 'Literal',
162
154
  minCount: 0,
163
155
  maxCount: 5,
164
- pattern: "^[a-z]+$",
156
+ pattern: '^[a-z]+$',
165
157
  minInclusive: 10,
166
158
  maxInclusive: 100,
167
- hasValue: "expectedValue",
168
- resolveLanguage: "test://language",
159
+ hasValue: 'expectedValue',
160
+ resolveLanguage: 'test://language',
169
161
  local: true,
170
- setter: [
171
- {
172
- action: "addLink",
173
- source: "this",
174
- predicate: "test://field",
175
- target: "value",
176
- },
177
- ],
178
- adder: [
179
- {
180
- action: "addLink",
181
- source: "this",
182
- predicate: "test://items",
183
- target: "value",
184
- },
185
- ],
186
- remover: [
187
- {
188
- action: "removeLink",
189
- source: "this",
190
- predicate: "test://items",
191
- target: "value",
192
- },
193
- ],
162
+ writable: true,
163
+ setter: [{ action: 'addLink', source: 'this', predicate: 'test://field', target: 'value' }],
164
+ adder: [{ action: 'addLink', source: 'this', predicate: 'test://items', target: 'value' }],
165
+ remover: [{ action: 'removeLink', source: 'this', predicate: 'test://items', target: 'value' }],
194
166
  });
195
167
  const links = original.toLinks();
196
- const reconstructed = SHACLShape.fromLinks(links, "test://ModelShape");
168
+ const reconstructed = SHACLShape.fromLinks(links, 'test://ModelShape');
197
169
  const prop = reconstructed.properties[0];
198
- expect(prop.path).toBe("test://field");
199
- expect(prop.datatype).toBe("xsd:string");
200
- expect(prop.nodeKind).toBe("Literal");
170
+ expect(prop.path).toBe('test://field');
171
+ expect(prop.datatype).toBe('xsd:string');
172
+ expect(prop.nodeKind).toBe('Literal');
201
173
  expect(prop.minCount).toBe(0);
202
174
  expect(prop.maxCount).toBe(5);
203
- expect(prop.pattern).toBe("^[a-z]+$");
175
+ expect(prop.pattern).toBe('^[a-z]+$');
204
176
  expect(prop.minInclusive).toBe(10);
205
177
  expect(prop.maxInclusive).toBe(100);
206
- expect(prop.hasValue).toBe("expectedValue");
207
- expect(prop.resolveLanguage).toBe("test://language");
178
+ expect(prop.hasValue).toBe('expectedValue');
179
+ expect(prop.resolveLanguage).toBe('test://language');
208
180
  expect(prop.local).toBe(true);
209
- expect(prop.readOnly).toBeFalsy();
181
+ expect(prop.writable).toBe(true);
210
182
  expect(prop.setter).toBeDefined();
211
183
  expect(prop.adder).toBeDefined();
212
184
  expect(prop.remover).toBeDefined();
213
185
  });
214
- it("preserves constructor and destructor actions", () => {
215
- const original = new SHACLShape("test://Model");
186
+ it('preserves constructor and destructor actions', () => {
187
+ const original = new SHACLShape('test://Model');
216
188
  original.constructor_actions = [
217
- {
218
- action: "addLink",
219
- source: "this",
220
- predicate: "rdf://type",
221
- target: "test://Model",
222
- },
189
+ { action: 'addLink', source: 'this', predicate: 'rdf://type', target: 'test://Model' }
223
190
  ];
224
191
  original.destructor_actions = [
225
- {
226
- action: "removeLink",
227
- source: "this",
228
- predicate: "rdf://type",
229
- target: "test://Model",
230
- },
192
+ { action: 'removeLink', source: 'this', predicate: 'rdf://type', target: 'test://Model' }
231
193
  ];
232
194
  const links = original.toLinks();
233
- const reconstructed = SHACLShape.fromLinks(links, "test://ModelShape");
195
+ const reconstructed = SHACLShape.fromLinks(links, 'test://ModelShape');
234
196
  expect(reconstructed.constructor_actions).toBeDefined();
235
197
  expect(reconstructed.constructor_actions.length).toBe(1);
236
- expect(reconstructed.constructor_actions[0].action).toBe("addLink");
198
+ expect(reconstructed.constructor_actions[0].action).toBe('addLink');
237
199
  expect(reconstructed.destructor_actions).toBeDefined();
238
200
  expect(reconstructed.destructor_actions.length).toBe(1);
239
- expect(reconstructed.destructor_actions[0].action).toBe("removeLink");
201
+ expect(reconstructed.destructor_actions[0].action).toBe('removeLink');
240
202
  });
241
203
  });
242
- describe("edge cases", () => {
243
- it("handles empty shape", () => {
244
- const shape = new SHACLShape("test://Empty");
204
+ describe('edge cases', () => {
205
+ it('handles empty shape', () => {
206
+ const shape = new SHACLShape('test://Empty');
245
207
  const links = shape.toLinks();
246
208
  expect(links.length).toBeGreaterThanOrEqual(1); // At least targetClass link
247
- const reconstructed = SHACLShape.fromLinks(links, "test://EmptyShape");
248
- expect(reconstructed.targetClass).toBe("test://Empty");
209
+ const reconstructed = SHACLShape.fromLinks(links, 'test://EmptyShape');
210
+ expect(reconstructed.targetClass).toBe('test://Empty');
249
211
  expect(reconstructed.properties.length).toBe(0);
250
212
  });
251
- it("handles URI with hash fragment", () => {
252
- const shape = new SHACLShape("https://example.com/vocab#Recipe");
213
+ it('handles URI with hash fragment', () => {
214
+ const shape = new SHACLShape('https://example.com/vocab#Recipe');
253
215
  const links = shape.toLinks();
254
- const targetClassLink = links.find((l) => l.predicate === "sh://targetClass");
255
- expect(targetClassLink.source).toBe("https://example.com/vocab#RecipeShape");
216
+ const targetClassLink = links.find(l => l.predicate === 'sh://targetClass');
217
+ expect(targetClassLink.source).toBe('https://example.com/vocab#RecipeShape');
256
218
  });
257
- it("falls back to blank nodes when property has no name", () => {
258
- const shape = new SHACLShape("test://Model");
219
+ it('falls back to blank nodes when property has no name', () => {
220
+ const shape = new SHACLShape('test://Model');
259
221
  shape.addProperty({
260
- path: "test://unnamed",
222
+ path: 'test://unnamed',
261
223
  // No name property
262
224
  });
263
225
  const links = shape.toLinks();
264
- const propLink = links.find((l) => l.predicate === "sh://property");
226
+ const propLink = links.find(l => l.predicate === 'sh://property');
265
227
  expect(propLink).toBeDefined();
266
228
  // Should use blank node format when no name provided
267
229
  expect(propLink.target).toMatch(/_:propShape\d+|test:\/\/Model\./);
268
230
  });
269
231
  });
270
- describe("toJSON/fromJSON", () => {
271
- it("serializes and deserializes basic shape", () => {
272
- const original = new SHACLShape("recipe://Recipe");
232
+ describe('toJSON/fromJSON', () => {
233
+ it('serializes and deserializes basic shape', () => {
234
+ const original = new SHACLShape('recipe://Recipe');
273
235
  original.addProperty({
274
- name: "name",
275
- path: "recipe://name",
276
- datatype: "xsd:string",
236
+ name: 'name',
237
+ path: 'recipe://name',
238
+ datatype: 'xsd:string',
277
239
  minCount: 1,
278
240
  });
279
241
  const json = original.toJSON();
280
242
  const reconstructed = SHACLShape.fromJSON(json);
281
- expect(reconstructed.targetClass).toBe("recipe://Recipe");
243
+ expect(reconstructed.targetClass).toBe('recipe://Recipe');
282
244
  expect(reconstructed.properties.length).toBe(1);
283
- expect(reconstructed.properties[0].name).toBe("name");
284
- expect(reconstructed.properties[0].path).toBe("recipe://name");
285
- expect(reconstructed.properties[0].datatype).toBe("xsd:string");
245
+ expect(reconstructed.properties[0].name).toBe('name');
246
+ expect(reconstructed.properties[0].path).toBe('recipe://name');
247
+ expect(reconstructed.properties[0].datatype).toBe('xsd:string');
286
248
  expect(reconstructed.properties[0].minCount).toBe(1);
287
249
  });
288
- it("preserves nodeShapeUri in round-trip", () => {
289
- const original = new SHACLShape("custom://CustomShape", "recipe://Recipe");
250
+ it('preserves nodeShapeUri in round-trip', () => {
251
+ const original = new SHACLShape('custom://CustomShape', 'recipe://Recipe');
290
252
  const json = original.toJSON();
291
253
  const reconstructed = SHACLShape.fromJSON(json);
292
- expect(reconstructed.nodeShapeUri).toBe("custom://CustomShape");
293
- expect(reconstructed.targetClass).toBe("recipe://Recipe");
254
+ expect(reconstructed.nodeShapeUri).toBe('custom://CustomShape');
255
+ expect(reconstructed.targetClass).toBe('recipe://Recipe');
294
256
  });
295
- it("preserves minInclusive and maxInclusive", () => {
296
- const original = new SHACLShape("test://Model");
257
+ it('preserves minInclusive and maxInclusive', () => {
258
+ const original = new SHACLShape('test://Model');
297
259
  original.addProperty({
298
- name: "rating",
299
- path: "test://rating",
300
- datatype: "xsd:integer",
260
+ name: 'rating',
261
+ path: 'test://rating',
262
+ datatype: 'xsd:integer',
301
263
  minInclusive: 1,
302
264
  maxInclusive: 5,
303
265
  });
@@ -306,96 +268,66 @@ describe("SHACLShape", () => {
306
268
  expect(reconstructed.properties[0].minInclusive).toBe(1);
307
269
  expect(reconstructed.properties[0].maxInclusive).toBe(5);
308
270
  });
309
- it("preserves resolveLanguage", () => {
310
- const original = new SHACLShape("test://Model");
271
+ it('preserves resolveLanguage', () => {
272
+ const original = new SHACLShape('test://Model');
311
273
  original.addProperty({
312
- name: "content",
313
- path: "test://content",
314
- resolveLanguage: "literal",
274
+ name: 'content',
275
+ path: 'test://content',
276
+ resolveLanguage: 'literal',
315
277
  });
316
278
  const json = original.toJSON();
317
279
  const reconstructed = SHACLShape.fromJSON(json);
318
- expect(reconstructed.properties[0].resolveLanguage).toBe("literal");
280
+ expect(reconstructed.properties[0].resolveLanguage).toBe('literal');
319
281
  });
320
- it("preserves constructor and destructor actions", () => {
321
- const original = new SHACLShape("test://Model");
282
+ it('preserves constructor and destructor actions', () => {
283
+ const original = new SHACLShape('test://Model');
322
284
  original.constructor_actions = [
323
- {
324
- action: "addLink",
325
- source: "this",
326
- predicate: "rdf://type",
327
- target: "test://Model",
328
- },
285
+ { action: 'addLink', source: 'this', predicate: 'rdf://type', target: 'test://Model' }
329
286
  ];
330
287
  original.destructor_actions = [
331
- {
332
- action: "removeLink",
333
- source: "this",
334
- predicate: "rdf://type",
335
- target: "test://Model",
336
- },
288
+ { action: 'removeLink', source: 'this', predicate: 'rdf://type', target: 'test://Model' }
337
289
  ];
338
290
  const json = original.toJSON();
339
291
  const reconstructed = SHACLShape.fromJSON(json);
340
292
  expect(reconstructed.constructor_actions).toEqual(original.constructor_actions);
341
293
  expect(reconstructed.destructor_actions).toEqual(original.destructor_actions);
342
294
  });
343
- it("preserves all property attributes", () => {
344
- const original = new SHACLShape("test://Model");
295
+ it('preserves all property attributes', () => {
296
+ const original = new SHACLShape('test://Model');
345
297
  original.addProperty({
346
- name: "field",
347
- path: "test://field",
348
- datatype: "xsd:string",
349
- nodeKind: "Literal",
298
+ name: 'field',
299
+ path: 'test://field',
300
+ datatype: 'xsd:string',
301
+ nodeKind: 'Literal',
350
302
  minCount: 0,
351
303
  maxCount: 5,
352
304
  minInclusive: 0,
353
305
  maxInclusive: 100,
354
- pattern: "^[a-z]+$",
355
- hasValue: "default",
306
+ pattern: '^[a-z]+$',
307
+ hasValue: 'default',
356
308
  local: true,
357
- resolveLanguage: "literal",
358
- setter: [
359
- {
360
- action: "addLink",
361
- source: "this",
362
- predicate: "test://field",
363
- target: "value",
364
- },
365
- ],
366
- adder: [
367
- {
368
- action: "addLink",
369
- source: "this",
370
- predicate: "test://items",
371
- target: "value",
372
- },
373
- ],
374
- remover: [
375
- {
376
- action: "removeLink",
377
- source: "this",
378
- predicate: "test://items",
379
- target: "value",
380
- },
381
- ],
309
+ writable: true,
310
+ resolveLanguage: 'literal',
311
+ setter: [{ action: 'addLink', source: 'this', predicate: 'test://field', target: 'value' }],
312
+ adder: [{ action: 'addLink', source: 'this', predicate: 'test://items', target: 'value' }],
313
+ remover: [{ action: 'removeLink', source: 'this', predicate: 'test://items', target: 'value' }],
382
314
  });
383
315
  const json = original.toJSON();
384
316
  const reconstructed = SHACLShape.fromJSON(json);
385
317
  const prop = reconstructed.properties[0];
386
- expect(prop.name).toBe("field");
387
- expect(prop.path).toBe("test://field");
388
- expect(prop.datatype).toBe("xsd:string");
389
- expect(prop.nodeKind).toBe("Literal");
318
+ expect(prop.name).toBe('field');
319
+ expect(prop.path).toBe('test://field');
320
+ expect(prop.datatype).toBe('xsd:string');
321
+ expect(prop.nodeKind).toBe('Literal');
390
322
  expect(prop.minCount).toBe(0);
391
323
  expect(prop.maxCount).toBe(5);
392
324
  expect(prop.minInclusive).toBe(0);
393
325
  expect(prop.maxInclusive).toBe(100);
394
- expect(prop.pattern).toBe("^[a-z]+$");
395
- expect(prop.hasValue).toBe("default");
326
+ expect(prop.pattern).toBe('^[a-z]+$');
327
+ expect(prop.hasValue).toBe('default');
396
328
  expect(prop.local).toBe(true);
397
- expect(prop.readOnly).toBeFalsy();
398
- expect(prop.resolveLanguage).toBe("literal");
329
+ expect(prop.writable).toBe(true);
330
+ expect(prop.resolveLanguage).toBe('literal');
399
331
  expect(prop.setter).toEqual(original.properties[0].setter);
400
332
  expect(prop.adder).toEqual(original.properties[0].adder);
401
333
  expect(prop.remover).toEqual(original.properties[0].remover);
File without changes
@@ -0,0 +1,32 @@
1
+ import * as src from "../node_modules/type-graphql/dist/index.js";
2
+ export declare const dummyValue = "";
3
+ export declare function dummyFn(): void;
4
+ export declare function dummyDecorator(): typeof dummyFn;
5
+ export declare const Arg: typeof src.Arg;
6
+ export declare const Args: typeof src.Args;
7
+ export declare const ArgsType: typeof src.ArgsType;
8
+ export declare const Authorized: typeof src.Authorized;
9
+ export declare const Ctx: typeof src.Ctx;
10
+ export declare const registerEnumType: typeof src.registerEnumType;
11
+ export declare const Field: typeof src.Field;
12
+ export declare const FieldResolver: typeof src.FieldResolver;
13
+ export declare const Info: typeof src.Info;
14
+ export declare const InputType: typeof src.InputType;
15
+ export declare const InterfaceType: typeof src.InterfaceType;
16
+ export declare const Mutation: typeof src.Mutation;
17
+ export declare const ObjectType: typeof src.ObjectType;
18
+ export declare const PubSub: typeof src.PubSub;
19
+ export declare const Query: typeof src.Query;
20
+ export declare const Resolver: typeof src.Resolver;
21
+ export declare const Root: typeof src.Root;
22
+ export declare const Subscription: typeof src.Subscription;
23
+ export declare const createUnionType: typeof src.createUnionType;
24
+ export declare const UseMiddleware: typeof src.UseMiddleware;
25
+ export declare const PubSubEngine: typeof src.PubSubEngine;
26
+ export declare class ClassType<t> {
27
+ }
28
+ export declare const Int: typeof src.Int;
29
+ export declare const Float: typeof src.Float;
30
+ export declare const ID: typeof src.ID;
31
+ export declare const GraphQLISODateTime: typeof src.GraphQLISODateTime;
32
+ export declare const GraphQLTimestamp: typeof src.GraphQLTimestamp;