@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.
- package/README.md +61 -61
- package/lib/index.d.ts +6 -6
- package/lib/index.js +30 -30
- package/lib/ovsx-api-filter.d.ts +30 -30
- package/lib/ovsx-api-filter.js +73 -73
- package/lib/ovsx-http-client.d.ts +17 -17
- package/lib/ovsx-http-client.js +82 -82
- package/lib/ovsx-mock-client.d.ts +43 -43
- package/lib/ovsx-mock-client.js +168 -168
- package/lib/ovsx-router-client.d.ts +68 -68
- package/lib/ovsx-router-client.js +169 -169
- package/lib/ovsx-router-client.spec-data.d.ts +10 -10
- package/lib/ovsx-router-client.spec-data.js +66 -66
- package/lib/ovsx-router-client.spec.d.ts +1 -1
- package/lib/ovsx-router-client.spec.js +107 -107
- package/lib/ovsx-router-filters/abstract-reg-exp-filter.d.ts +5 -5
- package/lib/ovsx-router-filters/abstract-reg-exp-filter.js +27 -27
- package/lib/ovsx-router-filters/extension-id-matches-filter.d.ts +7 -7
- package/lib/ovsx-router-filters/extension-id-matches-filter.js +33 -33
- package/lib/ovsx-router-filters/index.d.ts +2 -2
- package/lib/ovsx-router-filters/index.js +22 -22
- package/lib/ovsx-router-filters/request-contains-filter.d.ts +8 -8
- package/lib/ovsx-router-filters/request-contains-filter.js +35 -35
- package/lib/ovsx-types.d.ts +212 -212
- package/lib/ovsx-types.js +74 -74
- package/lib/types.d.ts +1 -1
- package/lib/types.js +17 -17
- package/package.json +3 -3
- package/src/index.ts +22 -22
- package/src/ovsx-api-filter.ts +91 -91
- package/src/ovsx-http-client.ts +85 -85
- package/src/ovsx-mock-client.ts +182 -182
- package/src/ovsx-router-client.spec-data.ts +68 -68
- package/src/ovsx-router-client.spec.ts +126 -126
- package/src/ovsx-router-client.ts +248 -248
- package/src/ovsx-router-filters/abstract-reg-exp-filter.ts +26 -26
- package/src/ovsx-router-filters/extension-id-matches-filter.ts +32 -32
- package/src/ovsx-router-filters/index.ts +18 -18
- package/src/ovsx-router-filters/request-contains-filter.ts +35 -35
- package/src/ovsx-types.ts +268 -268
- package/src/types.ts +17 -17
|
@@ -1,126 +1,126 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2023 Ericsson and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
/* eslint-disable no-null/no-null */
|
|
18
|
-
|
|
19
|
-
import { OVSXRouterClient } from './ovsx-router-client';
|
|
20
|
-
import { testClientProvider, registries, filterFactories } from './ovsx-router-client.spec-data';
|
|
21
|
-
import { ExtensionLike } from './ovsx-types';
|
|
22
|
-
import assert = require('assert');
|
|
23
|
-
|
|
24
|
-
describe('OVSXRouterClient', async () => {
|
|
25
|
-
|
|
26
|
-
const router = await OVSXRouterClient.FromConfig(
|
|
27
|
-
{
|
|
28
|
-
registries,
|
|
29
|
-
use: ['internal', 'public', 'third'],
|
|
30
|
-
rules: [{
|
|
31
|
-
ifRequestContains: /\btestFullStop\b/.source,
|
|
32
|
-
use: null,
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
ifRequestContains: /\bsecret\b/.source,
|
|
36
|
-
use: 'internal'
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
ifExtensionIdMatches: /^some\./.source,
|
|
40
|
-
use: 'internal'
|
|
41
|
-
}]
|
|
42
|
-
},
|
|
43
|
-
testClientProvider,
|
|
44
|
-
filterFactories,
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
it('test query agglomeration', async () => {
|
|
48
|
-
const result = await router.query({ namespaceName: 'other' });
|
|
49
|
-
assert.deepStrictEqual(result.extensions.map(ExtensionLike.id), [
|
|
50
|
-
// note the order: plugins from "internal" first then from "public"
|
|
51
|
-
'other.d',
|
|
52
|
-
'other.e'
|
|
53
|
-
]);
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it('test query request filtering', async () => {
|
|
57
|
-
const result = await router.query({ namespaceName: 'secret' });
|
|
58
|
-
assert.deepStrictEqual(result.extensions.map(ExtensionLike.id), [
|
|
59
|
-
// 'secret.w' from 'public' shouldn't be returned
|
|
60
|
-
'secret.x',
|
|
61
|
-
'secret.y',
|
|
62
|
-
'secret.z'
|
|
63
|
-
]);
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it('test query result filtering', async () => {
|
|
67
|
-
const result = await router.query({ namespaceName: 'some' });
|
|
68
|
-
assert.deepStrictEqual(result.extensions.map(ExtensionLike.idWithVersion), [
|
|
69
|
-
// no entry for the `some` namespace should be returned from the `public` registry
|
|
70
|
-
'some.a@1.0.0'
|
|
71
|
-
]);
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it('test query full stop', async () => {
|
|
75
|
-
const result = await router.query({ extensionId: 'testFullStop.c' });
|
|
76
|
-
assert.deepStrictEqual(result.extensions.length, 0);
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it('test search agglomeration', async () => {
|
|
80
|
-
const result = await router.search({ query: 'other.' });
|
|
81
|
-
assert.deepStrictEqual(result.extensions.map(ExtensionLike.id), [
|
|
82
|
-
// note the order: plugins from "internal" first then from "public"
|
|
83
|
-
'other.d',
|
|
84
|
-
'other.e'
|
|
85
|
-
]);
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
it('test search request filtering', async () => {
|
|
89
|
-
const result = await router.search({ query: 'secret.' });
|
|
90
|
-
assert.deepStrictEqual(result.extensions.map(ExtensionLike.id), [
|
|
91
|
-
// 'secret.w' from 'public' shouldn't be returned
|
|
92
|
-
'secret.x',
|
|
93
|
-
'secret.y',
|
|
94
|
-
'secret.z'
|
|
95
|
-
]);
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
it('test search result filtering', async () => {
|
|
99
|
-
const result = await router.search({ query: 'some.' });
|
|
100
|
-
assert.deepStrictEqual(result.extensions.map(ExtensionLike.idWithVersion), [
|
|
101
|
-
// no entry for the `some` namespace should be returned from the `public` registry
|
|
102
|
-
'some.a@1.0.0'
|
|
103
|
-
]);
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
it('test search full stop', async () => {
|
|
107
|
-
const result = await router.search({ query: 'testFullStop.c' });
|
|
108
|
-
assert.deepStrictEqual(result.extensions.length, 0);
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it('test config with unknown conditions', async () => {
|
|
112
|
-
const clientPromise = OVSXRouterClient.FromConfig(
|
|
113
|
-
{
|
|
114
|
-
use: 'not relevant',
|
|
115
|
-
rules: [{
|
|
116
|
-
ifRequestContains: /.*/.source,
|
|
117
|
-
unknownCondition: /should cause an error to be thrown/.source,
|
|
118
|
-
use: ['internal', 'public']
|
|
119
|
-
}]
|
|
120
|
-
},
|
|
121
|
-
testClientProvider,
|
|
122
|
-
filterFactories
|
|
123
|
-
);
|
|
124
|
-
assert.rejects(clientPromise, /^Error: unknown conditions:/);
|
|
125
|
-
});
|
|
126
|
-
});
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2023 Ericsson and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
/* eslint-disable no-null/no-null */
|
|
18
|
+
|
|
19
|
+
import { OVSXRouterClient } from './ovsx-router-client';
|
|
20
|
+
import { testClientProvider, registries, filterFactories } from './ovsx-router-client.spec-data';
|
|
21
|
+
import { ExtensionLike } from './ovsx-types';
|
|
22
|
+
import assert = require('assert');
|
|
23
|
+
|
|
24
|
+
describe('OVSXRouterClient', async () => {
|
|
25
|
+
|
|
26
|
+
const router = await OVSXRouterClient.FromConfig(
|
|
27
|
+
{
|
|
28
|
+
registries,
|
|
29
|
+
use: ['internal', 'public', 'third'],
|
|
30
|
+
rules: [{
|
|
31
|
+
ifRequestContains: /\btestFullStop\b/.source,
|
|
32
|
+
use: null,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
ifRequestContains: /\bsecret\b/.source,
|
|
36
|
+
use: 'internal'
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
ifExtensionIdMatches: /^some\./.source,
|
|
40
|
+
use: 'internal'
|
|
41
|
+
}]
|
|
42
|
+
},
|
|
43
|
+
testClientProvider,
|
|
44
|
+
filterFactories,
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
it('test query agglomeration', async () => {
|
|
48
|
+
const result = await router.query({ namespaceName: 'other' });
|
|
49
|
+
assert.deepStrictEqual(result.extensions.map(ExtensionLike.id), [
|
|
50
|
+
// note the order: plugins from "internal" first then from "public"
|
|
51
|
+
'other.d',
|
|
52
|
+
'other.e'
|
|
53
|
+
]);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('test query request filtering', async () => {
|
|
57
|
+
const result = await router.query({ namespaceName: 'secret' });
|
|
58
|
+
assert.deepStrictEqual(result.extensions.map(ExtensionLike.id), [
|
|
59
|
+
// 'secret.w' from 'public' shouldn't be returned
|
|
60
|
+
'secret.x',
|
|
61
|
+
'secret.y',
|
|
62
|
+
'secret.z'
|
|
63
|
+
]);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('test query result filtering', async () => {
|
|
67
|
+
const result = await router.query({ namespaceName: 'some' });
|
|
68
|
+
assert.deepStrictEqual(result.extensions.map(ExtensionLike.idWithVersion), [
|
|
69
|
+
// no entry for the `some` namespace should be returned from the `public` registry
|
|
70
|
+
'some.a@1.0.0'
|
|
71
|
+
]);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('test query full stop', async () => {
|
|
75
|
+
const result = await router.query({ extensionId: 'testFullStop.c' });
|
|
76
|
+
assert.deepStrictEqual(result.extensions.length, 0);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('test search agglomeration', async () => {
|
|
80
|
+
const result = await router.search({ query: 'other.' });
|
|
81
|
+
assert.deepStrictEqual(result.extensions.map(ExtensionLike.id), [
|
|
82
|
+
// note the order: plugins from "internal" first then from "public"
|
|
83
|
+
'other.d',
|
|
84
|
+
'other.e'
|
|
85
|
+
]);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('test search request filtering', async () => {
|
|
89
|
+
const result = await router.search({ query: 'secret.' });
|
|
90
|
+
assert.deepStrictEqual(result.extensions.map(ExtensionLike.id), [
|
|
91
|
+
// 'secret.w' from 'public' shouldn't be returned
|
|
92
|
+
'secret.x',
|
|
93
|
+
'secret.y',
|
|
94
|
+
'secret.z'
|
|
95
|
+
]);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('test search result filtering', async () => {
|
|
99
|
+
const result = await router.search({ query: 'some.' });
|
|
100
|
+
assert.deepStrictEqual(result.extensions.map(ExtensionLike.idWithVersion), [
|
|
101
|
+
// no entry for the `some` namespace should be returned from the `public` registry
|
|
102
|
+
'some.a@1.0.0'
|
|
103
|
+
]);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it('test search full stop', async () => {
|
|
107
|
+
const result = await router.search({ query: 'testFullStop.c' });
|
|
108
|
+
assert.deepStrictEqual(result.extensions.length, 0);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it('test config with unknown conditions', async () => {
|
|
112
|
+
const clientPromise = OVSXRouterClient.FromConfig(
|
|
113
|
+
{
|
|
114
|
+
use: 'not relevant',
|
|
115
|
+
rules: [{
|
|
116
|
+
ifRequestContains: /.*/.source,
|
|
117
|
+
unknownCondition: /should cause an error to be thrown/.source,
|
|
118
|
+
use: ['internal', 'public']
|
|
119
|
+
}]
|
|
120
|
+
},
|
|
121
|
+
testClientProvider,
|
|
122
|
+
filterFactories
|
|
123
|
+
);
|
|
124
|
+
assert.rejects(clientPromise, /^Error: unknown conditions:/);
|
|
125
|
+
});
|
|
126
|
+
});
|