All files / platform/core/src/services/CustomizationService customizationUrlTypes.ts

0% Statements 0/0
0% Branches 0/0
0% Functions 0/0
0% Lines 0/0

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60                                                                                                                       
import type { CustomizationUrlPolicy } from './customizationUrlDefaults';
import type { ValidatedCustomization } from './validate';
import type { CustomizationEntries } from './types';
 
/**
 * The value accepted by any single customization phase block. It is whatever
 * {@link CustomizationService.setCustomizations} accepts:
 *   - an object map of `customizationId -> customization` (with optional
 *     immutability-helper commands like `$set` / `$apply` / `$splice`), where
 *     ids registered in `AppTypes.Customizations` are checked against their
 *     declared value type, or
 *   - an array that mixes string references (extension module ids resolved via
 *     the ExtensionManager) and inline object maps.
 */
export type CustomizationPhaseInput = string[] | CustomizationEntries;
 
/**
 * Mode-phase customizations, keyed by mode. The reserved `*` key (see
 * `GENERAL_MODE_KEY`) is the "general" block applied to every mode FIRST; any
 * other key is matched against the entered mode's `id` / `routeName` and applied
 * AFTER the general block, so a single mode can override the general values.
 */
export type ModePhaseCustomizations = Record<string, CustomizationPhaseInput>;
 
/**
 * Phase-tagged customization payload. The same shape is used by:
 *   - URL-loaded customization modules (`?customization=` JSONC files), and
 *   - the `appConfig.customizationService` structured config.
 *
 * Each block is applied at a distinct point in the app lifecycle so ordering is
 * deterministic regardless of when extensions / modes load:
 *   - `requires`     — other URL customization modules to resolve first.
 *   - `bootstrap`    — applied (Global scope) BEFORE extensions register.
 *   - `global`       — applied (Global scope) AFTER extensions register / init.
 *   - `mode`         — applied (Mode scope) on every mode enter; general first,
 *                      then the entered mode's specific block.
 */
export interface PhasedCustomizationConfig {
  requires?: string | string[];
  bootstrap?: CustomizationPhaseInput;
  global?: CustomizationPhaseInput;
  mode?: ModePhaseCustomizations;
}
 
export interface CustomizationModule extends PhasedCustomizationConfig {
  [key: string]: any;
}
 
export interface LoadedCustomization {
  request: ValidatedCustomization;
  module: CustomizationModule;
  url: string;
}
 
export interface LoadOptions {
  policy?: CustomizationUrlPolicy;
  importFn?: (url: string) => Promise<any>;
  logger?: { warn: (...args: any[]) => void; error: (...args: any[]) => void };
}