1
>
/*---------------------------------------------------------------------------------------------
marketplaceReference.ts
2
>
* Copyright (c) Microsoft Corporation. All rights reserved.
3
>
* Licensed under the MIT License. See License.txt in the project root for license information.
4
>
*--------------------------------------------------------------------------------------------*/
5
>
6
>
import { URI } from '../../../../../base/common/uri.js';
7
>
import { IConfigurationService } from '../../../../../platform/configuration/common/configuration.js';
8
>
import { ChatConfiguration } from '../constants.js';
9
>
10
>
export { extraKnownMarketplacesToConfigDict } from '../../../../../base/common/managedSettings.js';
11
>
12
>
export const enum MarketplaceReferenceKind {
13
>
GitHubShorthand = 'githubShorthand',
14
>
GitUri = 'gitUri',
15
>
LocalFileUri = 'localFileUri',
16
>
}
17
>
18
>
export interface IMarketplaceReference {
19
>
readonly rawValue: string;
20
>
readonly displayLabel: string;
21
>
readonly cloneUrl: string;
22
>
readonly canonicalId: string;
23
>
readonly cacheSegments: readonly string[];
24
>
readonly kind: MarketplaceReferenceKind;
25
>
readonly ref?: string;
26
>
readonly githubRepo?: string;
27
>
readonly localRepositoryUri?: URI;
28
>
}
29
>
30
>
/**
31
>
* The two configuration layers behind plugin marketplaces:
32
>
* - `userValues` — what's stored at {@link ChatConfiguration.PluginMarketplaces}
33
>
* (default + user). Writable by the user.
34
>
* - `extraValues` — what's delivered via the `ChatExtraMarketplaces` enterprise
35
>
* policy into {@link ChatConfiguration.ExtraMarketplaces}. Read-only.
36
>
*
37
>
* Entries may be strings (`<owner>/<repo>` or git URIs) or, in the policy case,
38
>
* {@link IExtraMarketplaceObjectEntry} objects — both shapes flow through
39
>
* {@link parseMarketplaceReferences}.
40
>
*/
41
>
export interface IConfiguredMarketplaces {
42
>
readonly userValues: readonly unknown[];
43
>
readonly extraValues: readonly unknown[];
44
>
readonly effectiveValues: readonly unknown[];
45
>
}
46
>
47
>
/** Shorthand-or-URI regex used to detect GitHub `owner/repo[#ref]` entries. */
48
>
const _githubShorthandRe = /^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+(?:#.+)?$/;
49
>
50
>
export function readConfiguredMarketplaces(configurationService: IConfigurationService): IConfiguredMarketplaces {
51
const userValues = configurationService.getValue<(string | object)[]>(ChatConfiguration.PluginMarketplaces) ?? [];
52