@eui/mcp 1.0.3
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.
- package/README.md +846 -0
- package/dist/config/index.d.ts +6 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +6 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/loader.d.ts +27 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/loader.js +224 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/config/schema.d.ts +171 -0
- package/dist/config/schema.d.ts.map +1 -0
- package/dist/config/schema.js +100 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +45 -0
- package/dist/index.js.map +1 -0
- package/dist/loader/cache-manager.d.ts +74 -0
- package/dist/loader/cache-manager.d.ts.map +1 -0
- package/dist/loader/cache-manager.js +107 -0
- package/dist/loader/cache-manager.js.map +1 -0
- package/dist/loader/documentation-loader.d.ts +57 -0
- package/dist/loader/documentation-loader.d.ts.map +1 -0
- package/dist/loader/documentation-loader.js +81 -0
- package/dist/loader/documentation-loader.js.map +1 -0
- package/dist/loader/documentation-source.d.ts +37 -0
- package/dist/loader/documentation-source.d.ts.map +1 -0
- package/dist/loader/documentation-source.js +2 -0
- package/dist/loader/documentation-source.js.map +1 -0
- package/dist/loader/errors.d.ts +34 -0
- package/dist/loader/errors.d.ts.map +1 -0
- package/dist/loader/errors.js +65 -0
- package/dist/loader/errors.js.map +1 -0
- package/dist/loader/http-client.d.ts +43 -0
- package/dist/loader/http-client.d.ts.map +1 -0
- package/dist/loader/http-client.js +144 -0
- package/dist/loader/http-client.js.map +1 -0
- package/dist/loader/index.d.ts +6 -0
- package/dist/loader/index.d.ts.map +1 -0
- package/dist/loader/index.js +5 -0
- package/dist/loader/index.js.map +1 -0
- package/dist/loader/local-documentation-source.d.ts +62 -0
- package/dist/loader/local-documentation-source.d.ts.map +1 -0
- package/dist/loader/local-documentation-source.js +190 -0
- package/dist/loader/local-documentation-source.js.map +1 -0
- package/dist/loader/path-type-detector.d.ts +34 -0
- package/dist/loader/path-type-detector.d.ts.map +1 -0
- package/dist/loader/path-type-detector.js +78 -0
- package/dist/loader/path-type-detector.js.map +1 -0
- package/dist/loader/remote-documentation-source.d.ts +112 -0
- package/dist/loader/remote-documentation-source.d.ts.map +1 -0
- package/dist/loader/remote-documentation-source.js +252 -0
- package/dist/loader/remote-documentation-source.js.map +1 -0
- package/dist/main.d.ts +3 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +211 -0
- package/dist/main.js.map +1 -0
- package/dist/mcp/index.d.ts +5 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +5 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/server.d.ts +65 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +224 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/publish/index.d.ts +8 -0
- package/dist/publish/index.d.ts.map +1 -0
- package/dist/publish/index.js +8 -0
- package/dist/publish/index.js.map +1 -0
- package/dist/publish/publish-utils.d.ts +74 -0
- package/dist/publish/publish-utils.d.ts.map +1 -0
- package/dist/publish/publish-utils.js +170 -0
- package/dist/publish/publish-utils.js.map +1 -0
- package/dist/query/component-query.d.ts +33 -0
- package/dist/query/component-query.d.ts.map +1 -0
- package/dist/query/component-query.js +63 -0
- package/dist/query/component-query.js.map +1 -0
- package/dist/query/index-builder.d.ts +79 -0
- package/dist/query/index-builder.d.ts.map +1 -0
- package/dist/query/index-builder.js +217 -0
- package/dist/query/index-builder.js.map +1 -0
- package/dist/query/index.d.ts +5 -0
- package/dist/query/index.d.ts.map +1 -0
- package/dist/query/index.js +6 -0
- package/dist/query/index.js.map +1 -0
- package/dist/query/result-formatter.d.ts +108 -0
- package/dist/query/result-formatter.d.ts.map +1 -0
- package/dist/query/result-formatter.js +165 -0
- package/dist/query/result-formatter.js.map +1 -0
- package/dist/query/search-engine.d.ts +54 -0
- package/dist/query/search-engine.d.ts.map +1 -0
- package/dist/query/search-engine.js +178 -0
- package/dist/query/search-engine.js.map +1 -0
- package/dist/test-error.ts +1 -0
- package/dist/tools/get-component-docs.d.ts +43 -0
- package/dist/tools/get-component-docs.d.ts.map +1 -0
- package/dist/tools/get-component-docs.js +55 -0
- package/dist/tools/get-component-docs.js.map +1 -0
- package/dist/tools/get-component-examples.d.ts +45 -0
- package/dist/tools/get-component-examples.d.ts.map +1 -0
- package/dist/tools/get-component-examples.js +56 -0
- package/dist/tools/get-component-examples.js.map +1 -0
- package/dist/tools/get-component-inputs.d.ts +44 -0
- package/dist/tools/get-component-inputs.d.ts.map +1 -0
- package/dist/tools/get-component-inputs.js +55 -0
- package/dist/tools/get-component-inputs.js.map +1 -0
- package/dist/tools/get-component-outputs.d.ts +44 -0
- package/dist/tools/get-component-outputs.d.ts.map +1 -0
- package/dist/tools/get-component-outputs.js +55 -0
- package/dist/tools/get-component-outputs.js.map +1 -0
- package/dist/tools/index.d.ts +7 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +8 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/list-components.d.ts +69 -0
- package/dist/tools/list-components.d.ts.map +1 -0
- package/dist/tools/list-components.js +84 -0
- package/dist/tools/list-components.js.map +1 -0
- package/dist/tools/search-components.d.ts +69 -0
- package/dist/tools/search-components.d.ts.map +1 -0
- package/dist/tools/search-components.js +98 -0
- package/dist/tools/search-components.js.map +1 -0
- package/dist/types/compodoc.d.ts +261 -0
- package/dist/types/compodoc.d.ts.map +1 -0
- package/dist/types/compodoc.js +5 -0
- package/dist/types/compodoc.js.map +1 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +5 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/circuit-breaker.d.ts +91 -0
- package/dist/utils/circuit-breaker.d.ts.map +1 -0
- package/dist/utils/circuit-breaker.js +186 -0
- package/dist/utils/circuit-breaker.js.map +1 -0
- package/dist/utils/credential-masking.d.ts +90 -0
- package/dist/utils/credential-masking.d.ts.map +1 -0
- package/dist/utils/credential-masking.js +202 -0
- package/dist/utils/credential-masking.js.map +1 -0
- package/dist/utils/error-handler.d.ts +68 -0
- package/dist/utils/error-handler.d.ts.map +1 -0
- package/dist/utils/error-handler.js +184 -0
- package/dist/utils/error-handler.js.map +1 -0
- package/dist/utils/errors.d.ts +156 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +242 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/index.d.ts +10 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +16 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/logger.d.ts +76 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +150 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/retry.d.ts +19 -0
- package/dist/utils/retry.d.ts.map +1 -0
- package/dist/utils/retry.js +81 -0
- package/dist/utils/retry.js.map +1 -0
- package/dist/version/changelog-file-utils.d.ts +69 -0
- package/dist/version/changelog-file-utils.d.ts.map +1 -0
- package/dist/version/changelog-file-utils.js +161 -0
- package/dist/version/changelog-file-utils.js.map +1 -0
- package/dist/version/changelog-utils.d.ts +98 -0
- package/dist/version/changelog-utils.d.ts.map +1 -0
- package/dist/version/changelog-utils.js +198 -0
- package/dist/version/changelog-utils.js.map +1 -0
- package/dist/version/dry-run-utils.d.ts +108 -0
- package/dist/version/dry-run-utils.d.ts.map +1 -0
- package/dist/version/dry-run-utils.js +126 -0
- package/dist/version/dry-run-utils.js.map +1 -0
- package/dist/version/git-tag-utils.d.ts +50 -0
- package/dist/version/git-tag-utils.d.ts.map +1 -0
- package/dist/version/git-tag-utils.js +66 -0
- package/dist/version/git-tag-utils.js.map +1 -0
- package/dist/version/index.d.ts +11 -0
- package/dist/version/index.d.ts.map +1 -0
- package/dist/version/index.js +11 -0
- package/dist/version/index.js.map +1 -0
- package/dist/version/release-utils.d.ts +94 -0
- package/dist/version/release-utils.d.ts.map +1 -0
- package/dist/version/release-utils.js +170 -0
- package/dist/version/release-utils.js.map +1 -0
- package/dist/version/rollback-utils.d.ts +47 -0
- package/dist/version/rollback-utils.d.ts.map +1 -0
- package/dist/version/rollback-utils.js +73 -0
- package/dist/version/rollback-utils.js.map +1 -0
- package/dist/version/version-manager.d.ts +98 -0
- package/dist/version/version-manager.d.ts.map +1 -0
- package/dist/version/version-manager.js +158 -0
- package/dist/version/version-manager.js.map +1 -0
- package/package.json +61 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP client with timeout support and retry logic
|
|
3
|
+
*/
|
|
4
|
+
export class HttpClient {
|
|
5
|
+
options;
|
|
6
|
+
constructor(options) {
|
|
7
|
+
this.options = options;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Fetch content from URL with timeout support and retry logic
|
|
11
|
+
*/
|
|
12
|
+
async fetch(url, headers) {
|
|
13
|
+
let lastError;
|
|
14
|
+
for (let attempt = 0; attempt <= this.options.maxRetries; attempt++) {
|
|
15
|
+
try {
|
|
16
|
+
const response = await this.fetchOnce(url, headers);
|
|
17
|
+
// Check if we should retry based on status code
|
|
18
|
+
// If not retryable or no more retries, return the response
|
|
19
|
+
if (!this.isRetryableError(undefined, response.status) || attempt >= this.options.maxRetries) {
|
|
20
|
+
return response;
|
|
21
|
+
}
|
|
22
|
+
// Retry with backoff
|
|
23
|
+
const delay = this.calculateBackoff(attempt);
|
|
24
|
+
await this.sleep(delay);
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
lastError = error instanceof Error ? error : new Error(String(error));
|
|
28
|
+
// Check if we should retry
|
|
29
|
+
if (attempt < this.options.maxRetries && this.isRetryableError(lastError)) {
|
|
30
|
+
const delay = this.calculateBackoff(attempt);
|
|
31
|
+
await this.sleep(delay);
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
// No more retries, throw the error
|
|
35
|
+
throw lastError;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
// Should not reach here, but throw last error if we do
|
|
39
|
+
throw lastError || new Error('Unknown error during fetch');
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Perform a single fetch attempt with timeout
|
|
43
|
+
*/
|
|
44
|
+
async fetchOnce(url, headers) {
|
|
45
|
+
const controller = new AbortController();
|
|
46
|
+
const timeoutId = setTimeout(() => controller.abort(), this.options.timeout);
|
|
47
|
+
try {
|
|
48
|
+
// Build headers object
|
|
49
|
+
const fetchHeaders = {
|
|
50
|
+
'Accept': 'application/json',
|
|
51
|
+
'User-Agent': this.options.userAgent || 'DocumentationLoader/1.0',
|
|
52
|
+
};
|
|
53
|
+
// Add custom headers if provided
|
|
54
|
+
if (headers) {
|
|
55
|
+
headers.forEach((value, key) => {
|
|
56
|
+
fetchHeaders[key] = value;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
const response = await fetch(url, {
|
|
60
|
+
signal: controller.signal,
|
|
61
|
+
headers: fetchHeaders,
|
|
62
|
+
});
|
|
63
|
+
clearTimeout(timeoutId);
|
|
64
|
+
// Parse response headers into Map
|
|
65
|
+
const responseHeaders = new Map();
|
|
66
|
+
response.headers.forEach((value, key) => {
|
|
67
|
+
responseHeaders.set(key, value);
|
|
68
|
+
});
|
|
69
|
+
// Read response body
|
|
70
|
+
const data = await response.text();
|
|
71
|
+
return {
|
|
72
|
+
status: response.status,
|
|
73
|
+
statusText: response.statusText,
|
|
74
|
+
data,
|
|
75
|
+
headers: responseHeaders,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
clearTimeout(timeoutId);
|
|
80
|
+
// Handle abort/timeout errors
|
|
81
|
+
if (error instanceof Error && error.name === 'AbortError') {
|
|
82
|
+
throw new Error(`Request timeout after ${this.options.timeout}ms`);
|
|
83
|
+
}
|
|
84
|
+
throw error;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Check if error is retryable
|
|
89
|
+
* Retryable: network errors, timeouts, 5xx errors, 408, 429
|
|
90
|
+
* Non-retryable: 4xx client errors (except 408, 429)
|
|
91
|
+
*/
|
|
92
|
+
isRetryableError(error, statusCode) {
|
|
93
|
+
// Check status code if provided
|
|
94
|
+
if (statusCode !== undefined) {
|
|
95
|
+
// 2xx and 3xx are successful, don't retry
|
|
96
|
+
if (statusCode >= 200 && statusCode < 400) {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
// 5xx server errors are retryable
|
|
100
|
+
if (statusCode >= 500) {
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
// 408 Request Timeout and 429 Too Many Requests are retryable
|
|
104
|
+
if (statusCode === 408 || statusCode === 429) {
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
// Other 4xx client errors are not retryable
|
|
108
|
+
if (statusCode >= 400 && statusCode < 500) {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
// Network errors and timeouts are retryable
|
|
113
|
+
if (error) {
|
|
114
|
+
const errorMessage = error.message.toLowerCase();
|
|
115
|
+
// Timeout errors
|
|
116
|
+
if (errorMessage.includes('timeout')) {
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
// Network errors
|
|
120
|
+
if (errorMessage.includes('network') ||
|
|
121
|
+
errorMessage.includes('econnrefused') ||
|
|
122
|
+
errorMessage.includes('enotfound') ||
|
|
123
|
+
errorMessage.includes('econnreset')) {
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
// Default to retryable for unknown errors
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Calculate exponential backoff delay
|
|
132
|
+
* Formula: retryDelay * (2 ^ attempt)
|
|
133
|
+
*/
|
|
134
|
+
calculateBackoff(attempt) {
|
|
135
|
+
return this.options.retryDelay * Math.pow(2, attempt);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Sleep for specified milliseconds
|
|
139
|
+
*/
|
|
140
|
+
sleep(ms) {
|
|
141
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=http-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-client.js","sourceRoot":"","sources":["../../src/loader/http-client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAgBH,MAAM,OAAO,UAAU;IACb,OAAO,CAAoB;IAEnC,YAAY,OAA0B;QACpC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,KAAK,CAAC,GAAW,EAAE,OAA6B;QACpD,IAAI,SAA4B,CAAC;QAEjC,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,OAAO,EAAE,EAAE,CAAC;YACpE,IAAI,CAAC;gBACH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;gBAEpD,gDAAgD;gBAChD,2DAA2D;gBAC3D,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,IAAI,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;oBAC7F,OAAO,QAAQ,CAAC;gBAClB,CAAC;gBAED,qBAAqB;gBACrB,MAAM,KAAK,GAAG,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;gBAC7C,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YAC1B,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,SAAS,GAAG,KAAK,YAAY,KAA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C;gBAC7C,OAAO,IAAI,CAAC;YACd,CAAC;YAED,4CAA4C;YAC5C,IAAI,UAAU,IAAI,GAAG,IAAI,UAAU,GAAG,GAAG,EAAE,CAAC;gBAC1C,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;QAED,4CAA4C;QAC5C,IAAI,KAAK,EAAE,CAAC;YACV,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;YAEjD,iBAAiB;YACjB,IAAI,YAAY,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;gBACrC,OAAO,IAAI,CAAC;YACd,CAAC;YAED,iBAAiB;YACjB,IACE,YAAY,CAAC,QAAQ,CAAC,SAAS,CAAC;gBAChC,YAAY,CAAC,QAAQ,CAAC,cAAc,CAAC;gBACrC,YAAY,CAAC,QAAQ,CAAC,WAAW,CAAC;gBAClC,YAAY,CAAC,QAAQ,CAAC,YAAY,CAAC,EACnC,CAAC;gBACD,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;QAED,0CAA0C;QAC1C,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;OAGG;IACK,gBAAgB,CAAC,OAAe;QACtC,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;IACxD,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,EAAU;QACtB,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;IACzD,CAAC;CACF"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Documentation loader module exports
|
|
3
|
+
*/
|
|
4
|
+
export { DocumentationLoader, DocumentationLoaderOptions, LoadResult, loadDocumentation, } from './documentation-loader.js';
|
|
5
|
+
export { DocumentationSource } from './documentation-source.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/loader/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EACL,mBAAmB,EACnB,0BAA0B,EAC1B,UAAU,EACV,iBAAiB,GAClB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/loader/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EACL,mBAAmB,EAGnB,iBAAiB,GAClB,MAAM,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { CompodocDocumentation } from '../types/compodoc.js';
|
|
2
|
+
import { DocumentationSource } from './documentation-source.js';
|
|
3
|
+
import { LoadResult } from './documentation-loader.js';
|
|
4
|
+
export interface LocalSourceOptions {
|
|
5
|
+
path: string;
|
|
6
|
+
watchForChanges: boolean;
|
|
7
|
+
reloadDebounce: number;
|
|
8
|
+
onReload?: (data: CompodocDocumentation) => void;
|
|
9
|
+
onError?: (error: Error) => void;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* LocalDocumentationSource class
|
|
13
|
+
* Handles loading documentation from local file system with file watching support
|
|
14
|
+
*/
|
|
15
|
+
export declare class LocalDocumentationSource implements DocumentationSource {
|
|
16
|
+
private filePath;
|
|
17
|
+
private watchForChanges;
|
|
18
|
+
private reloadDebounce;
|
|
19
|
+
private watcher?;
|
|
20
|
+
private reloadTimer?;
|
|
21
|
+
private onReloadCallback?;
|
|
22
|
+
private onErrorCallback?;
|
|
23
|
+
private currentData?;
|
|
24
|
+
constructor(options: LocalSourceOptions);
|
|
25
|
+
/**
|
|
26
|
+
* Load the documentation.json file from local file system
|
|
27
|
+
*/
|
|
28
|
+
load(): Promise<LoadResult>;
|
|
29
|
+
/**
|
|
30
|
+
* Start monitoring the file for changes using file watcher
|
|
31
|
+
*/
|
|
32
|
+
startMonitoring(): void;
|
|
33
|
+
/**
|
|
34
|
+
* Stop monitoring the file for changes
|
|
35
|
+
*/
|
|
36
|
+
stopMonitoring(): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Get the currently loaded documentation
|
|
39
|
+
*/
|
|
40
|
+
getCurrentData(): CompodocDocumentation | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Clean up resources
|
|
43
|
+
*/
|
|
44
|
+
dispose(): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Validate the basic structure of the documentation
|
|
47
|
+
*/
|
|
48
|
+
private validateStructure;
|
|
49
|
+
/**
|
|
50
|
+
* Start watching the documentation file for changes
|
|
51
|
+
*/
|
|
52
|
+
private startWatching;
|
|
53
|
+
/**
|
|
54
|
+
* Schedule a reload with debouncing
|
|
55
|
+
*/
|
|
56
|
+
private scheduleReload;
|
|
57
|
+
/**
|
|
58
|
+
* Reload the documentation file
|
|
59
|
+
*/
|
|
60
|
+
private reload;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=local-documentation-source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-documentation-source.d.ts","sourceRoot":"","sources":["../../src/loader/local-documentation-source.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAEvD,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,EAAE,OAAO,CAAC;IACzB,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,qBAAqB,KAAK,IAAI,CAAC;IACjD,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAED;;;GAGG;AACH,qBAAa,wBAAyB,YAAW,mBAAmB;IAClE,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,eAAe,CAAU;IACjC,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,OAAO,CAAC,CAAY;IAC5B,OAAO,CAAC,WAAW,CAAC,CAAiB;IACrC,OAAO,CAAC,gBAAgB,CAAC,CAAwC;IACjE,OAAO,CAAC,eAAe,CAAC,CAAyB;IACjD,OAAO,CAAC,WAAW,CAAC,CAAwB;gBAEhC,OAAO,EAAE,kBAAkB;IAQvC;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,UAAU,CAAC;IAsDjC;;OAEG;IACH,eAAe,IAAI,IAAI;IAQvB;;OAEG;IACG,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAarC;;OAEG;IACH,cAAc,IAAI,qBAAqB,GAAG,SAAS;IAInD;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAO9B;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAmBzB;;OAEG;IACH,OAAO,CAAC,aAAa;IAwBrB;;OAEG;IACH,OAAO,CAAC,cAAc;IAYtB;;OAEG;YACW,MAAM;CAiBrB"}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local documentation source - loads documentation from local file system
|
|
3
|
+
*/
|
|
4
|
+
import * as fs from 'fs';
|
|
5
|
+
import * as path from 'path';
|
|
6
|
+
import { watch } from 'chokidar';
|
|
7
|
+
/**
|
|
8
|
+
* LocalDocumentationSource class
|
|
9
|
+
* Handles loading documentation from local file system with file watching support
|
|
10
|
+
*/
|
|
11
|
+
export class LocalDocumentationSource {
|
|
12
|
+
filePath;
|
|
13
|
+
watchForChanges;
|
|
14
|
+
reloadDebounce;
|
|
15
|
+
watcher;
|
|
16
|
+
reloadTimer;
|
|
17
|
+
onReloadCallback;
|
|
18
|
+
onErrorCallback;
|
|
19
|
+
currentData;
|
|
20
|
+
constructor(options) {
|
|
21
|
+
this.filePath = path.resolve(options.path);
|
|
22
|
+
this.watchForChanges = options.watchForChanges;
|
|
23
|
+
this.reloadDebounce = options.reloadDebounce;
|
|
24
|
+
this.onReloadCallback = options.onReload;
|
|
25
|
+
this.onErrorCallback = options.onError;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Load the documentation.json file from local file system
|
|
29
|
+
*/
|
|
30
|
+
async load() {
|
|
31
|
+
try {
|
|
32
|
+
// Check if file exists
|
|
33
|
+
if (!fs.existsSync(this.filePath)) {
|
|
34
|
+
return {
|
|
35
|
+
success: false,
|
|
36
|
+
error: `Documentation file not found: ${this.filePath}`,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
// Read file
|
|
40
|
+
const content = await fs.promises.readFile(this.filePath, 'utf-8');
|
|
41
|
+
// Parse JSON
|
|
42
|
+
let data;
|
|
43
|
+
try {
|
|
44
|
+
data = JSON.parse(content);
|
|
45
|
+
}
|
|
46
|
+
catch (parseError) {
|
|
47
|
+
return {
|
|
48
|
+
success: false,
|
|
49
|
+
error: `Failed to parse JSON: ${parseError instanceof Error ? parseError.message : String(parseError)}`,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
// Validate structure
|
|
53
|
+
const validationError = this.validateStructure(data);
|
|
54
|
+
if (validationError) {
|
|
55
|
+
return {
|
|
56
|
+
success: false,
|
|
57
|
+
error: validationError,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
// Store current data
|
|
61
|
+
this.currentData = data;
|
|
62
|
+
// Start watching if enabled
|
|
63
|
+
if (this.watchForChanges && !this.watcher) {
|
|
64
|
+
this.startMonitoring();
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
success: true,
|
|
68
|
+
data,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
73
|
+
return {
|
|
74
|
+
success: false,
|
|
75
|
+
error: `Failed to load documentation: ${errorMessage}`,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Start monitoring the file for changes using file watcher
|
|
81
|
+
*/
|
|
82
|
+
startMonitoring() {
|
|
83
|
+
if (this.watcher) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
this.startWatching();
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Stop monitoring the file for changes
|
|
90
|
+
*/
|
|
91
|
+
async stopMonitoring() {
|
|
92
|
+
if (this.reloadTimer) {
|
|
93
|
+
clearTimeout(this.reloadTimer);
|
|
94
|
+
this.reloadTimer = undefined;
|
|
95
|
+
}
|
|
96
|
+
if (this.watcher) {
|
|
97
|
+
await this.watcher.close();
|
|
98
|
+
this.watcher = undefined;
|
|
99
|
+
console.log('Stopped watching documentation file');
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Get the currently loaded documentation
|
|
104
|
+
*/
|
|
105
|
+
getCurrentData() {
|
|
106
|
+
return this.currentData;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Clean up resources
|
|
110
|
+
*/
|
|
111
|
+
async dispose() {
|
|
112
|
+
await this.stopMonitoring();
|
|
113
|
+
this.currentData = undefined;
|
|
114
|
+
this.onReloadCallback = undefined;
|
|
115
|
+
this.onErrorCallback = undefined;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Validate the basic structure of the documentation
|
|
119
|
+
*/
|
|
120
|
+
validateStructure(data) {
|
|
121
|
+
if (!data || typeof data !== 'object') {
|
|
122
|
+
return 'Documentation must be an object';
|
|
123
|
+
}
|
|
124
|
+
const doc = data;
|
|
125
|
+
// Check for required top-level arrays
|
|
126
|
+
const requiredArrays = ['pipes', 'components', 'directives', 'injectables', 'interfaces', 'classes', 'modules'];
|
|
127
|
+
for (const key of requiredArrays) {
|
|
128
|
+
const value = doc[key];
|
|
129
|
+
if (value !== undefined && !Array.isArray(value)) {
|
|
130
|
+
return `${key} must be an array`;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Start watching the documentation file for changes
|
|
137
|
+
*/
|
|
138
|
+
startWatching() {
|
|
139
|
+
if (this.watcher) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
this.watcher = watch(this.filePath, {
|
|
143
|
+
persistent: true,
|
|
144
|
+
ignoreInitial: true,
|
|
145
|
+
});
|
|
146
|
+
this.watcher.on('change', () => {
|
|
147
|
+
this.scheduleReload();
|
|
148
|
+
});
|
|
149
|
+
this.watcher.on('error', (error) => {
|
|
150
|
+
console.error('File watcher error:', error);
|
|
151
|
+
if (this.onErrorCallback) {
|
|
152
|
+
this.onErrorCallback(error);
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
console.log(`Watching for changes: ${this.filePath}`);
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Schedule a reload with debouncing
|
|
159
|
+
*/
|
|
160
|
+
scheduleReload() {
|
|
161
|
+
// Clear existing timer
|
|
162
|
+
if (this.reloadTimer) {
|
|
163
|
+
clearTimeout(this.reloadTimer);
|
|
164
|
+
}
|
|
165
|
+
// Schedule new reload
|
|
166
|
+
this.reloadTimer = setTimeout(() => {
|
|
167
|
+
void this.reload();
|
|
168
|
+
}, this.reloadDebounce);
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Reload the documentation file
|
|
172
|
+
*/
|
|
173
|
+
async reload() {
|
|
174
|
+
console.log('Reloading documentation...');
|
|
175
|
+
const result = await this.load();
|
|
176
|
+
if (result.success && result.data) {
|
|
177
|
+
console.log('Documentation reloaded successfully');
|
|
178
|
+
if (this.onReloadCallback) {
|
|
179
|
+
this.onReloadCallback(result.data);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
console.error('Failed to reload documentation:', result.error);
|
|
184
|
+
if (this.onErrorCallback) {
|
|
185
|
+
this.onErrorCallback(new Error(result.error));
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
//# sourceMappingURL=local-documentation-source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-documentation-source.js","sourceRoot":"","sources":["../../src/loader/local-documentation-source.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAa,MAAM,UAAU,CAAC;AAa5C;;;GAGG;AACH,MAAM,OAAO,wBAAwB;IAC3B,QAAQ,CAAS;IACjB,eAAe,CAAU;IACzB,cAAc,CAAS;IACvB,OAAO,CAAa;IACpB,WAAW,CAAkB;IAC7B,gBAAgB,CAAyC;IACzD,eAAe,CAA0B;IACzC,WAAW,CAAyB;IAE5C,YAAY,OAA2B;QACrC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC3C,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;QAC/C,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC;QAC7C,IAAI,CAAC,gBAAgB,GAAG,OAAO,CAAC,QAAQ,CAAC;QACzC,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC;IACzC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,IAAI;QACR,IAAI,CAAC;YACH,uBAAuB;YACvB,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAClC,OAAO;oBACL,OAAO,EAAE,KAAK;oBACd,KAAK,EAAE,iCAAiC,IAAI,CAAC,QAAQ,EAAE;iBACxD,CAAC;YACJ,C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AC,GAAG,CAAC,4BAA4B,CAAC,CAAC;QAE1C,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;QAEjC,IAAI,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;YAClC,OAAO,CAAC,GAAG,CAAC,qCAAqC,CAAC,CAAC;YACnD,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;gBAC1B,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACrC,CAAC;QACH,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,KAAK,CAAC,iCAAiC,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;YAC/D,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;gBACzB,IAAI,CAAC,eAAe,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YAChD,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Path type detection utilities for distinguishing between local paths and remote URLs
|
|
3
|
+
*/
|
|
4
|
+
export declare enum PathType {
|
|
5
|
+
LOCAL = "local",
|
|
6
|
+
HTTP_URL = "http_url",
|
|
7
|
+
HTTPS_URL = "https_url"
|
|
8
|
+
}
|
|
9
|
+
export interface PathInfo {
|
|
10
|
+
type: PathType;
|
|
11
|
+
originalPath: string;
|
|
12
|
+
normalizedPath: string;
|
|
13
|
+
}
|
|
14
|
+
export declare class PathTypeDetector {
|
|
15
|
+
/**
|
|
16
|
+
* Detect whether a path is a local file path or URL
|
|
17
|
+
* @param path - The path to analyze
|
|
18
|
+
* @returns PathInfo object with type and normalized path
|
|
19
|
+
*/
|
|
20
|
+
static detect(path: string): PathInfo;
|
|
21
|
+
/**
|
|
22
|
+
* Validate URL format
|
|
23
|
+
* @param path - The path to validate
|
|
24
|
+
* @returns true if the path is a valid URL (any protocol)
|
|
25
|
+
*/
|
|
26
|
+
static isValidUrl(path: string): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Check if path is HTTP/HTTPS URL
|
|
29
|
+
* @param path - The path to check
|
|
30
|
+
* @returns true if the path is an HTTP or HTTPS URL
|
|
31
|
+
*/
|
|
32
|
+
static isRemoteUrl(path: string): boolean;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=path-type-detector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-type-detector.d.ts","sourceRoot":"","sources":["../../src/loader/path-type-detector.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,oBAAY,QAAQ;IAClB,KAAK,UAAU;IACf,QAAQ,aAAa;IACrB,SAAS,cAAc;CACxB;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,QAAQ,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,qBAAa,gBAAgB;IAC3B;;;;OAIG;IACH,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ;IAsBrC;;;;OAIG;IACH,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAUxC;;;;OAIG;IACH,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;CA2B1C"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Path type detection utilities for distinguishing between local paths and remote URLs
|
|
3
|
+
*/
|
|
4
|
+
export var PathType;
|
|
5
|
+
(function (PathType) {
|
|
6
|
+
PathType["LOCAL"] = "local";
|
|
7
|
+
PathType["HTTP_URL"] = "http_url";
|
|
8
|
+
PathType["HTTPS_URL"] = "https_url";
|
|
9
|
+
})(PathType || (PathType = {}));
|
|
10
|
+
export class PathTypeDetector {
|
|
11
|
+
/**
|
|
12
|
+
* Detect whether a path is a local file path or URL
|
|
13
|
+
* @param path - The path to analyze
|
|
14
|
+
* @returns PathInfo object with type and normalized path
|
|
15
|
+
*/
|
|
16
|
+
static detect(path) {
|
|
17
|
+
const trimmedPath = path.trim();
|
|
18
|
+
if (this.isRemoteUrl(trimmedPath)) {
|
|
19
|
+
const url = new URL(trimmedPath);
|
|
20
|
+
const type = url.protocol === 'https:' ? PathType.HTTPS_URL : PathType.HTTP_URL;
|
|
21
|
+
return {
|
|
22
|
+
type,
|
|
23
|
+
originalPath: path,
|
|
24
|
+
normalizedPath: trimmedPath,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
// Default to local path
|
|
28
|
+
return {
|
|
29
|
+
type: PathType.LOCAL,
|
|
30
|
+
originalPath: path,
|
|
31
|
+
normalizedPath: trimmedPath,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Validate URL format
|
|
36
|
+
* @param path - The path to validate
|
|
37
|
+
* @returns true if the path is a valid URL (any protocol)
|
|
38
|
+
*/
|
|
39
|
+
static isValidUrl(path) {
|
|
40
|
+
try {
|
|
41
|
+
const url = new URL(path.trim());
|
|
42
|
+
// URL constructor accepts any protocol, so we just check if it parses
|
|
43
|
+
return url.protocol.length > 0;
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Check if path is HTTP/HTTPS URL
|
|
51
|
+
* @param path - The path to check
|
|
52
|
+
* @returns true if the path is an HTTP or HTTPS URL
|
|
53
|
+
*/
|
|
54
|
+
static isRemoteUrl(path) {
|
|
55
|
+
try {
|
|
56
|
+
const trimmed = path.trim();
|
|
57
|
+
// Must start with http:// or https:// to be a valid remote URL
|
|
58
|
+
// This prevents malformed URLs like "http:example.com" from being accepted
|
|
59
|
+
if (!trimmed.startsWith('http://') && !trimmed.startsWith('https://')) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
const url = new URL(trimmed);
|
|
63
|
+
// Must be http or https protocol
|
|
64
|
+
if (url.protocol !== 'http:' && url.protocol !== 'https:') {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
// Must have a hostname (not empty)
|
|
68
|
+
if (!url.hostname || url.hostname.length === 0) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=path-type-detector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-type-detector.js","sourceRoot":"","sources":["../../src/loader/path-type-detector.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,CAAN,IAAY,QAIX;AAJD,WAAY,QAAQ;IAClB,2BAAe,CAAA;IACf,iCAAqB,CAAA;IACrB,mCAAuB,CAAA;AACzB,CAAC,EAJW,QAAQ,KAAR,QAAQ,QAInB;AAQD,MAAM,OAAO,gBAAgB;IAC3B;;;;OAIG;IACH,MAAM,CAAC,MAAM,CAAC,IAAY;QACxB,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QAEhC,IAAI,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,EAAE,CAAC;YAClC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,CAAC;YACjC,MAAM,IAAI,GAAG,GAAG,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;YAEhF,OAAO;gBACL,IAAI;gBACJ,YAAY,EAAE,IAAI;gBAClB,cAAc,EAAE,WAAW;aAC5B,CAAC;QACJ,CAAC;QAED,wBAAwB;QACxB,OAAO;YACL,IAAI,EAAE,QAAQ,CAAC,KAAK;YACpB,YAAY,EAAE,IAAI;YAClB,cAAc,EAAE,WAAW;SAC5B,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,UAAU,CAAC,IAAY;QAC5B,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;YACjC,sEAAsE;YACtE,OAAO,GAAG,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;QACjC,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,WAAW,CAAC,IAAY;QAC7B,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;YAE5B,+DAA+D;YAC/D,2EAA2E;YAC3E,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;gBACtE,OAAO,KAAK,CAAC;YACf,CAAC;YAED,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;YAE7B,iCAAiC;YACjC,IAAI,GAAG,CAAC,QAAQ,KAAK,OAAO,IAAI,GAAG,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;gBAC1D,OAAO,KAAK,CAAC;YACf,CAAC;YAED,mCAAmC;YACnC,IAAI,CAAC,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC/C,OAAO,KAAK,CAAC;YACf,CAAC;YAED,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remote documentation source - loads documentation from HTTP/HTTPS URLs
|
|
3
|
+
*/
|
|
4
|
+
import { DocumentationSource } from './documentation-source.js';
|
|
5
|
+
import { LoadResult } from './documentation-loader.js';
|
|
6
|
+
import { CompodocDocumentation } from '../types/compodoc.js';
|
|
7
|
+
/**
|
|
8
|
+
* Options for RemoteDocumentationSource
|
|
9
|
+
*/
|
|
10
|
+
export interface RemoteSourceOptions {
|
|
11
|
+
/** The URL to fetch documentation from */
|
|
12
|
+
url: string;
|
|
13
|
+
/** Request timeout in milliseconds */
|
|
14
|
+
timeout: number;
|
|
15
|
+
/** Maximum number of retry attempts */
|
|
16
|
+
maxRetries: number;
|
|
17
|
+
/** Polling interval in milliseconds */
|
|
18
|
+
pollingInterval: number;
|
|
19
|
+
/** Callback invoked when documentation is reloaded */
|
|
20
|
+
onReload?: (data: CompodocDocumentation) => void;
|
|
21
|
+
/** Callback invoked when an error occurs */
|
|
22
|
+
onError?: (error: Error) => void;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* RemoteDocumentationSource class
|
|
26
|
+
* Implements DocumentationSource interface for remote HTTP/HTTPS sources
|
|
27
|
+
*
|
|
28
|
+
* Features:
|
|
29
|
+
* - Fetches documentation from remote URLs
|
|
30
|
+
* - Caches responses with ETag/Last-Modified headers
|
|
31
|
+
* - Polls for updates using conditional requests
|
|
32
|
+
* - Handles network errors with retry logic
|
|
33
|
+
*/
|
|
34
|
+
export declare class RemoteDocumentationSource implements DocumentationSource {
|
|
35
|
+
private url;
|
|
36
|
+
private httpClient;
|
|
37
|
+
private cacheManager;
|
|
38
|
+
private pollingTimer?;
|
|
39
|
+
private currentData?;
|
|
40
|
+
private pollingInterval;
|
|
41
|
+
private onReloadCallback?;
|
|
42
|
+
private onErrorCallback?;
|
|
43
|
+
constructor(options: RemoteSourceOptions);
|
|
44
|
+
/**
|
|
45
|
+
* Load documentation from the remote URL
|
|
46
|
+
*
|
|
47
|
+
* @returns Promise resolving to LoadResult with success status and data or error
|
|
48
|
+
*/
|
|
49
|
+
load(): Promise<LoadResult>;
|
|
50
|
+
/**
|
|
51
|
+
* Start monitoring for changes by polling the remote URL
|
|
52
|
+
*
|
|
53
|
+
* Uses setInterval to periodically check for updates using conditional requests
|
|
54
|
+
*/
|
|
55
|
+
startMonitoring(): void;
|
|
56
|
+
/**
|
|
57
|
+
* Stop monitoring for changes
|
|
58
|
+
*
|
|
59
|
+
* Clears the polling interval
|
|
60
|
+
*
|
|
61
|
+
* @returns Promise that resolves when monitoring has been stopped
|
|
62
|
+
*/
|
|
63
|
+
stopMonitoring(): Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Get currently loaded documentation data
|
|
66
|
+
*
|
|
67
|
+
* @returns The currently loaded CompodocDocumentation or undefined if not loaded
|
|
68
|
+
*/
|
|
69
|
+
getCurrentData(): CompodocDocumentation | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* Clean up resources and dispose of the source
|
|
72
|
+
*
|
|
73
|
+
* Stops monitoring and clears cached data
|
|
74
|
+
*
|
|
75
|
+
* @returns Promise that resolves when cleanup is complete
|
|
76
|
+
*/
|
|
77
|
+
dispose(): Promise<void>;
|
|
78
|
+
/**
|
|
79
|
+
* Poll for updates using conditional requests
|
|
80
|
+
*
|
|
81
|
+
* Uses If-None-Match (ETag) and If-Modified-Since (Last-Modified) headers
|
|
82
|
+
* to minimize bandwidth. If the server returns 304 Not Modified, uses cached data.
|
|
83
|
+
*
|
|
84
|
+
* @private
|
|
85
|
+
*/
|
|
86
|
+
private poll;
|
|
87
|
+
/**
|
|
88
|
+
* Fetch and parse documentation from the remote URL
|
|
89
|
+
*
|
|
90
|
+
* @private
|
|
91
|
+
* @returns Promise resolving to LoadResult
|
|
92
|
+
*/
|
|
93
|
+
private fetchDocumentation;
|
|
94
|
+
/**
|
|
95
|
+
* Parse JSON string into CompodocDocumentation
|
|
96
|
+
*
|
|
97
|
+
* @private
|
|
98
|
+
* @param content - JSON string to parse
|
|
99
|
+
* @returns Parsed CompodocDocumentation object
|
|
100
|
+
* @throws ParseError if JSON is invalid
|
|
101
|
+
*/
|
|
102
|
+
private parseJson;
|
|
103
|
+
/**
|
|
104
|
+
* Validate the basic structure of the documentation
|
|
105
|
+
*
|
|
106
|
+
* @private
|
|
107
|
+
* @param data - Data to validate
|
|
108
|
+
* @returns Error message if validation fails, null otherwise
|
|
109
|
+
*/
|
|
110
|
+
private validateStructure;
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=remote-documentation-source.d.ts.map
|