Skip to content

domain/policy/policy-service

Defined in: app/src/domain/policy/policy-service.ts:66

Merges the values of all policy providers, validates them against the policy definitions and answers which value applies and whether a setting is locked.

Precedence: mandatory before recommended, and within a level machine before user. Sensitive policies are only applied from machine-wide mandatory sources. Invalid values are ignored and reported, never guessed.

new PolicyService(definitions, providers, logger, cache?): PolicyService

Defined in: app/src/domain/policy/policy-service.ts:88

readonly PolicyDefinition<unknown>[]

All known policies, including setting policies.

readonly PolicyProvider[]

Sources for the current platform.

Logger

Receives read problems.

PolicyCache

Optional fallback for providers that fail at startup.

PolicyService

readonly onDidChange: Event<readonly string[]>

Defined in: app/src/domain/policy/policy-service.ts:80

Fires with the names of policies whose effective value changed.

applyCached(): boolean

Defined in: app/src/domain/policy/policy-service.ts:123

Applies the last known policies from the cache, for the time until fresh values have been read.

boolean

Whether the cache held a state; without one, nothing changes.

definitionForSetting(settingKey): PolicyDefinition<unknown> | undefined

Defined in: app/src/domain/policy/policy-service.ts:185

The policy that belongs to a setting.

string

A setting key.

PolicyDefinition<unknown> | undefined

dispose(): void

Defined in: app/src/domain/policy/policy-service.ts:209

Removes all listeners.

void

Disposable.dispose

getMandatory(name): EffectivePolicy | undefined

Defined in: app/src/domain/policy/policy-service.ts:156

The value that a mandatory policy forces, if any.

string

Policy name.

EffectivePolicy | undefined

getRecommended(name): EffectivePolicy | undefined

Defined in: app/src/domain/policy/policy-service.ts:177

The recommended default from policy, if any.

string

Policy name.

EffectivePolicy | undefined

isLocked(settingKey): boolean

Defined in: app/src/domain/policy/policy-service.ts:193

Tells whether a mandatory policy locks a setting.

string

A setting key.

boolean

mandatoryValue<T>(definition): T | undefined

Defined in: app/src/domain/policy/policy-service.ts:164

The value that a mandatory policy forces, typed by its definition.

T

PolicyDefinition<T>

The policy, as registered with this service.

T | undefined

readErrors(): readonly PolicyReadError[]

Defined in: app/src/domain/policy/policy-service.ts:204

Problems from the last refresh.

readonly PolicyReadError[]

refresh(): Promise<readonly string[]>

Defined in: app/src/domain/policy/policy-service.ts:109

Reads all providers and applies the result. Calls made while a read is running share it.

Promise<readonly string[]>

The names of policies whose effective value changed.

statuses(): readonly PolicyStatus[]

Defined in: app/src/domain/policy/policy-service.ts:199

Every value read in the last refresh, with its state.

readonly PolicyStatus[]

Defined in: app/src/domain/policy/policy-service.ts:38

An applied policy value.

readonly scope: PolicyScope

Defined in: app/src/domain/policy/policy-service.ts:40

readonly source: string

Defined in: app/src/domain/policy/policy-service.ts:41

readonly value: unknown

Defined in: app/src/domain/policy/policy-service.ts:39


Defined in: app/src/domain/policy/policy-service.ts:45

Stores the last known raw values, used when a provider cannot be read at startup.

read(): readonly RawPolicyValue[] | undefined

Defined in: app/src/domain/policy/policy-service.ts:47

Returns the cached values, or undefined when there is no usable cache.

readonly RawPolicyValue[] | undefined

write(values): void

Defined in: app/src/domain/policy/policy-service.ts:52

Replaces the cached values.

readonly RawPolicyValue[]

The values just read from the providers.

void


Defined in: app/src/domain/policy/policy-service.ts:26

One policy value with the reason it was or was not applied.

readonly level: PolicyLevel

Defined in: app/src/domain/policy/policy-service.ts:29

readonly optional message?: string

Defined in: app/src/domain/policy/policy-service.ts:34

Explanation for states other than applied.

readonly name: string

Defined in: app/src/domain/policy/policy-service.ts:27

readonly scope: PolicyScope

Defined in: app/src/domain/policy/policy-service.ts:30

readonly source: string

Defined in: app/src/domain/policy/policy-service.ts:31

readonly state: PolicyState

Defined in: app/src/domain/policy/policy-service.ts:32

readonly value: unknown

Defined in: app/src/domain/policy/policy-service.ts:28

PolicyState = "applied" | "overridden" | "invalid" | "unknown" | "not-allowed-as-recommended" | "sensitive-requires-machine"

Defined in: app/src/domain/policy/policy-service.ts:17

Outcome for one policy value, as listed on the diagnostics page.

const PolicyServiceToken: Token<PolicyService>

Defined in: app/src/domain/policy/policy-service.ts:56

Token for the PolicyService.