@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
package/README.md CHANGED
@@ -1,61 +1,61 @@
1
- <div align='center'>
2
-
3
- <br />
4
-
5
- <img src='https://raw.githubusercontent.com/eclipse-theia/theia/master/logo/theia.svg?sanitize=true' alt='theia-ext-logo' width='100px' />
6
-
7
- <h2>ECLIPSE THEIA - OVSX CLIENT</h2>
8
-
9
- <hr />
10
-
11
- </div>
12
-
13
- ## Description
14
-
15
- The `@theia/ovsx-client` package is used to interact with `open-vsx` through its REST APIs.
16
- The package allows clients to fetch extensions and their metadata, search the registry, and
17
- includes the necessary logic to determine compatibility based on a provided supported API version.
18
-
19
- Note that this client only supports a subset of the whole OpenVSX API, only what's relevant to
20
- clients like Theia applications.
21
-
22
- ### `OVSXRouterClient`
23
-
24
- This class is an `OVSXClient` that can delegate requests to sub-clients based on some configuration (`OVSXRouterConfig`).
25
-
26
- ```jsonc
27
- {
28
- "registries": {
29
- // `[Alias]: URL` pairs to avoid copy pasting URLs down the config
30
- },
31
- "use": [
32
- // List of aliases/URLs to use when no filtering was applied.
33
- ],
34
- "rules": [
35
- {
36
- "ifRequestContains": "regex matched against various fields in requests",
37
- "ifExtensionIdMatches": "regex matched against the extension id (without version)",
38
- "use": [/*
39
- List of registries to forward the request to when all the
40
- conditions are matched.
41
-
42
- `null` or `[]` means to not forward the request anywhere.
43
- */]
44
- }
45
- ]
46
- }
47
- ```
48
-
49
- ## Additional Information
50
-
51
- - [Theia - GitHub](https://github.com/eclipse-theia/theia)
52
- - [Theia - Website](https://theia-ide.org/)
53
-
54
- ## License
55
-
56
- - [Eclipse Public License 2.0](http://www.eclipse.org/legal/epl-2.0/)
57
- - [一 (Secondary) GNU General Public License, version 2 with the GNU Classpath Exception](https://projects.eclipse.org/license/secondary-gpl-2.0-cp)
58
-
59
- ## Trademark
60
- "Theia" is a trademark of the Eclipse Foundation
61
- https://www.eclipse.org/theia
1
+ <div align='center'>
2
+
3
+ <br />
4
+
5
+ <img src='https://raw.githubusercontent.com/eclipse-theia/theia/master/logo/theia.svg?sanitize=true' alt='theia-ext-logo' width='100px' />
6
+
7
+ <h2>ECLIPSE THEIA - OVSX CLIENT</h2>
8
+
9
+ <hr />
10
+
11
+ </div>
12
+
13
+ ## Description
14
+
15
+ The `@theia/ovsx-client` package is used to interact with `open-vsx` through its REST APIs.
16
+ The package allows clients to fetch extensions and their metadata, search the registry, and
17
+ includes the necessary logic to determine compatibility based on a provided supported API version.
18
+
19
+ Note that this client only supports a subset of the whole OpenVSX API, only what's relevant to
20
+ clients like Theia applications.
21
+
22
+ ### `OVSXRouterClient`
23
+
24
+ This class is an `OVSXClient` that can delegate requests to sub-clients based on some configuration (`OVSXRouterConfig`).
25
+
26
+ ```jsonc
27
+ {
28
+ "registries": {
29
+ // `[Alias]: URL` pairs to avoid copy pasting URLs down the config
30
+ },
31
+ "use": [
32
+ // List of aliases/URLs to use when no filtering was applied.
33
+ ],
34
+ "rules": [
35
+ {
36
+ "ifRequestContains": "regex matched against various fields in requests",
37
+ "ifExtensionIdMatches": "regex matched against the extension id (without version)",
38
+ "use": [/*
39
+ List of registries to forward the request to when all the
40
+ conditions are matched.
41
+
42
+ `null` or `[]` means to not forward the request anywhere.
43
+ */]
44
+ }
45
+ ]
46
+ }
47
+ ```
48
+
49
+ ## Additional Information
50
+
51
+ - [Theia - GitHub](https://github.com/eclipse-theia/theia)
52
+ - [Theia - Website](https://theia-ide.org/)
53
+
54
+ ## License
55
+
56
+ - [Eclipse Public License 2.0](http://www.eclipse.org/legal/epl-2.0/)
57
+ - [一 (Secondary) GNU General Public License, version 2 with the GNU Classpath Exception](https://projects.eclipse.org/license/secondary-gpl-2.0-cp)
58
+
59
+ ## Trademark
60
+ "Theia" is a trademark of the Eclipse Foundation
61
+ https://www.eclipse.org/theia
package/lib/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- export { OVSXApiFilter, OVSXApiFilterImpl } from './ovsx-api-filter';
2
- export { OVSXHttpClient } from './ovsx-http-client';
3
- export { OVSXMockClient } from './ovsx-mock-client';
4
- export { OVSXRouterClient, OVSXRouterConfig, OVSXRouterFilterFactory as FilterFactory } from './ovsx-router-client';
5
- export * from './ovsx-router-filters';
6
- export * from './ovsx-types';
1
+ export { OVSXApiFilter, OVSXApiFilterImpl } from './ovsx-api-filter';
2
+ export { OVSXHttpClient } from './ovsx-http-client';
3
+ export { OVSXMockClient } from './ovsx-mock-client';
4
+ export { OVSXRouterClient, OVSXRouterConfig, OVSXRouterFilterFactory as FilterFactory } from './ovsx-router-client';
5
+ export * from './ovsx-router-filters';
6
+ export * from './ovsx-types';
7
7
  //# sourceMappingURL=index.d.ts.map
package/lib/index.js CHANGED
@@ -1,31 +1,31 @@
1
- "use strict";
2
- // *****************************************************************************
3
- // Copyright (C) 2021 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.OVSXRouterClient = exports.OVSXMockClient = exports.OVSXHttpClient = exports.OVSXApiFilterImpl = exports.OVSXApiFilter = void 0;
19
- const tslib_1 = require("tslib");
20
- var ovsx_api_filter_1 = require("./ovsx-api-filter");
21
- Object.defineProperty(exports, "OVSXApiFilter", { enumerable: true, get: function () { return ovsx_api_filter_1.OVSXApiFilter; } });
22
- Object.defineProperty(exports, "OVSXApiFilterImpl", { enumerable: true, get: function () { return ovsx_api_filter_1.OVSXApiFilterImpl; } });
23
- var ovsx_http_client_1 = require("./ovsx-http-client");
24
- Object.defineProperty(exports, "OVSXHttpClient", { enumerable: true, get: function () { return ovsx_http_client_1.OVSXHttpClient; } });
25
- var ovsx_mock_client_1 = require("./ovsx-mock-client");
26
- Object.defineProperty(exports, "OVSXMockClient", { enumerable: true, get: function () { return ovsx_mock_client_1.OVSXMockClient; } });
27
- var ovsx_router_client_1 = require("./ovsx-router-client");
28
- Object.defineProperty(exports, "OVSXRouterClient", { enumerable: true, get: function () { return ovsx_router_client_1.OVSXRouterClient; } });
29
- (0, tslib_1.__exportStar)(require("./ovsx-router-filters"), exports);
30
- (0, tslib_1.__exportStar)(require("./ovsx-types"), exports);
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2021 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.OVSXRouterClient = exports.OVSXMockClient = exports.OVSXHttpClient = exports.OVSXApiFilterImpl = exports.OVSXApiFilter = void 0;
19
+ const tslib_1 = require("tslib");
20
+ var ovsx_api_filter_1 = require("./ovsx-api-filter");
21
+ Object.defineProperty(exports, "OVSXApiFilter", { enumerable: true, get: function () { return ovsx_api_filter_1.OVSXApiFilter; } });
22
+ Object.defineProperty(exports, "OVSXApiFilterImpl", { enumerable: true, get: function () { return ovsx_api_filter_1.OVSXApiFilterImpl; } });
23
+ var ovsx_http_client_1 = require("./ovsx-http-client");
24
+ Object.defineProperty(exports, "OVSXHttpClient", { enumerable: true, get: function () { return ovsx_http_client_1.OVSXHttpClient; } });
25
+ var ovsx_mock_client_1 = require("./ovsx-mock-client");
26
+ Object.defineProperty(exports, "OVSXMockClient", { enumerable: true, get: function () { return ovsx_mock_client_1.OVSXMockClient; } });
27
+ var ovsx_router_client_1 = require("./ovsx-router-client");
28
+ Object.defineProperty(exports, "OVSXRouterClient", { enumerable: true, get: function () { return ovsx_router_client_1.OVSXRouterClient; } });
29
+ (0, tslib_1.__exportStar)(require("./ovsx-router-filters"), exports);
30
+ (0, tslib_1.__exportStar)(require("./ovsx-types"), exports);
31
31
  //# sourceMappingURL=index.js.map
@@ -1,31 +1,31 @@
1
- import { VSXAllVersions, VSXExtensionRaw, VSXSearchEntry } from './ovsx-types';
2
- export declare const OVSXApiFilter: unique symbol;
3
- /**
4
- * Filter various data types based on a pre-defined supported VS Code API version.
5
- */
6
- export interface OVSXApiFilter {
7
- supportedApiVersion: string;
8
- /**
9
- * Get the latest compatible extension version:
10
- * - A builtin extension is fetched based on the extension version which matches the API.
11
- * - An extension satisfies compatibility if its `engines.vscode` version is supported.
12
- *
13
- * @param extensionId the extension id.
14
- * @returns the data for the latest compatible extension version if available, else `undefined`.
15
- */
16
- getLatestCompatibleExtension(extensions: VSXExtensionRaw[]): VSXExtensionRaw | undefined;
17
- getLatestCompatibleVersion(searchEntry: VSXSearchEntry): VSXAllVersions | undefined;
18
- }
19
- export declare class OVSXApiFilterImpl implements OVSXApiFilter {
20
- supportedApiVersion: string;
21
- constructor(supportedApiVersion: string);
22
- getLatestCompatibleExtension(extensions: VSXExtensionRaw[]): VSXExtensionRaw | undefined;
23
- getLatestCompatibleVersion(searchEntry: VSXSearchEntry): VSXAllVersions | undefined;
24
- protected isBuiltinNamespace(namespace: string): boolean;
25
- /**
26
- * @returns `a >= b`
27
- */
28
- protected versionGreaterThanOrEqualTo(a: string, b: string): boolean;
29
- protected supportedVscodeApiSatisfies(vscodeApiRange: string): boolean;
30
- }
1
+ import { VSXAllVersions, VSXExtensionRaw, VSXSearchEntry } from './ovsx-types';
2
+ export declare const OVSXApiFilter: unique symbol;
3
+ /**
4
+ * Filter various data types based on a pre-defined supported VS Code API version.
5
+ */
6
+ export interface OVSXApiFilter {
7
+ supportedApiVersion: string;
8
+ /**
9
+ * Get the latest compatible extension version:
10
+ * - A builtin extension is fetched based on the extension version which matches the API.
11
+ * - An extension satisfies compatibility if its `engines.vscode` version is supported.
12
+ *
13
+ * @param extensionId the extension id.
14
+ * @returns the data for the latest compatible extension version if available, else `undefined`.
15
+ */
16
+ getLatestCompatibleExtension(extensions: VSXExtensionRaw[]): VSXExtensionRaw | undefined;
17
+ getLatestCompatibleVersion(searchEntry: VSXSearchEntry): VSXAllVersions | undefined;
18
+ }
19
+ export declare class OVSXApiFilterImpl implements OVSXApiFilter {
20
+ supportedApiVersion: string;
21
+ constructor(supportedApiVersion: string);
22
+ getLatestCompatibleExtension(extensions: VSXExtensionRaw[]): VSXExtensionRaw | undefined;
23
+ getLatestCompatibleVersion(searchEntry: VSXSearchEntry): VSXAllVersions | undefined;
24
+ protected isBuiltinNamespace(namespace: string): boolean;
25
+ /**
26
+ * @returns `a >= b`
27
+ */
28
+ protected versionGreaterThanOrEqualTo(a: string, b: string): boolean;
29
+ protected supportedVscodeApiSatisfies(vscodeApiRange: string): boolean;
30
+ }
31
31
  //# sourceMappingURL=ovsx-api-filter.d.ts.map
@@ -1,74 +1,74 @@
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.OVSXApiFilterImpl = exports.OVSXApiFilter = void 0;
19
- const semver = require("semver");
20
- const ovsx_types_1 = require("./ovsx-types");
21
- exports.OVSXApiFilter = Symbol('OVSXApiFilter');
22
- class OVSXApiFilterImpl {
23
- constructor(supportedApiVersion) {
24
- this.supportedApiVersion = supportedApiVersion;
25
- }
26
- getLatestCompatibleExtension(extensions) {
27
- if (extensions.length === 0) {
28
- return;
29
- }
30
- else if (this.isBuiltinNamespace(extensions[0].namespace.toLowerCase())) {
31
- return extensions.find(extension => this.versionGreaterThanOrEqualTo(extension.version, this.supportedApiVersion));
32
- }
33
- else {
34
- return extensions.find(extension => { var _a, _b; return this.supportedVscodeApiSatisfies((_b = (_a = extension.engines) === null || _a === void 0 ? void 0 : _a.vscode) !== null && _b !== void 0 ? _b : '*'); });
35
- }
36
- }
37
- getLatestCompatibleVersion(searchEntry) {
38
- function getLatestCompatibleVersion(predicate) {
39
- if (searchEntry.allVersions) {
40
- return searchEntry.allVersions.find(predicate);
41
- }
42
- // If the allVersions field is missing then try to use the
43
- // searchEntry as VSXAllVersions and check if it's compatible:
44
- if (predicate(searchEntry)) {
45
- return searchEntry;
46
- }
47
- }
48
- if (this.isBuiltinNamespace(searchEntry.namespace)) {
49
- return getLatestCompatibleVersion(allVersions => this.versionGreaterThanOrEqualTo(allVersions.version, this.supportedApiVersion));
50
- }
51
- else {
52
- return getLatestCompatibleVersion(allVersions => { var _a, _b; return this.supportedVscodeApiSatisfies((_b = (_a = allVersions.engines) === null || _a === void 0 ? void 0 : _a.vscode) !== null && _b !== void 0 ? _b : '*'); });
53
- }
54
- }
55
- isBuiltinNamespace(namespace) {
56
- return ovsx_types_1.VSXBuiltinNamespaces.is(namespace);
57
- }
58
- /**
59
- * @returns `a >= b`
60
- */
61
- versionGreaterThanOrEqualTo(a, b) {
62
- const versionA = semver.clean(a);
63
- const versionB = semver.clean(b);
64
- if (!versionA || !versionB) {
65
- return false;
66
- }
67
- return semver.lte(versionA, versionB);
68
- }
69
- supportedVscodeApiSatisfies(vscodeApiRange) {
70
- return semver.satisfies(this.supportedApiVersion, vscodeApiRange);
71
- }
72
- }
73
- exports.OVSXApiFilterImpl = OVSXApiFilterImpl;
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.OVSXApiFilterImpl = exports.OVSXApiFilter = void 0;
19
+ const semver = require("semver");
20
+ const ovsx_types_1 = require("./ovsx-types");
21
+ exports.OVSXApiFilter = Symbol('OVSXApiFilter');
22
+ class OVSXApiFilterImpl {
23
+ constructor(supportedApiVersion) {
24
+ this.supportedApiVersion = supportedApiVersion;
25
+ }
26
+ getLatestCompatibleExtension(extensions) {
27
+ if (extensions.length === 0) {
28
+ return;
29
+ }
30
+ else if (this.isBuiltinNamespace(extensions[0].namespace.toLowerCase())) {
31
+ return extensions.find(extension => this.versionGreaterThanOrEqualTo(extension.version, this.supportedApiVersion));
32
+ }
33
+ else {
34
+ return extensions.find(extension => { var _a, _b; return this.supportedVscodeApiSatisfies((_b = (_a = extension.engines) === null || _a === void 0 ? void 0 : _a.vscode) !== null && _b !== void 0 ? _b : '*'); });
35
+ }
36
+ }
37
+ getLatestCompatibleVersion(searchEntry) {
38
+ function getLatestCompatibleVersion(predicate) {
39
+ if (searchEntry.allVersions) {
40
+ return searchEntry.allVersions.find(predicate);
41
+ }
42
+ // If the allVersions field is missing then try to use the
43
+ // searchEntry as VSXAllVersions and check if it's compatible:
44
+ if (predicate(searchEntry)) {
45
+ return searchEntry;
46
+ }
47
+ }
48
+ if (this.isBuiltinNamespace(searchEntry.namespace)) {
49
+ return getLatestCompatibleVersion(allVersions => this.versionGreaterThanOrEqualTo(allVersions.version, this.supportedApiVersion));
50
+ }
51
+ else {
52
+ return getLatestCompatibleVersion(allVersions => { var _a, _b; return this.supportedVscodeApiSatisfies((_b = (_a = allVersions.engines) === null || _a === void 0 ? void 0 : _a.vscode) !== null && _b !== void 0 ? _b : '*'); });
53
+ }
54
+ }
55
+ isBuiltinNamespace(namespace) {
56
+ return ovsx_types_1.VSXBuiltinNamespaces.is(namespace);
57
+ }
58
+ /**
59
+ * @returns `a >= b`
60
+ */
61
+ versionGreaterThanOrEqualTo(a, b) {
62
+ const versionA = semver.clean(a);
63
+ const versionB = semver.clean(b);
64
+ if (!versionA || !versionB) {
65
+ return false;
66
+ }
67
+ return semver.lte(versionA, versionB);
68
+ }
69
+ supportedVscodeApiSatisfies(vscodeApiRange) {
70
+ return semver.satisfies(this.supportedApiVersion, vscodeApiRange);
71
+ }
72
+ }
73
+ exports.OVSXApiFilterImpl = OVSXApiFilterImpl;
74
74
  //# sourceMappingURL=ovsx-api-filter.js.map
@@ -1,18 +1,18 @@
1
- import { OVSXClient, VSXQueryOptions, VSXQueryResult, VSXSearchOptions, VSXSearchResult } from './ovsx-types';
2
- import { RequestService } from '@theia/request';
3
- export declare class OVSXHttpClient implements OVSXClient {
4
- protected vsxRegistryUrl: string;
5
- protected requestService: RequestService;
6
- /**
7
- * @param requestService
8
- * @returns factory that will cache clients based on the requested input URL.
9
- */
10
- static createClientFactory(requestService: RequestService): (url: string) => OVSXClient;
11
- constructor(vsxRegistryUrl: string, requestService: RequestService);
12
- search(searchOptions?: VSXSearchOptions): Promise<VSXSearchResult>;
13
- query(queryOptions?: VSXQueryOptions): Promise<VSXQueryResult>;
14
- protected requestJson<R>(url: string): Promise<R>;
15
- protected buildUrl(url: string, query?: object): string;
16
- protected buildQueryString(searchQuery?: object): string;
17
- }
1
+ import { OVSXClient, VSXQueryOptions, VSXQueryResult, VSXSearchOptions, VSXSearchResult } from './ovsx-types';
2
+ import { RequestService } from '@theia/request';
3
+ export declare class OVSXHttpClient implements OVSXClient {
4
+ protected vsxRegistryUrl: string;
5
+ protected requestService: RequestService;
6
+ /**
7
+ * @param requestService
8
+ * @returns factory that will cache clients based on the requested input URL.
9
+ */
10
+ static createClientFactory(requestService: RequestService): (url: string) => OVSXClient;
11
+ constructor(vsxRegistryUrl: string, requestService: RequestService);
12
+ search(searchOptions?: VSXSearchOptions): Promise<VSXSearchResult>;
13
+ query(queryOptions?: VSXQueryOptions): Promise<VSXQueryResult>;
14
+ protected requestJson<R>(url: string): Promise<R>;
15
+ protected buildUrl(url: string, query?: object): string;
16
+ protected buildQueryString(searchQuery?: object): string;
17
+ }
18
18
  //# sourceMappingURL=ovsx-http-client.d.ts.map
@@ -1,83 +1,83 @@
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.OVSXHttpClient = void 0;
19
- const request_1 = require("@theia/request");
20
- class OVSXHttpClient {
21
- constructor(vsxRegistryUrl, requestService) {
22
- this.vsxRegistryUrl = vsxRegistryUrl;
23
- this.requestService = requestService;
24
- }
25
- /**
26
- * @param requestService
27
- * @returns factory that will cache clients based on the requested input URL.
28
- */
29
- static createClientFactory(requestService) {
30
- // eslint-disable-next-line no-null/no-null
31
- const cachedClients = Object.create(null);
32
- return url => { var _a; return (_a = cachedClients[url]) !== null && _a !== void 0 ? _a : (cachedClients[url] = new this(url, requestService)); };
33
- }
34
- async search(searchOptions) {
35
- try {
36
- return await this.requestJson(this.buildUrl('api/-/search', searchOptions));
37
- }
38
- catch (err) {
39
- return {
40
- error: (err === null || err === void 0 ? void 0 : err.message) || String(err),
41
- offset: -1,
42
- extensions: []
43
- };
44
- }
45
- }
46
- async query(queryOptions) {
47
- try {
48
- return await this.requestJson(this.buildUrl('api/-/query', queryOptions));
49
- }
50
- catch (error) {
51
- console.warn(error);
52
- return {
53
- extensions: []
54
- };
55
- }
56
- }
57
- async requestJson(url) {
58
- return request_1.RequestContext.asJson(await this.requestService.request({
59
- url,
60
- headers: { 'Accept': 'application/json' }
61
- }));
62
- }
63
- buildUrl(url, query) {
64
- return new URL(`${url}${this.buildQueryString(query)}`, this.vsxRegistryUrl).toString();
65
- }
66
- buildQueryString(searchQuery) {
67
- if (!searchQuery) {
68
- return '';
69
- }
70
- let queryString = '';
71
- for (const [key, value] of Object.entries(searchQuery)) {
72
- if (typeof value === 'string') {
73
- queryString += `&${key}=${encodeURIComponent(value)}`;
74
- }
75
- else if (typeof value === 'boolean' || typeof value === 'number') {
76
- queryString += `&${key}=${value}`;
77
- }
78
- }
79
- return queryString && '?' + queryString.slice(1);
80
- }
81
- }
82
- exports.OVSXHttpClient = OVSXHttpClient;
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.OVSXHttpClient = void 0;
19
+ const request_1 = require("@theia/request");
20
+ class OVSXHttpClient {
21
+ constructor(vsxRegistryUrl, requestService) {
22
+ this.vsxRegistryUrl = vsxRegistryUrl;
23
+ this.requestService = requestService;
24
+ }
25
+ /**
26
+ * @param requestService
27
+ * @returns factory that will cache clients based on the requested input URL.
28
+ */
29
+ static createClientFactory(requestService) {
30
+ // eslint-disable-next-line no-null/no-null
31
+ const cachedClients = Object.create(null);
32
+ return url => { var _a; return (_a = cachedClients[url]) !== null && _a !== void 0 ? _a : (cachedClients[url] = new this(url, requestService)); };
33
+ }
34
+ async search(searchOptions) {
35
+ try {
36
+ return await this.requestJson(this.buildUrl('api/-/search', searchOptions));
37
+ }
38
+ catch (err) {
39
+ return {
40
+ error: (err === null || err === void 0 ? void 0 : err.message) || String(err),
41
+ offset: -1,
42
+ extensions: []
43
+ };
44
+ }
45
+ }
46
+ async query(queryOptions) {
47
+ try {
48
+ return await this.requestJson(this.buildUrl('api/-/query', queryOptions));
49
+ }
50
+ catch (error) {
51
+ console.warn(error);
52
+ return {
53
+ extensions: []
54
+ };
55
+ }
56
+ }
57
+ async requestJson(url) {
58
+ return request_1.RequestContext.asJson(await this.requestService.request({
59
+ url,
60
+ headers: { 'Accept': 'application/json' }
61
+ }));
62
+ }
63
+ buildUrl(url, query) {
64
+ return new URL(`${url}${this.buildQueryString(query)}`, this.vsxRegistryUrl).toString();
65
+ }
66
+ buildQueryString(searchQuery) {
67
+ if (!searchQuery) {
68
+ return '';
69
+ }
70
+ let queryString = '';
71
+ for (const [key, value] of Object.entries(searchQuery)) {
72
+ if (typeof value === 'string') {
73
+ queryString += `&${key}=${encodeURIComponent(value)}`;
74
+ }
75
+ else if (typeof value === 'boolean' || typeof value === 'number') {
76
+ queryString += `&${key}=${value}`;
77
+ }
78
+ }
79
+ return queryString && '?' + queryString.slice(1);
80
+ }
81
+ }
82
+ exports.OVSXHttpClient = OVSXHttpClient;
83
83
  //# sourceMappingURL=ovsx-http-client.js.map