@theia/ovsx-client 1.48.0 → 1.48.1

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 (41) hide show
  1. package/README.md +61 -61
  2. package/lib/index.d.ts +6 -6
  3. package/lib/index.js +30 -30
  4. package/lib/ovsx-api-filter.d.ts +30 -30
  5. package/lib/ovsx-api-filter.js +73 -73
  6. package/lib/ovsx-http-client.d.ts +17 -17
  7. package/lib/ovsx-http-client.js +82 -82
  8. package/lib/ovsx-mock-client.d.ts +43 -43
  9. package/lib/ovsx-mock-client.js +168 -168
  10. package/lib/ovsx-router-client.d.ts +68 -68
  11. package/lib/ovsx-router-client.js +169 -169
  12. package/lib/ovsx-router-client.spec-data.d.ts +10 -10
  13. package/lib/ovsx-router-client.spec-data.js +66 -66
  14. package/lib/ovsx-router-client.spec.d.ts +1 -1
  15. package/lib/ovsx-router-client.spec.js +107 -107
  16. package/lib/ovsx-router-filters/abstract-reg-exp-filter.d.ts +5 -5
  17. package/lib/ovsx-router-filters/abstract-reg-exp-filter.js +27 -27
  18. package/lib/ovsx-router-filters/extension-id-matches-filter.d.ts +7 -7
  19. package/lib/ovsx-router-filters/extension-id-matches-filter.js +33 -33
  20. package/lib/ovsx-router-filters/index.d.ts +2 -2
  21. package/lib/ovsx-router-filters/index.js +22 -22
  22. package/lib/ovsx-router-filters/request-contains-filter.d.ts +8 -8
  23. package/lib/ovsx-router-filters/request-contains-filter.js +35 -35
  24. package/lib/ovsx-types.d.ts +212 -212
  25. package/lib/ovsx-types.js +74 -74
  26. package/lib/types.d.ts +1 -1
  27. package/lib/types.js +17 -17
  28. package/package.json +3 -3
  29. package/src/index.ts +22 -22
  30. package/src/ovsx-api-filter.ts +91 -91
  31. package/src/ovsx-http-client.ts +85 -85
  32. package/src/ovsx-mock-client.ts +182 -182
  33. package/src/ovsx-router-client.spec-data.ts +68 -68
  34. package/src/ovsx-router-client.spec.ts +126 -126
  35. package/src/ovsx-router-client.ts +248 -248
  36. package/src/ovsx-router-filters/abstract-reg-exp-filter.ts +26 -26
  37. package/src/ovsx-router-filters/extension-id-matches-filter.ts +32 -32
  38. package/src/ovsx-router-filters/index.ts +18 -18
  39. package/src/ovsx-router-filters/request-contains-filter.ts +35 -35
  40. package/src/ovsx-types.ts +268 -268
  41. package/src/types.ts +17 -17
@@ -1,44 +1,44 @@
1
- import { ExtensionLike, OVSXClient, VSXExtensionRaw, VSXQueryOptions, VSXQueryResult, VSXSearchOptions, VSXSearchResult } from './ovsx-types';
2
- /**
3
- * Querying will only find exact matches.
4
- * Searching will try to find the query string in various fields.
5
- */
6
- export declare class OVSXMockClient implements OVSXClient {
7
- extensions: VSXExtensionRaw[];
8
- constructor(extensions?: VSXExtensionRaw[]);
9
- setExtensions(extensions: VSXExtensionRaw[]): this;
10
- /**
11
- * @param baseUrl required to construct the URLs required by {@link VSXExtensionRaw}.
12
- * @param ids list of ids to generate {@link VSXExtensionRaw} from.
13
- */
14
- setExtensionsFromIds(baseUrl: string, ids: string[]): this;
15
- query(queryOptions?: VSXQueryOptions): Promise<VSXQueryResult>;
16
- search(searchOptions?: VSXSearchOptions): Promise<VSXSearchResult>;
17
- protected id(extension: ExtensionLike): string;
18
- /**
19
- * Case sensitive.
20
- */
21
- protected compare(expected?: string, value?: string): boolean;
22
- /**
23
- * Case insensitive.
24
- */
25
- protected includes(needle: string, value?: string): boolean;
26
- protected sort(a: VSXExtensionRaw, b: VSXExtensionRaw, searchOptions?: VSXSearchOptions): number;
27
- }
28
- export declare namespace OVSXMockClient {
29
- /**
30
- * URLs should respect the official OpenVSX API:
31
- * https://open-vsx.org/swagger-ui/index.html
32
- */
33
- class UrlBuilder {
34
- protected baseUrl: string;
35
- constructor(baseUrl: string);
36
- url(path: string): string;
37
- apiUrl(path: string): string;
38
- namespaceUrl(namespace: string, path?: string): string;
39
- extensionUrl(namespace: string, name: string, path?: string): string;
40
- extensionReviewsUrl(namespace: string, name: string): string;
41
- extensionFileUrl(namespace: string, name: string, version: string, path?: string): string;
42
- }
43
- }
1
+ import { ExtensionLike, OVSXClient, VSXExtensionRaw, VSXQueryOptions, VSXQueryResult, VSXSearchOptions, VSXSearchResult } from './ovsx-types';
2
+ /**
3
+ * Querying will only find exact matches.
4
+ * Searching will try to find the query string in various fields.
5
+ */
6
+ export declare class OVSXMockClient implements OVSXClient {
7
+ extensions: VSXExtensionRaw[];
8
+ constructor(extensions?: VSXExtensionRaw[]);
9
+ setExtensions(extensions: VSXExtensionRaw[]): this;
10
+ /**
11
+ * @param baseUrl required to construct the URLs required by {@link VSXExtensionRaw}.
12
+ * @param ids list of ids to generate {@link VSXExtensionRaw} from.
13
+ */
14
+ setExtensionsFromIds(baseUrl: string, ids: string[]): this;
15
+ query(queryOptions?: VSXQueryOptions): Promise<VSXQueryResult>;
16
+ search(searchOptions?: VSXSearchOptions): Promise<VSXSearchResult>;
17
+ protected id(extension: ExtensionLike): string;
18
+ /**
19
+ * Case sensitive.
20
+ */
21
+ protected compare(expected?: string, value?: string): boolean;
22
+ /**
23
+ * Case insensitive.
24
+ */
25
+ protected includes(needle: string, value?: string): boolean;
26
+ protected sort(a: VSXExtensionRaw, b: VSXExtensionRaw, searchOptions?: VSXSearchOptions): number;
27
+ }
28
+ export declare namespace OVSXMockClient {
29
+ /**
30
+ * URLs should respect the official OpenVSX API:
31
+ * https://open-vsx.org/swagger-ui/index.html
32
+ */
33
+ class UrlBuilder {
34
+ protected baseUrl: string;
35
+ constructor(baseUrl: string);
36
+ url(path: string): string;
37
+ apiUrl(path: string): string;
38
+ namespaceUrl(namespace: string, path?: string): string;
39
+ extensionUrl(namespace: string, name: string, path?: string): string;
40
+ extensionReviewsUrl(namespace: string, name: string): string;
41
+ extensionFileUrl(namespace: string, name: string, version: string, path?: string): string;
42
+ }
43
+ }
44
44
  //# sourceMappingURL=ovsx-mock-client.d.ts.map
@@ -1,169 +1,169 @@
1
- "use strict";
2
- // *****************************************************************************
3
- // Copyright (C) 2023 Ericsson and others.
4
- //
5
- // This program and the accompanying materials are made available under the
6
- // terms of the Eclipse Public License v. 2.0 which is available at
7
- // http://www.eclipse.org/legal/epl-2.0.
8
- //
9
- // This Source Code may also be made available under the following Secondary
10
- // Licenses when the conditions for such availability set forth in the Eclipse
11
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
- // with the GNU Classpath Exception which is available at
13
- // https://www.gnu.org/software/classpath/license.html.
14
- //
15
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
16
- // *****************************************************************************
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.OVSXMockClient = void 0;
19
- /**
20
- * Querying will only find exact matches.
21
- * Searching will try to find the query string in various fields.
22
- */
23
- class OVSXMockClient {
24
- constructor(extensions = []) {
25
- this.extensions = extensions;
26
- }
27
- setExtensions(extensions) {
28
- this.extensions = extensions;
29
- return this;
30
- }
31
- /**
32
- * @param baseUrl required to construct the URLs required by {@link VSXExtensionRaw}.
33
- * @param ids list of ids to generate {@link VSXExtensionRaw} from.
34
- */
35
- setExtensionsFromIds(baseUrl, ids) {
36
- const now = Date.now();
37
- const url = new OVSXMockClient.UrlBuilder(baseUrl);
38
- this.extensions = ids.map((extension, i) => {
39
- const [id, version = '0.0.1'] = extension.split('@', 2);
40
- const [namespace, name] = id.split('.', 2);
41
- return {
42
- allVersions: {
43
- [version]: url.extensionUrl(namespace, name, `/${version}`)
44
- },
45
- displayName: name,
46
- downloadCount: 0,
47
- files: {
48
- download: url.extensionFileUrl(namespace, name, version, `/${id}-${version}.vsix`)
49
- },
50
- name,
51
- namespace,
52
- namespaceAccess: 'public',
53
- namespaceUrl: url.namespaceUrl(namespace),
54
- publishedBy: {
55
- loginName: 'mock'
56
- },
57
- reviewCount: 0,
58
- reviewsUrl: url.extensionReviewsUrl(namespace, name),
59
- timestamp: new Date(now - ids.length + i + 1).toISOString(),
60
- version,
61
- description: `Mock VS Code Extension for ${id}`
62
- };
63
- });
64
- return this;
65
- }
66
- async query(queryOptions) {
67
- return {
68
- extensions: this.extensions
69
- .filter(extension => typeof queryOptions === 'object' && (this.compare(queryOptions.extensionId, this.id(extension)) &&
70
- this.compare(queryOptions.extensionName, extension.name) &&
71
- this.compare(queryOptions.extensionVersion, extension.version) &&
72
- this.compare(queryOptions.namespaceName, extension.namespace)))
73
- };
74
- }
75
- async search(searchOptions) {
76
- var _a, _b;
77
- const query = searchOptions === null || searchOptions === void 0 ? void 0 : searchOptions.query;
78
- const offset = (_a = searchOptions === null || searchOptions === void 0 ? void 0 : searchOptions.offset) !== null && _a !== void 0 ? _a : 0;
79
- const size = (_b = searchOptions === null || searchOptions === void 0 ? void 0 : searchOptions.size) !== null && _b !== void 0 ? _b : 18;
80
- const end = offset + size;
81
- return {
82
- offset,
83
- extensions: this.extensions
84
- .filter(extension => typeof query !== 'string' || (this.includes(query, this.id(extension)) ||
85
- this.includes(query, extension.description) ||
86
- this.includes(query, extension.displayName)))
87
- .sort((a, b) => this.sort(a, b, searchOptions))
88
- .filter((extension, i) => i >= offset && i < end)
89
- .map(extension => ({
90
- downloadCount: extension.downloadCount,
91
- files: extension.files,
92
- name: extension.name,
93
- namespace: extension.namespace,
94
- timestamp: extension.timestamp,
95
- url: `${extension.namespaceUrl}/${extension.name}`,
96
- version: extension.version,
97
- }))
98
- };
99
- }
100
- id(extension) {
101
- return `${extension.namespace}.${extension.name}`;
102
- }
103
- /**
104
- * Case sensitive.
105
- */
106
- compare(expected, value) {
107
- return expected === undefined || value === undefined || expected === value;
108
- }
109
- /**
110
- * Case insensitive.
111
- */
112
- includes(needle, value) {
113
- return value === undefined || value.toLowerCase().includes(needle.toLowerCase());
114
- }
115
- sort(a, b, searchOptions) {
116
- var _a, _b, _c, _d;
117
- let order = 0;
118
- const sortBy = (_a = searchOptions === null || searchOptions === void 0 ? void 0 : searchOptions.sortBy) !== null && _a !== void 0 ? _a : 'relevance';
119
- const sortOrder = (_b = searchOptions === null || searchOptions === void 0 ? void 0 : searchOptions.sortOrder) !== null && _b !== void 0 ? _b : 'desc';
120
- if (sortBy === 'averageRating') {
121
- order = ((_c = a.averageRating) !== null && _c !== void 0 ? _c : -1) - ((_d = b.averageRating) !== null && _d !== void 0 ? _d : -1);
122
- }
123
- else if (sortBy === 'downloadCount') {
124
- order = a.downloadCount - b.downloadCount;
125
- }
126
- else if (sortBy === 'relevance') {
127
- order = 0;
128
- }
129
- else if (sortBy === 'timestamp') {
130
- order = new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime();
131
- }
132
- if (sortOrder === 'asc') {
133
- order *= -1;
134
- }
135
- return order;
136
- }
137
- }
138
- exports.OVSXMockClient = OVSXMockClient;
139
- (function (OVSXMockClient) {
140
- /**
141
- * URLs should respect the official OpenVSX API:
142
- * https://open-vsx.org/swagger-ui/index.html
143
- */
144
- class UrlBuilder {
145
- constructor(baseUrl) {
146
- this.baseUrl = baseUrl;
147
- }
148
- url(path) {
149
- return this.baseUrl + path;
150
- }
151
- apiUrl(path) {
152
- return this.url(`/api${path}`);
153
- }
154
- namespaceUrl(namespace, path = '') {
155
- return this.apiUrl(`/${namespace}${path}`);
156
- }
157
- extensionUrl(namespace, name, path = '') {
158
- return this.apiUrl(`/${namespace}/${name}${path}`);
159
- }
160
- extensionReviewsUrl(namespace, name) {
161
- return this.apiUrl(`/${namespace}/${name}/reviews`);
162
- }
163
- extensionFileUrl(namespace, name, version, path = '') {
164
- return this.apiUrl(`/${namespace}/${name}/${version}/file${path}`);
165
- }
166
- }
167
- OVSXMockClient.UrlBuilder = UrlBuilder;
168
- })(OVSXMockClient = exports.OVSXMockClient || (exports.OVSXMockClient = {}));
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2023 Ericsson and others.
4
+ //
5
+ // This program and the accompanying materials are made available under the
6
+ // terms of the Eclipse Public License v. 2.0 which is available at
7
+ // http://www.eclipse.org/legal/epl-2.0.
8
+ //
9
+ // This Source Code may also be made available under the following Secondary
10
+ // Licenses when the conditions for such availability set forth in the Eclipse
11
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
+ // with the GNU Classpath Exception which is available at
13
+ // https://www.gnu.org/software/classpath/license.html.
14
+ //
15
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
16
+ // *****************************************************************************
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.OVSXMockClient = void 0;
19
+ /**
20
+ * Querying will only find exact matches.
21
+ * Searching will try to find the query string in various fields.
22
+ */
23
+ class OVSXMockClient {
24
+ constructor(extensions = []) {
25
+ this.extensions = extensions;
26
+ }
27
+ setExtensions(extensions) {
28
+ this.extensions = extensions;
29
+ return this;
30
+ }
31
+ /**
32
+ * @param baseUrl required to construct the URLs required by {@link VSXExtensionRaw}.
33
+ * @param ids list of ids to generate {@link VSXExtensionRaw} from.
34
+ */
35
+ setExtensionsFromIds(baseUrl, ids) {
36
+ const now = Date.now();
37
+ const url = new OVSXMockClient.UrlBuilder(baseUrl);
38
+ this.extensions = ids.map((extension, i) => {
39
+ const [id, version = '0.0.1'] = extension.split('@', 2);
40
+ const [namespace, name] = id.split('.', 2);
41
+ return {
42
+ allVersions: {
43
+ [version]: url.extensionUrl(namespace, name, `/${version}`)
44
+ },
45
+ displayName: name,
46
+ downloadCount: 0,
47
+ files: {
48
+ download: url.extensionFileUrl(namespace, name, version, `/${id}-${version}.vsix`)
49
+ },
50
+ name,
51
+ namespace,
52
+ namespaceAccess: 'public',
53
+ namespaceUrl: url.namespaceUrl(namespace),
54
+ publishedBy: {
55
+ loginName: 'mock'
56
+ },
57
+ reviewCount: 0,
58
+ reviewsUrl: url.extensionReviewsUrl(namespace, name),
59
+ timestamp: new Date(now - ids.length + i + 1).toISOString(),
60
+ version,
61
+ description: `Mock VS Code Extension for ${id}`
62
+ };
63
+ });
64
+ return this;
65
+ }
66
+ async query(queryOptions) {
67
+ return {
68
+ extensions: this.extensions
69
+ .filter(extension => typeof queryOptions === 'object' && (this.compare(queryOptions.extensionId, this.id(extension)) &&
70
+ this.compare(queryOptions.extensionName, extension.name) &&
71
+ this.compare(queryOptions.extensionVersion, extension.version) &&
72
+ this.compare(queryOptions.namespaceName, extension.namespace)))
73
+ };
74
+ }
75
+ async search(searchOptions) {
76
+ var _a, _b;
77
+ const query = searchOptions === null || searchOptions === void 0 ? void 0 : searchOptions.query;
78
+ const offset = (_a = searchOptions === null || searchOptions === void 0 ? void 0 : searchOptions.offset) !== null && _a !== void 0 ? _a : 0;
79
+ const size = (_b = searchOptions === null || searchOptions === void 0 ? void 0 : searchOptions.size) !== null && _b !== void 0 ? _b : 18;
80
+ const end = offset + size;
81
+ return {
82
+ offset,
83
+ extensions: this.extensions
84
+ .filter(extension => typeof query !== 'string' || (this.includes(query, this.id(extension)) ||
85
+ this.includes(query, extension.description) ||
86
+ this.includes(query, extension.displayName)))
87
+ .sort((a, b) => this.sort(a, b, searchOptions))
88
+ .filter((extension, i) => i >= offset && i < end)
89
+ .map(extension => ({
90
+ downloadCount: extension.downloadCount,
91
+ files: extension.files,
92
+ name: extension.name,
93
+ namespace: extension.namespace,
94
+ timestamp: extension.timestamp,
95
+ url: `${extension.namespaceUrl}/${extension.name}`,
96
+ version: extension.version,
97
+ }))
98
+ };
99
+ }
100
+ id(extension) {
101
+ return `${extension.namespace}.${extension.name}`;
102
+ }
103
+ /**
104
+ * Case sensitive.
105
+ */
106
+ compare(expected, value) {
107
+ return expected === undefined || value === undefined || expected === value;
108
+ }
109
+ /**
110
+ * Case insensitive.
111
+ */
112
+ includes(needle, value) {
113
+ return value === undefined || value.toLowerCase().includes(needle.toLowerCase());
114
+ }
115
+ sort(a, b, searchOptions) {
116
+ var _a, _b, _c, _d;
117
+ let order = 0;
118
+ const sortBy = (_a = searchOptions === null || searchOptions === void 0 ? void 0 : searchOptions.sortBy) !== null && _a !== void 0 ? _a : 'relevance';
119
+ const sortOrder = (_b = searchOptions === null || searchOptions === void 0 ? void 0 : searchOptions.sortOrder) !== null && _b !== void 0 ? _b : 'desc';
120
+ if (sortBy === 'averageRating') {
121
+ order = ((_c = a.averageRating) !== null && _c !== void 0 ? _c : -1) - ((_d = b.averageRating) !== null && _d !== void 0 ? _d : -1);
122
+ }
123
+ else if (sortBy === 'downloadCount') {
124
+ order = a.downloadCount - b.downloadCount;
125
+ }
126
+ else if (sortBy === 'relevance') {
127
+ order = 0;
128
+ }
129
+ else if (sortBy === 'timestamp') {
130
+ order = new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime();
131
+ }
132
+ if (sortOrder === 'asc') {
133
+ order *= -1;
134
+ }
135
+ return order;
136
+ }
137
+ }
138
+ exports.OVSXMockClient = OVSXMockClient;
139
+ (function (OVSXMockClient) {
140
+ /**
141
+ * URLs should respect the official OpenVSX API:
142
+ * https://open-vsx.org/swagger-ui/index.html
143
+ */
144
+ class UrlBuilder {
145
+ constructor(baseUrl) {
146
+ this.baseUrl = baseUrl;
147
+ }
148
+ url(path) {
149
+ return this.baseUrl + path;
150
+ }
151
+ apiUrl(path) {
152
+ return this.url(`/api${path}`);
153
+ }
154
+ namespaceUrl(namespace, path = '') {
155
+ return this.apiUrl(`/${namespace}${path}`);
156
+ }
157
+ extensionUrl(namespace, name, path = '') {
158
+ return this.apiUrl(`/${namespace}/${name}${path}`);
159
+ }
160
+ extensionReviewsUrl(namespace, name) {
161
+ return this.apiUrl(`/${namespace}/${name}/reviews`);
162
+ }
163
+ extensionFileUrl(namespace, name, version, path = '') {
164
+ return this.apiUrl(`/${namespace}/${name}/${version}/file${path}`);
165
+ }
166
+ }
167
+ OVSXMockClient.UrlBuilder = UrlBuilder;
168
+ })(OVSXMockClient = exports.OVSXMockClient || (exports.OVSXMockClient = {}));
169
169
  //# sourceMappingURL=ovsx-mock-client.js.map
@@ -1,69 +1,69 @@
1
- import { ExtensionLike, OVSXClient, OVSXClientProvider, VSXQueryOptions, VSXQueryResult, VSXSearchOptions, VSXSearchResult } from './ovsx-types';
2
- import type { MaybePromise } from './types';
3
- export interface OVSXRouterFilter {
4
- filterSearchOptions?(searchOptions?: VSXSearchOptions): MaybePromise<unknown>;
5
- filterQueryOptions?(queryOptions?: VSXQueryOptions): MaybePromise<unknown>;
6
- filterExtension?(extension: ExtensionLike): MaybePromise<unknown>;
7
- }
8
- /**
9
- * @param conditions key/value mapping of condition statements that rules may process
10
- * @param remainingKeys keys left to be processed, remove items from it when you handled them
11
- */
12
- export declare type OVSXRouterFilterFactory = (conditions: Readonly<Record<string, unknown>>, remainingKeys: Set<string>) => MaybePromise<OVSXRouterFilter | undefined>;
13
- /**
14
- * Helper function to create factories that handle a single condition key.
15
- */
16
- export declare function createFilterFactory(conditionKey: string, factory: (conditionValue: unknown) => OVSXRouterFilter | undefined): OVSXRouterFilterFactory;
17
- export interface OVSXRouterConfig {
18
- /**
19
- * Registry aliases that will be used for routing.
20
- */
21
- registries?: {
22
- [alias: string]: string;
23
- };
24
- /**
25
- * The registry/ies to use by default.
26
- */
27
- use: string | string[];
28
- /**
29
- * Filters for the different phases of interfacing with a registry.
30
- */
31
- rules?: OVSXRouterRule[];
32
- }
33
- export interface OVSXRouterRule {
34
- [condition: string]: unknown;
35
- use?: string | string[] | null;
36
- }
37
- /**
38
- * @internal
39
- */
40
- export interface OVSXRouterParsedRule {
41
- filters: OVSXRouterFilter[];
42
- use: string[];
43
- }
44
- /**
45
- * Route and agglomerate queries according to {@link routerConfig}.
46
- * {@link ruleFactories} is the actual logic used to evaluate the config.
47
- * Each rule implementation will be ran sequentially over each configured rule.
48
- */
49
- export declare class OVSXRouterClient implements OVSXClient {
50
- protected readonly useDefault: string[];
51
- protected readonly clientProvider: OVSXClientProvider;
52
- protected readonly rules: OVSXRouterParsedRule[];
53
- static FromConfig(routerConfig: OVSXRouterConfig, clientProvider: OVSXClientProvider, filterFactories: OVSXRouterFilterFactory[]): Promise<OVSXRouterClient>;
54
- protected static ParseRules(rules: OVSXRouterRule[], filterFactories: OVSXRouterFilterFactory[], aliases?: Record<string, string>): Promise<OVSXRouterParsedRule[]>;
55
- protected static ParseUse(use: string | string[] | null | undefined, aliases?: Record<string, string>): string[];
56
- constructor(useDefault: string[], clientProvider: OVSXClientProvider, rules: OVSXRouterParsedRule[]);
57
- search(searchOptions?: VSXSearchOptions): Promise<VSXSearchResult>;
58
- query(queryOptions?: VSXQueryOptions): Promise<VSXQueryResult>;
59
- protected emptySearchResult(searchOptions?: VSXSearchOptions): VSXSearchResult;
60
- protected emptyQueryResult(queryOptions?: VSXQueryOptions): VSXQueryResult;
61
- protected mergedQuery(registries: string[], queryOptions?: VSXQueryOptions): Promise<VSXQueryResult>;
62
- protected mergedSearch(registries: string[], searchOptions?: VSXSearchOptions): Promise<VSXSearchResult>;
63
- protected mergeSearchResults(results: Map<string, VSXSearchResult>): Promise<VSXSearchResult>;
64
- protected mergeQueryResults(results: Map<string, VSXQueryResult>): Promise<VSXQueryResult>;
65
- protected filterExtension<T extends ExtensionLike>(sourceUri: string, extension: T): Promise<T | undefined>;
66
- protected runRules<T>(runFilter: (filter: OVSXRouterFilter) => unknown, onRuleMatched: (rule: OVSXRouterParsedRule) => T): Promise<T | undefined>;
67
- protected runRules<T, U>(runFilter: (filter: OVSXRouterFilter) => unknown, onRuleMatched: (rule: OVSXRouterParsedRule) => T, onNoRuleMatched: () => U): Promise<T | U>;
68
- }
1
+ import { ExtensionLike, OVSXClient, OVSXClientProvider, VSXQueryOptions, VSXQueryResult, VSXSearchOptions, VSXSearchResult } from './ovsx-types';
2
+ import type { MaybePromise } from './types';
3
+ export interface OVSXRouterFilter {
4
+ filterSearchOptions?(searchOptions?: VSXSearchOptions): MaybePromise<unknown>;
5
+ filterQueryOptions?(queryOptions?: VSXQueryOptions): MaybePromise<unknown>;
6
+ filterExtension?(extension: ExtensionLike): MaybePromise<unknown>;
7
+ }
8
+ /**
9
+ * @param conditions key/value mapping of condition statements that rules may process
10
+ * @param remainingKeys keys left to be processed, remove items from it when you handled them
11
+ */
12
+ export declare type OVSXRouterFilterFactory = (conditions: Readonly<Record<string, unknown>>, remainingKeys: Set<string>) => MaybePromise<OVSXRouterFilter | undefined>;
13
+ /**
14
+ * Helper function to create factories that handle a single condition key.
15
+ */
16
+ export declare function createFilterFactory(conditionKey: string, factory: (conditionValue: unknown) => OVSXRouterFilter | undefined): OVSXRouterFilterFactory;
17
+ export interface OVSXRouterConfig {
18
+ /**
19
+ * Registry aliases that will be used for routing.
20
+ */
21
+ registries?: {
22
+ [alias: string]: string;
23
+ };
24
+ /**
25
+ * The registry/ies to use by default.
26
+ */
27
+ use: string | string[];
28
+ /**
29
+ * Filters for the different phases of interfacing with a registry.
30
+ */
31
+ rules?: OVSXRouterRule[];
32
+ }
33
+ export interface OVSXRouterRule {
34
+ [condition: string]: unknown;
35
+ use?: string | string[] | null;
36
+ }
37
+ /**
38
+ * @internal
39
+ */
40
+ export interface OVSXRouterParsedRule {
41
+ filters: OVSXRouterFilter[];
42
+ use: string[];
43
+ }
44
+ /**
45
+ * Route and agglomerate queries according to {@link routerConfig}.
46
+ * {@link ruleFactories} is the actual logic used to evaluate the config.
47
+ * Each rule implementation will be ran sequentially over each configured rule.
48
+ */
49
+ export declare class OVSXRouterClient implements OVSXClient {
50
+ protected readonly useDefault: string[];
51
+ protected readonly clientProvider: OVSXClientProvider;
52
+ protected readonly rules: OVSXRouterParsedRule[];
53
+ static FromConfig(routerConfig: OVSXRouterConfig, clientProvider: OVSXClientProvider, filterFactories: OVSXRouterFilterFactory[]): Promise<OVSXRouterClient>;
54
+ protected static ParseRules(rules: OVSXRouterRule[], filterFactories: OVSXRouterFilterFactory[], aliases?: Record<string, string>): Promise<OVSXRouterParsedRule[]>;
55
+ protected static ParseUse(use: string | string[] | null | undefined, aliases?: Record<string, string>): string[];
56
+ constructor(useDefault: string[], clientProvider: OVSXClientProvider, rules: OVSXRouterParsedRule[]);
57
+ search(searchOptions?: VSXSearchOptions): Promise<VSXSearchResult>;
58
+ query(queryOptions?: VSXQueryOptions): Promise<VSXQueryResult>;
59
+ protected emptySearchResult(searchOptions?: VSXSearchOptions): VSXSearchResult;
60
+ protected emptyQueryResult(queryOptions?: VSXQueryOptions): VSXQueryResult;
61
+ protected mergedQuery(registries: string[], queryOptions?: VSXQueryOptions): Promise<VSXQueryResult>;
62
+ protected mergedSearch(registries: string[], searchOptions?: VSXSearchOptions): Promise<VSXSearchResult>;
63
+ protected mergeSearchResults(results: Map<string, VSXSearchResult>): Promise<VSXSearchResult>;
64
+ protected mergeQueryResults(results: Map<string, VSXQueryResult>): Promise<VSXQueryResult>;
65
+ protected filterExtension<T extends ExtensionLike>(sourceUri: string, extension: T): Promise<T | undefined>;
66
+ protected runRules<T>(runFilter: (filter: OVSXRouterFilter) => unknown, onRuleMatched: (rule: OVSXRouterParsedRule) => T): Promise<T | undefined>;
67
+ protected runRules<T, U>(runFilter: (filter: OVSXRouterFilter) => unknown, onRuleMatched: (rule: OVSXRouterParsedRule) => T, onNoRuleMatched: () => U): Promise<T | U>;
68
+ }
69
69
  //# sourceMappingURL=ovsx-router-client.d.ts.map