@canon-protocol/sdk 8.0.0

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 (165) hide show
  1. package/dist/canons/Canon.d.ts +2 -0
  2. package/dist/canons/Canon.js +2 -0
  3. package/dist/canons/DefinedCanon.d.ts +5 -0
  4. package/dist/canons/DefinedCanon.js +4 -0
  5. package/dist/canons/EmbeddedCanon.d.ts +3 -0
  6. package/dist/canons/EmbeddedCanon.js +3 -0
  7. package/dist/canons/ReferenceCanon.d.ts +6 -0
  8. package/dist/canons/ReferenceCanon.js +10 -0
  9. package/dist/canons/SubjectCanon.d.ts +6 -0
  10. package/dist/canons/SubjectCanon.js +6 -0
  11. package/dist/canons/index.d.ts +5 -0
  12. package/dist/canons/index.js +5 -0
  13. package/dist/ctl/CtlCanonUri.d.ts +28 -0
  14. package/dist/ctl/CtlCanonUri.js +230 -0
  15. package/dist/ctl/CtlGraphResolver.d.ts +14 -0
  16. package/dist/ctl/CtlGraphResolver.js +411 -0
  17. package/dist/ctl/CtlMarkdownRenderer.d.ts +17 -0
  18. package/dist/ctl/CtlMarkdownRenderer.js +262 -0
  19. package/dist/ctl/CtlParser.d.ts +10 -0
  20. package/dist/ctl/CtlParser.js +331 -0
  21. package/dist/ctl/CtlValidator.d.ts +12 -0
  22. package/dist/ctl/CtlValidator.js +207 -0
  23. package/dist/ctl/ResourceTypeClassifier.d.ts +21 -0
  24. package/dist/ctl/ResourceTypeClassifier.js +126 -0
  25. package/dist/ctl/index.d.ts +12 -0
  26. package/dist/ctl/index.js +9 -0
  27. package/dist/filtering/GitIgnoreFilter.d.ts +7 -0
  28. package/dist/filtering/GitIgnoreFilter.js +32 -0
  29. package/dist/filtering/IGitIgnoreFilter.d.ts +3 -0
  30. package/dist/filtering/IGitIgnoreFilter.js +1 -0
  31. package/dist/filtering/index.d.ts +2 -0
  32. package/dist/filtering/index.js +1 -0
  33. package/dist/index.d.ts +19 -0
  34. package/dist/index.js +8 -0
  35. package/dist/parsing/CanonObjectParser.d.ts +21 -0
  36. package/dist/parsing/CanonObjectParser.js +242 -0
  37. package/dist/parsing/CanonParser.d.ts +21 -0
  38. package/dist/parsing/CanonParser.js +457 -0
  39. package/dist/parsing/ICanonObjectParser.d.ts +7 -0
  40. package/dist/parsing/ICanonObjectParser.js +1 -0
  41. package/dist/parsing/PropertyMetadata.d.ts +7 -0
  42. package/dist/parsing/PropertyMetadata.js +7 -0
  43. package/dist/parsing/index.d.ts +6 -0
  44. package/dist/parsing/index.js +3 -0
  45. package/dist/repositories/CompositeCanonDocumentRepository.d.ts +28 -0
  46. package/dist/repositories/CompositeCanonDocumentRepository.js +125 -0
  47. package/dist/repositories/FileSystemCanonDocumentRepository.d.ts +28 -0
  48. package/dist/repositories/FileSystemCanonDocumentRepository.js +295 -0
  49. package/dist/repositories/HttpCanonDocumentRepository.d.ts +24 -0
  50. package/dist/repositories/HttpCanonDocumentRepository.js +79 -0
  51. package/dist/repositories/InMemoryCanonDocumentRepository.d.ts +23 -0
  52. package/dist/repositories/InMemoryCanonDocumentRepository.js +149 -0
  53. package/dist/repositories/PublisherConfig.d.ts +12 -0
  54. package/dist/repositories/PublisherConfig.js +62 -0
  55. package/dist/repositories/PublisherIndex.d.ts +20 -0
  56. package/dist/repositories/PublisherIndex.js +127 -0
  57. package/dist/repositories/RepositoryFactory.d.ts +6 -0
  58. package/dist/repositories/RepositoryFactory.js +13 -0
  59. package/dist/repositories/index.d.ts +9 -0
  60. package/dist/repositories/index.js +7 -0
  61. package/dist/resolution/CanonUri.d.ts +10 -0
  62. package/dist/resolution/CanonUri.js +55 -0
  63. package/dist/resolution/CanonUriBuilder.d.ts +12 -0
  64. package/dist/resolution/CanonUriBuilder.js +51 -0
  65. package/dist/resolution/ResourceResolutionResult.d.ts +9 -0
  66. package/dist/resolution/ResourceResolutionResult.js +1 -0
  67. package/dist/resolution/ResourceResolver.d.ts +27 -0
  68. package/dist/resolution/ResourceResolver.js +266 -0
  69. package/dist/resolution/TypeResolver.d.ts +15 -0
  70. package/dist/resolution/TypeResolver.js +110 -0
  71. package/dist/resolution/index.d.ts +6 -0
  72. package/dist/resolution/index.js +4 -0
  73. package/dist/statements/BooleanStatement.d.ts +3 -0
  74. package/dist/statements/BooleanStatement.js +3 -0
  75. package/dist/statements/EmbeddedStatement.d.ts +4 -0
  76. package/dist/statements/EmbeddedStatement.js +3 -0
  77. package/dist/statements/IStatement.d.ts +2 -0
  78. package/dist/statements/IStatement.js +1 -0
  79. package/dist/statements/ListStatement.d.ts +4 -0
  80. package/dist/statements/ListStatement.js +3 -0
  81. package/dist/statements/NumberStatement.d.ts +4 -0
  82. package/dist/statements/NumberStatement.js +10 -0
  83. package/dist/statements/ReferenceStatement.d.ts +5 -0
  84. package/dist/statements/ReferenceStatement.js +10 -0
  85. package/dist/statements/ScalarStatement.d.ts +3 -0
  86. package/dist/statements/ScalarStatement.js +3 -0
  87. package/dist/statements/Statement.d.ts +6 -0
  88. package/dist/statements/Statement.js +4 -0
  89. package/dist/statements/StringStatement.d.ts +4 -0
  90. package/dist/statements/StringStatement.js +10 -0
  91. package/dist/statements/index.d.ts +9 -0
  92. package/dist/statements/index.js +8 -0
  93. package/dist/validation/CanonObjectValidator.d.ts +21 -0
  94. package/dist/validation/CanonObjectValidator.js +150 -0
  95. package/dist/validation/ICanonObjectValidator.d.ts +7 -0
  96. package/dist/validation/ICanonObjectValidator.js +1 -0
  97. package/dist/validation/OntologyValidationError.d.ts +15 -0
  98. package/dist/validation/OntologyValidationError.js +25 -0
  99. package/dist/validation/OntologyValidationResult.d.ts +7 -0
  100. package/dist/validation/OntologyValidationResult.js +8 -0
  101. package/dist/validation/ValidationContext.d.ts +6 -0
  102. package/dist/validation/ValidationContext.js +10 -0
  103. package/dist/validation/ValidationSeverity.d.ts +4 -0
  104. package/dist/validation/ValidationSeverity.js +5 -0
  105. package/dist/validation/index.d.ts +10 -0
  106. package/dist/validation/index.js +7 -0
  107. package/dist/validation/rules/document/EmbeddedCanonNoExplicitTypeRule.d.ts +8 -0
  108. package/dist/validation/rules/document/EmbeddedCanonNoExplicitTypeRule.js +53 -0
  109. package/dist/validation/rules/document/IDocumentValidationRule.d.ts +6 -0
  110. package/dist/validation/rules/document/IDocumentValidationRule.js +1 -0
  111. package/dist/validation/rules/document/NamespacePrefixRule.d.ts +10 -0
  112. package/dist/validation/rules/document/NamespacePrefixRule.js +51 -0
  113. package/dist/validation/rules/document/PropertyTypeSpecificityRule.d.ts +11 -0
  114. package/dist/validation/rules/document/PropertyTypeSpecificityRule.js +89 -0
  115. package/dist/validation/rules/document/ResourceNamingRule.d.ts +12 -0
  116. package/dist/validation/rules/document/ResourceNamingRule.js +79 -0
  117. package/dist/validation/rules/document/SubjectCanonTypeRequiredRule.d.ts +7 -0
  118. package/dist/validation/rules/document/SubjectCanonTypeRequiredRule.js +33 -0
  119. package/dist/validation/rules/document/index.d.ts +6 -0
  120. package/dist/validation/rules/document/index.js +5 -0
  121. package/dist/validation/rules/normalizeToStringList.d.ts +1 -0
  122. package/dist/validation/rules/normalizeToStringList.js +9 -0
  123. package/dist/validation/rules/repository/AmbiguousReferenceRule.d.ts +14 -0
  124. package/dist/validation/rules/repository/AmbiguousReferenceRule.js +155 -0
  125. package/dist/validation/rules/repository/ClassDefinitionRule.d.ts +12 -0
  126. package/dist/validation/rules/repository/ClassDefinitionRule.js +205 -0
  127. package/dist/validation/rules/repository/ClassHierarchyCycleRule.d.ts +11 -0
  128. package/dist/validation/rules/repository/ClassHierarchyCycleRule.js +98 -0
  129. package/dist/validation/rules/repository/DefinitionPropertyReferenceRule.d.ts +13 -0
  130. package/dist/validation/rules/repository/DefinitionPropertyReferenceRule.js +162 -0
  131. package/dist/validation/rules/repository/IRepositoryValidationRule.d.ts +7 -0
  132. package/dist/validation/rules/repository/IRepositoryValidationRule.js +1 -0
  133. package/dist/validation/rules/repository/ImportExistenceRule.d.ts +12 -0
  134. package/dist/validation/rules/repository/ImportExistenceRule.js +124 -0
  135. package/dist/validation/rules/repository/InstancePropertyReferenceRule.d.ts +13 -0
  136. package/dist/validation/rules/repository/InstancePropertyReferenceRule.js +161 -0
  137. package/dist/validation/rules/repository/NamespaceImportCycleRule.d.ts +11 -0
  138. package/dist/validation/rules/repository/NamespaceImportCycleRule.js +85 -0
  139. package/dist/validation/rules/repository/ObjectPropertyImportRule.d.ts +9 -0
  140. package/dist/validation/rules/repository/ObjectPropertyImportRule.js +113 -0
  141. package/dist/validation/rules/repository/ObjectPropertyValueValidationRule.d.ts +12 -0
  142. package/dist/validation/rules/repository/ObjectPropertyValueValidationRule.js +281 -0
  143. package/dist/validation/rules/repository/PropertyDomainRule.d.ts +14 -0
  144. package/dist/validation/rules/repository/PropertyDomainRule.js +221 -0
  145. package/dist/validation/rules/repository/PropertyHierarchyCycleRule.d.ts +11 -0
  146. package/dist/validation/rules/repository/PropertyHierarchyCycleRule.js +104 -0
  147. package/dist/validation/rules/repository/PropertyRangeReferenceRule.d.ts +13 -0
  148. package/dist/validation/rules/repository/PropertyRangeReferenceRule.js +184 -0
  149. package/dist/validation/rules/repository/PropertyRangeRequiredRule.d.ts +8 -0
  150. package/dist/validation/rules/repository/PropertyRangeRequiredRule.js +40 -0
  151. package/dist/validation/rules/repository/PropertyValueTypeRule.d.ts +11 -0
  152. package/dist/validation/rules/repository/PropertyValueTypeRule.js +171 -0
  153. package/dist/validation/rules/repository/SubClassOfReferenceRule.d.ts +11 -0
  154. package/dist/validation/rules/repository/SubClassOfReferenceRule.js +133 -0
  155. package/dist/validation/rules/repository/SubPropertyOfReferenceRule.d.ts +11 -0
  156. package/dist/validation/rules/repository/SubPropertyOfReferenceRule.js +133 -0
  157. package/dist/validation/rules/repository/TypeAmbiguityRule.d.ts +10 -0
  158. package/dist/validation/rules/repository/TypeAmbiguityRule.js +104 -0
  159. package/dist/validation/rules/repository/UnresolvedReferenceRule.d.ts +11 -0
  160. package/dist/validation/rules/repository/UnresolvedReferenceRule.js +91 -0
  161. package/dist/validation/rules/repository/XsdImportRule.d.ts +11 -0
  162. package/dist/validation/rules/repository/XsdImportRule.js +125 -0
  163. package/dist/validation/rules/repository/index.d.ts +20 -0
  164. package/dist/validation/rules/repository/index.js +19 -0
  165. package/package.json +82 -0
@@ -0,0 +1,2 @@
1
+ export declare abstract class Canon {
2
+ }
@@ -0,0 +1,2 @@
1
+ export class Canon {
2
+ }
@@ -0,0 +1,5 @@
1
+ import { Canon } from './Canon.js';
2
+ import type { IStatement } from '../statements/IStatement.js';
3
+ export declare abstract class DefinedCanon extends Canon {
4
+ statement: IStatement[];
5
+ }
@@ -0,0 +1,4 @@
1
+ import { Canon } from './Canon.js';
2
+ export class DefinedCanon extends Canon {
3
+ statement = [];
4
+ }
@@ -0,0 +1,3 @@
1
+ import { DefinedCanon } from './DefinedCanon.js';
2
+ export declare class EmbeddedCanon extends DefinedCanon {
3
+ }
@@ -0,0 +1,3 @@
1
+ import { DefinedCanon } from './DefinedCanon.js';
2
+ export class EmbeddedCanon extends DefinedCanon {
3
+ }
@@ -0,0 +1,6 @@
1
+ import { Canon } from './Canon.js';
2
+ import { CanonUri } from '../resolution/CanonUri.js';
3
+ export declare class ReferenceCanon extends Canon {
4
+ subject: CanonUri;
5
+ static parse(subjectCanonUri: string): ReferenceCanon;
6
+ }
@@ -0,0 +1,10 @@
1
+ import { Canon } from './Canon.js';
2
+ import { CanonUri } from '../resolution/CanonUri.js';
3
+ export class ReferenceCanon extends Canon {
4
+ subject;
5
+ static parse(subjectCanonUri) {
6
+ const canon = new ReferenceCanon();
7
+ canon.subject = CanonUri.parse(subjectCanonUri);
8
+ return canon;
9
+ }
10
+ }
@@ -0,0 +1,6 @@
1
+ import { DefinedCanon } from './DefinedCanon.js';
2
+ export declare class SubjectCanon extends DefinedCanon {
3
+ namespace: string;
4
+ name: string;
5
+ icon?: string;
6
+ }
@@ -0,0 +1,6 @@
1
+ import { DefinedCanon } from './DefinedCanon.js';
2
+ export class SubjectCanon extends DefinedCanon {
3
+ namespace;
4
+ name;
5
+ icon;
6
+ }
@@ -0,0 +1,5 @@
1
+ export { Canon } from './Canon.js';
2
+ export { DefinedCanon } from './DefinedCanon.js';
3
+ export { SubjectCanon } from './SubjectCanon.js';
4
+ export { EmbeddedCanon } from './EmbeddedCanon.js';
5
+ export { ReferenceCanon } from './ReferenceCanon.js';
@@ -0,0 +1,5 @@
1
+ export { Canon } from './Canon.js';
2
+ export { DefinedCanon } from './DefinedCanon.js';
3
+ export { SubjectCanon } from './SubjectCanon.js';
4
+ export { EmbeddedCanon } from './EmbeddedCanon.js';
5
+ export { ReferenceCanon } from './ReferenceCanon.js';
@@ -0,0 +1,28 @@
1
+ import type { CtlCanonUri as ICtlCanonUri, PathSegment } from '@canon-protocol/types/ctl/parsing/types';
2
+ import { CtlCanonUriType } from '@canon-protocol/types/ctl/parsing/enums';
3
+ import type { Version } from '@canon-protocol/types/document/models/types';
4
+ export declare class CtlCanonUri implements ICtlCanonUri {
5
+ readonly scheme: string;
6
+ publisher: string;
7
+ package_?: string | null | undefined;
8
+ version?: Version | null | undefined;
9
+ resourceName?: string | null | undefined;
10
+ path: readonly PathSegment[];
11
+ rawUri: string;
12
+ constructor(init: {
13
+ publisher: string;
14
+ package_?: string | null | undefined;
15
+ version?: Version | null | undefined;
16
+ resourceName?: string | null | undefined;
17
+ path?: PathSegment[];
18
+ rawUri: string;
19
+ });
20
+ get uriType(): CtlCanonUriType;
21
+ get namespace_(): string | null;
22
+ static parse(uriString: string): CtlCanonUri;
23
+ static tryParse(uriString: string): CtlCanonUri | null;
24
+ static isCanonUri(value: string): boolean;
25
+ toString(): string;
26
+ equals(obj: any): boolean;
27
+ getHashCode(): number;
28
+ }
@@ -0,0 +1,230 @@
1
+ import { CtlCanonUriType, PathSegmentType } from '@canon-protocol/types/ctl/parsing/enums';
2
+ const PATH_SEGMENT_REGEX = /\.?([a-zA-Z_][a-zA-Z0-9_-]*|\[\d+\])/g;
3
+ function parseVersion(versionStr) {
4
+ const parts = versionStr.split('.').map(Number);
5
+ const major = parts[0] || 0;
6
+ const minor = parts[1] || 0;
7
+ const patch = parts[2] || 0;
8
+ return {
9
+ major,
10
+ minor,
11
+ patch,
12
+ toString: () => `${major}.${minor}.${patch}`,
13
+ equals: (obj) => obj && typeof obj === 'object' &&
14
+ obj.major === major && obj.minor === minor && obj.patch === patch,
15
+ getHashCode: () => (major << 20) | (minor << 10) | patch,
16
+ compareTo: (other) => {
17
+ if (major !== other.major)
18
+ return major - other.major;
19
+ if (minor !== other.minor)
20
+ return minor - other.minor;
21
+ return patch - other.patch;
22
+ }
23
+ };
24
+ }
25
+ export class CtlCanonUri {
26
+ scheme = 'canon';
27
+ publisher;
28
+ package_;
29
+ version;
30
+ resourceName;
31
+ path;
32
+ rawUri;
33
+ constructor(init) {
34
+ this.publisher = init.publisher;
35
+ this.package_ = init.package_;
36
+ this.version = init.version;
37
+ this.resourceName = init.resourceName;
38
+ this.path = init.path ?? [];
39
+ this.rawUri = init.rawUri;
40
+ }
41
+ get uriType() {
42
+ if (this.path.length > 0)
43
+ return CtlCanonUriType.DeepLink;
44
+ if (this.resourceName != null)
45
+ return CtlCanonUriType.Resource;
46
+ if (this.version != null)
47
+ return CtlCanonUriType.VersionedPackage;
48
+ if (this.package_ != null)
49
+ return CtlCanonUriType.Package;
50
+ return CtlCanonUriType.Publisher;
51
+ }
52
+ get namespace_() {
53
+ if (this.package_ == null)
54
+ return null;
55
+ if (this.version == null)
56
+ return `${this.publisher}/${this.package_}`;
57
+ return `${this.publisher}/${this.package_}@${this.version}`;
58
+ }
59
+ static parse(uriString) {
60
+ if (!uriString || uriString.trim().length === 0) {
61
+ throw new Error('Canon URI string cannot be null or empty');
62
+ }
63
+ if (!uriString.toLowerCase().startsWith('canon://')) {
64
+ throw new Error(`Invalid Canon URI: '${uriString}'. Must start with 'canon://'`);
65
+ }
66
+ const remainder = uriString.substring(8); // Remove "canon://"
67
+ if (!remainder || remainder.trim().length === 0) {
68
+ throw new Error(`Invalid Canon URI: '${uriString}'. Publisher is required after 'canon://'`);
69
+ }
70
+ const fragmentIndex = remainder.indexOf('#');
71
+ let fragment = null;
72
+ let resourcePart;
73
+ if (fragmentIndex >= 0) {
74
+ resourcePart = remainder.substring(0, fragmentIndex);
75
+ fragment = remainder.substring(fragmentIndex + 1);
76
+ if (!fragment || fragment.trim().length === 0) {
77
+ throw new Error(`Invalid Canon URI: '${uriString}'. Deep link path required after '#'`);
78
+ }
79
+ }
80
+ else {
81
+ resourcePart = remainder;
82
+ }
83
+ let publisher;
84
+ let package_ = null;
85
+ let version = null;
86
+ let resourceName = null;
87
+ const atIndex = resourcePart.indexOf('@');
88
+ if (atIndex >= 0) {
89
+ const beforeAt = resourcePart.substring(0, atIndex);
90
+ const afterAt = resourcePart.substring(atIndex + 1);
91
+ const slashIndex = beforeAt.indexOf('/');
92
+ if (slashIndex < 0) {
93
+ throw new Error(`Invalid Canon URI: '${uriString}'. Expected format: publisher/package@version/resource`);
94
+ }
95
+ publisher = beforeAt.substring(0, slashIndex);
96
+ package_ = beforeAt.substring(slashIndex + 1);
97
+ if (!publisher || publisher.trim().length === 0) {
98
+ throw new Error(`Invalid Canon URI: '${uriString}'. Publisher cannot be empty`);
99
+ }
100
+ if (!package_ || package_.trim().length === 0) {
101
+ throw new Error(`Invalid Canon URI: '${uriString}'. Package cannot be empty`);
102
+ }
103
+ const versionSlashIndex = afterAt.indexOf('/');
104
+ if (versionSlashIndex < 0) {
105
+ throw new Error(`Invalid Canon URI: '${uriString}'. CTL requires resource references (canon://publisher/package@version/resource)`);
106
+ }
107
+ const versionStr = afterAt.substring(0, versionSlashIndex);
108
+ resourceName = afterAt.substring(versionSlashIndex + 1);
109
+ if (!versionStr || versionStr.trim().length === 0) {
110
+ throw new Error(`Invalid Canon URI: '${uriString}'. Version required after '@'`);
111
+ }
112
+ version = parseVersion(versionStr);
113
+ if (!resourceName || resourceName.trim().length === 0) {
114
+ throw new Error(`Invalid Canon URI: '${uriString}'. Resource name cannot be empty`);
115
+ }
116
+ }
117
+ else {
118
+ const segments = resourcePart.split('/');
119
+ if (segments.length < 3) {
120
+ throw new Error(`Invalid Canon URI: '${uriString}'. CTL requires resource references (canon://publisher/package/resource)`);
121
+ }
122
+ if (segments.length > 3) {
123
+ throw new Error(`Invalid Canon URI: '${uriString}'. Too many path segments. Expected: publisher/package/resource`);
124
+ }
125
+ publisher = segments[0];
126
+ package_ = segments[1];
127
+ resourceName = segments[2];
128
+ if (!publisher || publisher.trim().length === 0) {
129
+ throw new Error(`Invalid Canon URI: '${uriString}'. Publisher cannot be empty`);
130
+ }
131
+ if (!package_ || package_.trim().length === 0) {
132
+ throw new Error(`Invalid Canon URI: '${uriString}'. Package cannot be empty`);
133
+ }
134
+ if (!resourceName || resourceName.trim().length === 0) {
135
+ throw new Error(`Invalid Canon URI: '${uriString}'. Resource name cannot be empty`);
136
+ }
137
+ }
138
+ let pathSegments = [];
139
+ if (fragment != null) {
140
+ pathSegments = parsePath(fragment, uriString);
141
+ }
142
+ return new CtlCanonUri({
143
+ publisher,
144
+ package_,
145
+ version,
146
+ resourceName,
147
+ path: pathSegments,
148
+ rawUri: uriString
149
+ });
150
+ }
151
+ static tryParse(uriString) {
152
+ try {
153
+ return CtlCanonUri.parse(uriString);
154
+ }
155
+ catch {
156
+ return null;
157
+ }
158
+ }
159
+ static isCanonUri(value) {
160
+ return !!value && value.trim().length > 0 &&
161
+ value.toLowerCase().startsWith('canon://');
162
+ }
163
+ toString() {
164
+ let result = `canon://${this.publisher}`;
165
+ if (this.package_ != null) {
166
+ result += `/${this.package_}`;
167
+ if (this.version != null) {
168
+ result += `@${this.version}`;
169
+ }
170
+ if (this.resourceName != null) {
171
+ result += `/${this.resourceName}`;
172
+ if (this.path.length > 0) {
173
+ result += '#';
174
+ let first = true;
175
+ for (const segment of this.path) {
176
+ if (segment.type_ === PathSegmentType.Index) {
177
+ result += `[${segment.index}]`;
178
+ }
179
+ else {
180
+ if (!first)
181
+ result += '.';
182
+ result += segment.name;
183
+ }
184
+ first = false;
185
+ }
186
+ }
187
+ }
188
+ }
189
+ return result;
190
+ }
191
+ equals(obj) {
192
+ if (!(obj instanceof CtlCanonUri))
193
+ return false;
194
+ return this.rawUri.toLowerCase() === obj.rawUri.toLowerCase();
195
+ }
196
+ getHashCode() {
197
+ let hash = 0;
198
+ const s = this.rawUri.toLowerCase();
199
+ for (let i = 0; i < s.length; i++) {
200
+ hash = ((hash << 5) - hash) + s.charCodeAt(i);
201
+ hash |= 0;
202
+ }
203
+ return hash;
204
+ }
205
+ }
206
+ function parsePath(pathPortion, originalUri) {
207
+ const segments = [];
208
+ const regex = new RegExp(PATH_SEGMENT_REGEX.source, 'g');
209
+ let totalMatchedLength = 0;
210
+ let match;
211
+ while ((match = regex.exec(pathPortion)) !== null) {
212
+ const segment = match[1];
213
+ if (segment.startsWith('[') && segment.endsWith(']')) {
214
+ const indexStr = segment.substring(1, segment.length - 1);
215
+ const index = parseInt(indexStr, 10);
216
+ if (isNaN(index)) {
217
+ throw new Error(`Invalid Canon URI: '${originalUri}'. Invalid array index: ${segment}`);
218
+ }
219
+ segments.push({ type_: PathSegmentType.Index, index, toString: () => `[${index}]` });
220
+ }
221
+ else {
222
+ segments.push({ type_: PathSegmentType.Property, name: segment, toString: () => segment });
223
+ }
224
+ totalMatchedLength += match[0].length;
225
+ }
226
+ if (totalMatchedLength !== pathPortion.length) {
227
+ throw new Error(`Invalid Canon URI: '${originalUri}'. Invalid path syntax in: ${pathPortion}`);
228
+ }
229
+ return segments;
230
+ }
@@ -0,0 +1,14 @@
1
+ import type { CtlDocument } from '@canon-protocol/types/ctl/models/types';
2
+ import type { ResolvedResourceGraph, CtlGraphResolver as ICtlGraphResolver } from '@canon-protocol/types/ctl/resolution/types';
3
+ import type { ICanonDocumentRepository } from '@canon-protocol/types/document/models';
4
+ export declare class CtlGraphResolver implements ICtlGraphResolver {
5
+ private readonly repository;
6
+ constructor(repository: ICanonDocumentRepository);
7
+ resolveAsync(document: CtlDocument, maxDepth?: number): Promise<ResolvedResourceGraph>;
8
+ private resolveEntityRecursive;
9
+ private createResolvedResource;
10
+ private classifyEntityType;
11
+ private classifyTier;
12
+ private resolveReferenceToUri;
13
+ private createMockSubjectCanon;
14
+ }