diff --git a/AGENTS.md b/AGENTS.md
index 798fb430..84d4a2b4 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -108,8 +108,11 @@ The engine (`IdLE.Core`) must **not** depend on:
Use the single event contract:
-- `Context.EventSink.WriteEvent(Type, Message, StepName, Data)`
+- `Context.EventSink.WriteEvent(Type, Message, StepName, Data[, Level])`
- This is the runtime contract used by steps/providers through the execution context.
+- `Type` follows the namespace scheme (`IdLE..` first-party, `.IdLE..` extensions);
+ severity goes into `Level` (`Information` default, `Warning`, `Error`), never into `Type`.
+- New or renamed first-party event types MUST be listed in `docs/extend/events.md` (type, level, data fields).
- External event sinks (host implementations) must follow the guidance in `docs/extend/events.md` (object-based event payload), but the engine-facing API remains `Context.EventSink.WriteEvent(...)`.
Do not introduce alternative eventing APIs unless explicitly planned and documented.
diff --git a/docs/extend/events.md b/docs/extend/events.md
index 320944f0..f4c15869 100644
--- a/docs/extend/events.md
+++ b/docs/extend/events.md
@@ -24,12 +24,12 @@ This document covers:
- Why events exist in IdLE
- Where and when events are created
- How events are collected and exposed
+- Event types, levels and data fields
- Responsibilities of engine, steps, and host environments
- Recommended usage patterns
Out of scope:
-- Detailed API or property reference of event objects
- Logging frameworks or telemetry backends
- Implementation details of specific steps
@@ -61,24 +61,130 @@ Those decisions belong to the **host environment**.
Events are created at well-defined points during plan execution:
-- **Run-level events**
- - `RunStarted`
- - `RunCompleted`
-
-- **Step-level events**
- - `StepStarted`
- - `StepCompleted`
- - `StepFailed`
- - `StepSkipped`
-
-- **Custom events**
- - Explicitly emitted by steps (for example via an `EmitEvent` step)
+- **Run-level events** (`IdLE.Run.*`) when a plan starts and finishes
+- **Step-level events** (`IdLE.Step.*`, `IdLE.OnFailure.*`) when a step starts, completes, fails or is skipped
+- **Domain events** emitted by steps and providers (for example `IdLE.Step.DirectorySync.Completed`)
+- **Workflow-defined events** from `PreconditionEvent` and the `IdLE.Step.EmitEvent` step
All events share a common intent:
> describe *what happened*, not *how it should be presented*.
---
+### Event object
+
+Every event is an object with `PSTypeName = 'IdLE.Event'`:
+
+| Property | Description |
+| --- | --- |
+| `TimestampUtc` | UTC timestamp. |
+| `Type` | What happened (see [Event types](#event-types)). |
+| `Level` | How severe it is: `Information`, `Warning` or `Error`. |
+| `Message` | Human-readable message. Do not parse it; use `Type` and `Data`. |
+| `CorrelationId` | Correlation ID of the request. |
+| `Actor` | Actor of the request. |
+| `StepName` | Name of the step (empty for run-level events). |
+| `Data` | Optional hashtable with structured details (redacted at output boundaries). |
+
+Steps and providers write events through the execution context:
+
+```powershell
+$Context.EventSink.WriteEvent(Type, Message, StepName, Data[, Level])
+```
+
+`Level` is optional and defaults to `Information`.
+
+---
+
+### Event types
+
+`Type` names the event; `Level` carries the severity. Sinks filter on both (for example: alert on
+`Level = 'Error'`, audit on `IdLE.Provider.AD.AttributeChanged`).
+
+| Emitted by | Format | Example |
+| --- | --- | --- |
+| IdLE (engine, first-party steps and providers) | `IdLE..` | `IdLE.Step.Failed`, `IdLE.Provider.AD.AttributeChanged` |
+| Extensions (third-party steps and providers) | `.IdLE..` | `Contoso.IdLE.Hr.ManagerSynced` |
+| Workflows (`PreconditionEvent.Type`, `EmitEvent` `With.Type`) | free, but not `IdLE.*` | `Contoso.ManualActionRequired` |
+
+Rules:
+
+- `IdLE.*` is reserved for events emitted by IdLE. Workflow-defined event types starting with `IdLE.`
+ are rejected (`ReservedNamespace`); see [Step type names](steps.md#step-type-names) for the namespace scheme.
+- `Information`, `Warning`, `Error` and `Custom` are not valid event types (`InvalidEventType`).
+ Use a descriptive type and set the severity with `Level`.
+- Event types and their `Data` fields listed below are a contract. `Message` texts are not.
+
+#### Engine events
+
+| Type | Level | Data |
+| --- | --- | --- |
+| `IdLE.Run.Started` | Information | `CorrelationId`, `Actor`, `StepCount` |
+| `IdLE.Run.Completed` | Information; `Warning` if `Blocked`; `Error` if `Failed` | `Status`, `StepCount` |
+| `IdLE.Step.Started` | Information | `StepType`, `Index` |
+| `IdLE.Step.Completed` | Information | `StepType`, `Index` |
+| `IdLE.Step.Failed` | Error | `StepType`, `Index`, `Error` |
+| `IdLE.Step.Blocked` | Warning | `StepType`, `Index` |
+| `IdLE.Step.NotApplicable` | Information | `StepType`, `Index` |
+| `IdLE.Step.PreconditionFailed` | Warning | `StepType`, `Index`, `OnPreconditionFalse` |
+| `IdLE.Step.Retrying` | Warning | `attempt`, `maxAttempts`, `delayMs`, `errorType`, `message` |
+| `IdLE.OnFailure.Started` | Information | `OnFailureStepCount` |
+| `IdLE.OnFailure.Completed` | Information; `Warning` if `PartiallyFailed` | `Status`, `StepCount` |
+| `IdLE.OnFailure.StepStarted` | Information | `StepType`, `Index` |
+| `IdLE.OnFailure.StepCompleted` | Information | `StepType`, `Index` |
+| `IdLE.OnFailure.StepFailed` | Error | `StepType`, `Index`, `Error` |
+| `IdLE.OnFailure.StepNotApplicable` | Information | `StepType`, `Index` |
+
+`IdLE.Run.Completed` is always the last event of a run.
+
+#### Step events
+
+| Type | Level | Data |
+| --- | --- | --- |
+| `IdLE.Step.EmitEvent.Emitted` | `With.Level` (default Information) | `StepType` |
+| `IdLE.Step.DirectorySync.Triggered` | Information | `PolicyType`, `ComputerName` |
+| `IdLE.Step.DirectorySync.Waiting` | Information | `TimeoutSeconds`, `PollIntervalSeconds` |
+| `IdLE.Step.DirectorySync.Polled` | Information | `Attempt`, `State`, `InProgress`, `ElapsedSeconds` |
+| `IdLE.Step.DirectorySync.Completed` | Information | `Attempts`, `ElapsedSeconds` (waited) or `PolicyType` (not waited) |
+| `IdLE.Step.DirectorySync.Failed` | Error | `TimeoutSeconds`, `ElapsedSeconds`, `LastKnownState` (timeout) or `Error` |
+| `IdLE.Step.PruneEntitlements.Planned` | Information | `Kind`, `KeepCount`, `PruneCount` |
+| `IdLE.Step.PruneEntitlements.EntitlementRevoked` | Information | `Kind`, `EntitlementId` |
+| `IdLE.Step.PruneEntitlements.EntitlementSkipped` | Warning | `Kind`, `EntitlementId`, `Reason` |
+| `IdLE.Step.PruneEntitlements.KeepGranted` | Information | `Kind`, `EntitlementId` |
+| `IdLE.Step.PruneEntitlements.KeepGrantFailed` | Warning | `Kind`, `EntitlementId`, `Reason` |
+
+`IdLE.Step.EmitEvent` emits `IdLE.Step.EmitEvent.Emitted` unless the workflow sets `With.Type`.
+
+#### Provider events
+
+Providers emit events only when the host passes an event sink to the provider.
+
+| Type | Level | Data |
+| --- | --- | --- |
+| `IdLE.Provider.AD.AttributesRequested` | Information | `IdentityKey`, `Requested` |
+| `IdLE.Provider.AD.AttributeChanged` | Information | `IdentityKey`, `AttributeName`, `OldValue`, `NewValue` |
+| `IdLE.Provider.ExchangeOnline.PermissionsEvaluated` | Information | `MailboxSmtp`, `Right`, `CurrentUsers` |
+| `IdLE.Provider.ExchangeOnline.PermissionChanging` | Information | `MailboxSmtp`, `Right`, `User`, `Action` |
+| `IdLE.Provider.ExchangeOnline.PermissionsEnsured` | Information | `MailboxSmtp`, `Changed` |
+
+#### Migration from earlier versions
+
+Event types were renamed in one step without aliases:
+
+| Old type | New type |
+| --- | --- |
+| `RunStarted`, `RunCompleted` | `IdLE.Run.Started`, `IdLE.Run.Completed` |
+| `StepStarted`, `StepCompleted`, `StepFailed`, `StepBlocked`, `StepNotApplicable`, `StepPreconditionFailed`, `StepRetrying` | `IdLE.Step.Started`, `.Completed`, `.Failed`, `.Blocked`, `.NotApplicable`, `.PreconditionFailed`, `.Retrying` |
+| `OnFailureStarted`, `OnFailureCompleted` | `IdLE.OnFailure.Started`, `IdLE.OnFailure.Completed` |
+| `OnFailureStepStarted`, `OnFailureStepCompleted`, `OnFailureStepFailed`, `OnFailureStepNotApplicable` | `IdLE.OnFailure.StepStarted`, `.StepCompleted`, `.StepFailed`, `.StepNotApplicable` |
+| `DirectorySyncTriggered`, `DirectorySyncWaiting`, `DirectorySyncPoll`, `DirectorySyncCompleted`, `DirectorySyncFailed` | `IdLE.Step.DirectorySync.Triggered`, `.Waiting`, `.Polled`, `.Completed`, `.Failed` |
+| `Information` / `Warning` (PruneEntitlements) | `IdLE.Step.PruneEntitlements.Planned`, `.EntitlementRevoked`, `.EntitlementSkipped`, `.KeepGranted`, `.KeepGrantFailed` |
+| `Custom` (EmitEvent) | `IdLE.Step.EmitEvent.Emitted` or the workflow's `With.Type` |
+| `Provider.AD.CreateIdentity.AttributesRequested`, `Provider.AD.EnsureAttribute.AttributeChanged` | `IdLE.Provider.AD.AttributesRequested`, `IdLE.Provider.AD.AttributeChanged` |
+| `Provider.ExchangeOnline.Permissions.Evaluated`, `.Applying`, `.Result` | `IdLE.Provider.ExchangeOnline.PermissionsEvaluated`, `.PermissionChanging`, `.PermissionsEnsured` |
+
+---
+
### Buffered by default
During execution, events are **buffered inside the execution result**.
@@ -132,7 +238,7 @@ The repository demo runner is an example of this pattern.
#### CI pipelines
- Inspect execution status
-- Fail the pipeline if a `RunFailed` or `StepFailed` event exists
+- Fail the pipeline if an event with `Level = 'Error'` exists (for example `IdLE.Step.Failed`)
- Optionally archive event output as build artifacts
#### Services and long-running hosts
diff --git a/docs/extend/extensibility.md b/docs/extend/extensibility.md
index e25026b7..d0de6362 100644
--- a/docs/extend/extensibility.md
+++ b/docs/extend/extensibility.md
@@ -26,12 +26,12 @@ Extension step types and capabilities use your own owner prefix: `.IdLE.S
Steps can emit structured events using the execution context contract:
-- `Context.EventSink.WriteEvent(Type, Message, StepName, Data)`
+- `Context.EventSink.WriteEvent(Type, Message, StepName, Data[, Level])` (see [Event types](events.md#event-types))
Keep steps host-agnostic: do not call UI APIs directly.
- Use providers for system operations; do not embed authentication logic inside steps.
-- Emit events using `Context.EventSink.WriteEvent(Type, Message, StepName, Data)`.
+- Emit events using `Context.EventSink.WriteEvent(Type, Message, StepName, Data[, Level])`.
- Avoid global state. Steps should be idempotent whenever possible.
---
diff --git a/docs/extend/steps.md b/docs/extend/steps.md
index f95af61b..42447540 100644
--- a/docs/extend/steps.md
+++ b/docs/extend/steps.md
@@ -288,23 +288,26 @@ Steps may emit **structured events** for progress and audit.
The engine provides a stable, object-based contract on the execution context:
-- `Context.EventSink.WriteEvent(Type, Message, StepName, Data)`
+- `Context.EventSink.WriteEvent(Type, Message, StepName, Data[, Level])`
Notes:
-- `Type` is a short string (for example: `Custom`, `Debug`).
+- `Type` says *what happened*: `IdLE..` for first-party steps (e.g. `IdLE.Step.DirectorySync.Completed`),
+ `.IdLE..` for extensions (e.g. `Contoso.IdLE.Hr.ManagerSynced`).
+ See [Event types](events.md#event-types).
- `Message` is a human-readable message.
- `StepName` should be the current step name (if available).
- `Data` is an optional hashtable for structured details.
+- `Level` says *how severe* it is: `Information` (default), `Warning` or `Error`.
Example:
```powershell
$Context.EventSink.WriteEvent(
- 'Custom',
- 'Ensured Department attribute.',
+ 'Contoso.IdLE.Hr.ManagerSynced',
+ 'Synced manager from HR.',
$Step.Name,
- @{ Provider = 'Identity'; Attribute = 'Department' }
+ @{ Provider = 'Identity'; Attribute = 'Manager' }
)
```
diff --git a/docs/reference/providers/provider-directorysync-entraconnect.md b/docs/reference/providers/provider-directorysync-entraconnect.md
index 90f69ca4..b2b4372c 100644
--- a/docs/reference/providers/provider-directorysync-entraconnect.md
+++ b/docs/reference/providers/provider-directorysync-entraconnect.md
@@ -106,7 +106,7 @@ and execution, as noted below.
| `With.PolicyType` | `string` | Required by provider | `Delta` or `Initial` sync policy |
| `With.Wait` | `bool` | `false` | Poll sync status and wait for result (or timeout) |
| `With.PollIntervalSeconds` | `int` | `10` | Interval in seconds to poll for sync status |
-| `With.TimeoutSeconds` | `int` | `600` | Timeout for poll wait in seconds. Will result in `StepFailed` |
+| `With.TimeoutSeconds` | `int` | `600` | Timeout for poll wait in seconds. Will result in `IdLE.Step.Failed` |
## Examples
diff --git a/docs/reference/steps.md b/docs/reference/steps.md
index a7c912bc..0976da41 100644
--- a/docs/reference/steps.md
+++ b/docs/reference/steps.md
@@ -8,7 +8,7 @@
| [IdLE.Step.CreateIdentity](steps/step-create-identity.md) | ``IdLE.Steps.Common`` | Creates a new identity in the target system. |
| [IdLE.Step.DeleteIdentity](steps/step-delete-identity.md) | ``IdLE.Steps.Common`` | Deletes an identity from the target system. |
| [IdLE.Step.DisableIdentity](steps/step-disable-identity.md) | ``IdLE.Steps.Common`` | Disables an identity in the target system. |
-| [IdLE.Step.EmitEvent](steps/step-emit-event.md) | ``IdLE.Steps.Common`` | Emits a custom event (demo step). |
+| [IdLE.Step.EmitEvent](steps/step-emit-event.md) | ``IdLE.Steps.Common`` | Emits a workflow-defined event. |
| [IdLE.Step.EnableIdentity](steps/step-enable-identity.md) | ``IdLE.Steps.Common`` | Enables an identity in the target system. |
| [IdLE.Step.EnsureAttributes](steps/step-ensure-attributes.md) | ``IdLE.Steps.Common`` | Ensures that multiple identity attributes match their desired values. |
| [IdLE.Step.EnsureEntitlement](steps/step-ensure-entitlement.md) | ``IdLE.Steps.Common`` | Ensures that an entitlement assignment is present or absent for an identity. |
diff --git a/docs/reference/steps/step-emit-event.md b/docs/reference/steps/step-emit-event.md
index bd882516..8ff70bf7 100644
--- a/docs/reference/steps/step-emit-event.md
+++ b/docs/reference/steps/step-emit-event.md
@@ -12,13 +12,23 @@
## Synopsis
-Emits a custom event (demo step).
+Emits a workflow-defined event.
## Description
-This step does not change external state. It emits a custom event message.
-The engine provides an EventSink on the execution context that the step can use
-to write structured events.
+This step does not change external state. It writes one structured event to the
+EventSink on the execution context (buffered in the execution result and forwarded
+to the host event sink, if any).
+
+Inputs (all optional):
+
+- With.Message: event message. Defaults to "Event emitted by step '<Name>'.".
+
+- With.Type: event type, e.g. 'Contoso.Joiner.Notified'. Must not start with 'IdLE.'
+ (reserved) and must not be 'Information', 'Warning', 'Error' or 'Custom'.
+ Defaults to 'IdLE.Step.EmitEvent.Emitted'.
+
+- With.Level: 'Information' (default), 'Warning' or 'Error'.
## Inputs (With.*)
diff --git a/docs/use/workflows/preconditions.md b/docs/use/workflows/preconditions.md
index c6ec8775..cb78b639 100644
--- a/docs/use/workflows/preconditions.md
+++ b/docs/use/workflows/preconditions.md
@@ -86,8 +86,9 @@ Add these optional properties to a workflow step definition:
| Key | Type | Required | Description |
|---|---|---|---|
-| `Type` | `String` | **Yes** | Event type string (for example: `ManualActionRequired`). |
+| `Type` | `String` | **Yes** | Event type string (for example: `Contoso.ManualActionRequired`). Must not start with `IdLE.` (reserved) and must not be `Information`, `Warning`, `Error` or `Custom`. |
| `Message` | `String` | **Yes** | Human-readable description of the required action. |
+| `Level` | `String` | No | `Information` (default), `Warning` or `Error`. |
| `Data` | `Hashtable` | No | Optional key-value payload. Must not contain secrets. |
---
@@ -107,8 +108,8 @@ When a step is `Blocked`:
- `result.Status` is `'Blocked'`.
- `result.Steps[n].Status` is `'Blocked'` for the blocking step.
- `result.OnFailure.Status` is `'NotRun'` (OnFailureSteps do not execute).
-- A `StepPreconditionFailed` engine event is always emitted.
-- A `StepBlocked` engine event is emitted for the blocked step.
+- An `IdLE.Step.PreconditionFailed` engine event is always emitted.
+- An `IdLE.Step.Blocked` engine event is emitted for the blocked step.
- If `PreconditionEvent` is configured, an additional event of the declared `Type` is also emitted.
### Execution result — Fail
@@ -118,8 +119,8 @@ When `OnPreconditionFalse = 'Fail'`:
- `result.Status` is `'Failed'`.
- `result.Steps[n].Status` is `'Failed'` with `Error = 'Precondition check failed.'`.
- `OnFailureSteps` run (same behavior as any other step failure).
-- A `StepPreconditionFailed` engine event is always emitted.
-- A `StepFailed` engine event is emitted (matching the format of regular step failure events).
+- An `IdLE.Step.PreconditionFailed` engine event is always emitted.
+- An `IdLE.Step.Failed` engine event is emitted (matching the format of regular step failure events).
- If `PreconditionEvent` is configured, an additional event of the declared `Type` is also emitted.
### Execution result — Continue
@@ -129,7 +130,7 @@ When `OnPreconditionFalse = 'Continue'`:
- `result.Status` is `'Completed'` (unless a subsequent step fails for another reason).
- `result.Steps[n].Status` is `'PreconditionSkipped'` for the skipped step.
- Subsequent steps execute as normal.
-- A `StepPreconditionFailed` engine event is always emitted for observability.
+- An `IdLE.Step.PreconditionFailed` engine event is always emitted for observability.
- If `PreconditionEvent` is configured, an additional event of the declared `Type` is also emitted.
Use `Continue` when a precondition failure is advisory rather than blocking — for example, to emit
@@ -142,16 +143,17 @@ the rest of the workflow to complete.
| Event type | `OnPreconditionFalse` modes | Description |
|---|---|---|
-| `StepPreconditionFailed` | All (`Blocked`, `Fail`, `Continue`) | Always emitted. Contains `StepType`, `Index`, `OnPreconditionFalse`. |
-| `StepBlocked` | `Blocked` | Emitted when the step outcome is `Blocked`. Contains `StepType`, `Index`. |
-| `StepFailed` | `Fail` | Emitted when the step outcome is `Failed`. Contains `StepType`, `Index`, `Error`. |
+| `IdLE.Step.PreconditionFailed` | All (`Blocked`, `Fail`, `Continue`) | Always emitted. Contains `StepType`, `Index`, `OnPreconditionFalse`. |
+| `IdLE.Step.Blocked` | `Blocked` | Emitted when the step outcome is `Blocked`. Contains `StepType`, `Index`. |
+| `IdLE.Step.Failed` | `Fail` | Emitted when the step outcome is `Failed`. Contains `StepType`, `Index`, `Error`. |
| Configured `PreconditionEvent.Type` | All (if `PreconditionEvent` configured) | Caller-defined event. |
-### StepPreconditionFailed event
+### IdLE.Step.PreconditionFailed event
| Field | Value |
|---|---|
-| `Type` | `StepPreconditionFailed` |
+| `Type` | `IdLE.Step.PreconditionFailed` |
+| `Level` | `Warning` |
| `StepName` | The name of the affected step. |
| `Data.StepType` | The step type identifier. |
| `Data.Index` | The step index in the plan. |
@@ -164,6 +166,7 @@ If `PreconditionEvent` is configured, an additional event is emitted with:
| Field | Value |
|---|---|
| `Type` | The configured `PreconditionEvent.Type`. |
+| `Level` | The configured `PreconditionEvent.Level` (default `Information`). |
| `Message` | The configured `PreconditionEvent.Message`. |
| `StepName` | The name of the affected step. |
| `Data` | The configured `PreconditionEvent.Data` (if provided). |
@@ -212,7 +215,7 @@ a `Blocked` outcome and a message instructing the operator to perform the wipe m
}
OnPreconditionFalse = 'Blocked'
PreconditionEvent = @{
- Type = 'ManualActionRequired'
+ Type = 'Contoso.ManualActionRequired'
Message = 'Perform Intune retire / wipe company data for BYOD device before disabling the identity.'
Data = @{
Reason = 'BYOD wipe not confirmed'
diff --git a/examples/Invoke-IdleDemo.ps1 b/examples/Invoke-IdleDemo.ps1
index d69e9246..d481c6e9 100644
--- a/examples/Invoke-IdleDemo.ps1
+++ b/examples/Invoke-IdleDemo.ps1
@@ -64,17 +64,26 @@ function Format-EventRow {
param([Parameter(Mandatory)][object]$EventRecord)
$icons = @{
- RunStarted = '🚀'
- RunCompleted = '🏁'
- StepStarted = '▶️'
- StepCompleted = '✅'
- StepSkipped = '⏭️'
- StepFailed = '❌'
- Custom = '📝'
- Debug = '🔎'
+ 'IdLE.Run.Started' = '🚀'
+ 'IdLE.Run.Completed' = '🏁'
+ 'IdLE.Step.Started' = '▶️'
+ 'IdLE.Step.Completed' = '✅'
+ 'IdLE.Step.NotApplicable' = '⏭️'
+ 'IdLE.Step.EmitEvent.Emitted' = '📝'
}
- $icon = if ($icons.ContainsKey($EventRecord.Type)) { $icons[$EventRecord.Type] } else { '•' }
+ $icon = if ($icons.ContainsKey($EventRecord.Type)) {
+ $icons[$EventRecord.Type]
+ }
+ elseif ($EventRecord.Level -eq 'Error') {
+ '❌'
+ }
+ elseif ($EventRecord.Level -eq 'Warning') {
+ '⚠️'
+ }
+ else {
+ '•'
+ }
$time = ([DateTime]$EventRecord.TimestampUtc).ToLocalTime().ToString('HH:mm:ss.fff')
$step = if ([string]::IsNullOrWhiteSpace($EventRecord.StepName)) { '-' } else { [string]$EventRecord.StepName }
diff --git a/src/IdLE.Core/Data/ReservedNamespaces.psd1 b/src/IdLE.Core/Data/ReservedNamespaces.psd1
index 5b716967..97e3e3b9 100644
--- a/src/IdLE.Core/Data/ReservedNamespaces.psd1
+++ b/src/IdLE.Core/Data/ReservedNamespaces.psd1
@@ -52,4 +52,12 @@
'IdLE.Mailbox.Read' = 'IdLE.Mailbox.Info.Read'
}
}
+
+ # Event types: first-party 'IdLE..', extensions '.IdLE..' (by convention).
+ # Workflow-defined types (PreconditionEvent.Type, EmitEvent With.Type) are free but must not use 'IdLE.'.
+ # See docs/extend/events.md.
+ EventType = @{
+ # Former catch-all types; severity is carried by Event.Level instead. Rejected everywhere.
+ Disallowed = @('Information', 'Warning', 'Error', 'Custom')
+ }
}
diff --git a/src/IdLE.Core/Private/ConvertTo-IdleWorkflowStepPreconditionSettings.ps1 b/src/IdLE.Core/Private/ConvertTo-IdleWorkflowStepPreconditionSettings.ps1
index b5d44813..17895aab 100644
--- a/src/IdLE.Core/Private/ConvertTo-IdleWorkflowStepPreconditionSettings.ps1
+++ b/src/IdLE.Core/Private/ConvertTo-IdleWorkflowStepPreconditionSettings.ps1
@@ -92,6 +92,21 @@ function ConvertTo-IdleWorkflowStepPreconditionSettings {
)
}
+ $pcEvtTypeError = Get-IdleIdentifierNamespaceError -Kind WorkflowEventType -Identifier $pcEvtType
+ if ($null -ne $pcEvtTypeError) {
+ throw [System.ArgumentException]::new(
+ ("Workflow step '{0}': PreconditionEvent.Type: {1}" -f $StepName, $pcEvtTypeError),
+ 'Workflow'
+ )
+ }
+
+ if ($rawPreconditionEvent.Contains('Level') -and [string]$rawPreconditionEvent['Level'] -notin @('Information', 'Warning', 'Error')) {
+ throw [System.ArgumentException]::new(
+ ("Workflow step '{0}': PreconditionEvent.Level must be 'Information', 'Warning', or 'Error'." -f $StepName),
+ 'Workflow'
+ )
+ }
+
$pcEvtMsg = if ($rawPreconditionEvent.Contains('Message')) { [string]$rawPreconditionEvent['Message'] } else { $null }
if ([string]::IsNullOrWhiteSpace($pcEvtMsg)) {
throw [System.ArgumentException]::new(
diff --git a/src/IdLE.Core/Private/Get-IdleIdentifierNamespaceError.ps1 b/src/IdLE.Core/Private/Get-IdleIdentifierNamespaceError.ps1
index d02bd391..f8916eff 100644
--- a/src/IdLE.Core/Private/Get-IdleIdentifierNamespaceError.ps1
+++ b/src/IdLE.Core/Private/Get-IdleIdentifierNamespaceError.ps1
@@ -7,11 +7,14 @@ function Get-IdleIdentifierNamespaceError {
Rules (see Data/ReservedNamespaces.psd1):
- StepType: 'IdLE.*' only from first-party modules; extensions use '.IdLE.Step.<...>'.
- Capability: 'IdLE.*' only if defined by IdLE (or a deprecated alias); extensions use '.IdLE..'.
+ - WorkflowEventType (PreconditionEvent.Type, EmitEvent With.Type): any name except 'IdLE.*' and the
+ disallowed catch-all types (Information, Warning, Error, Custom).
- Messages start with a stable error code (ReservedNamespace, InvalidExtensionNamespace, UnknownCapability).
+ Messages start with a stable error code (ReservedNamespace, InvalidExtensionNamespace, UnknownCapability,
+ InvalidEventType).
.PARAMETER Kind
- Identifier kind: StepType or Capability.
+ Identifier kind: StepType, Capability or WorkflowEventType.
.PARAMETER Identifier
The identifier to check.
@@ -25,7 +28,7 @@ function Get-IdleIdentifierNamespaceError {
[CmdletBinding()]
param(
[Parameter(Mandatory)]
- [ValidateSet('StepType', 'Capability')]
+ [ValidateSet('StepType', 'Capability', 'WorkflowEventType')]
[string] $Kind,
[Parameter(Mandatory)]
@@ -37,6 +40,19 @@ function Get-IdleIdentifierNamespaceError {
)
$rules = Get-IdleReservedNamespaces
+
+ if ($Kind -eq 'WorkflowEventType') {
+ if ($rules.EventType.Disallowed -contains $Identifier) {
+ return "InvalidEventType: Event type '$Identifier' is not allowed. Use a descriptive event name and set the severity via Level."
+ }
+
+ if ($Identifier.StartsWith($rules.ReservedPrefix, [System.StringComparison]::OrdinalIgnoreCase)) {
+ return "ReservedNamespace: Event type '$Identifier' uses the reserved prefix '$($rules.ReservedPrefix)'. Workflow-defined event types must not start with '$($rules.ReservedPrefix)'."
+ }
+
+ return $null
+ }
+
$kindRules = $rules[$Kind]
$label = if ($Kind -eq 'StepType') { 'Step type' } else { 'Capability' }
diff --git a/src/IdLE.Core/Private/Invoke-IdleWithRetry.ps1 b/src/IdLE.Core/Private/Invoke-IdleWithRetry.ps1
index 825b0795..5f3be7ec 100644
--- a/src/IdLE.Core/Private/Invoke-IdleWithRetry.ps1
+++ b/src/IdLE.Core/Private/Invoke-IdleWithRetry.ps1
@@ -174,7 +174,7 @@ function Invoke-IdleWithRetry {
if ($null -ne $EventSink -and $EventSink.PSObject.Methods.Name -contains 'WriteEvent') {
try {
$EventSink.WriteEvent(
- 'StepRetrying',
+ 'IdLE.Step.Retrying',
"Transient failure in '$OperationName' (attempt $attempt/$MaxAttempts). Retrying.",
$StepName,
@{
@@ -183,7 +183,8 @@ function Invoke-IdleWithRetry {
delayMs = $delay
errorType = $exception.GetType().FullName
message = $exception.Message
- }
+ },
+ 'Warning'
)
}
catch {
diff --git a/src/IdLE.Core/Private/New-IdleEvent.ps1 b/src/IdLE.Core/Private/New-IdleEvent.ps1
index d82ac6c5..ef6a11a1 100644
--- a/src/IdLE.Core/Private/New-IdleEvent.ps1
+++ b/src/IdLE.Core/Private/New-IdleEvent.ps1
@@ -23,14 +23,28 @@ function New-IdleEvent {
[Parameter()]
[AllowNull()]
- [hashtable] $Data
+ [hashtable] $Data,
+
+ [Parameter()]
+ [ValidateSet('Information', 'Warning', 'Error')]
+ [string] $Level = 'Information'
)
+ # Severity belongs in Level, not in Type. These former catch-all types carry no meaning for sinks
+ # that filter by type, so they are rejected (see docs/extend/events.md).
+ if ((Get-IdleReservedNamespaces).EventType.Disallowed -contains $Type) {
+ throw [System.ArgumentException]::new(
+ "Event type '$Type' is not allowed. Use a descriptive type such as 'IdLE..' or '.IdLE..' and pass the severity as Level.",
+ 'Type'
+ )
+ }
+
# Create a structured event object that can be streamed to an audit sink later.
return [pscustomobject]@{
PSTypeName = 'IdLE.Event'
TimestampUtc = [DateTime]::UtcNow
Type = $Type
+ Level = $Level
Message = $Message
CorrelationId = $CorrelationId
Actor = $Actor
diff --git a/src/IdLE.Core/Private/New-IdleEventSink.ps1 b/src/IdLE.Core/Private/New-IdleEventSink.ps1
index 961e3d24..72cfdd17 100644
--- a/src/IdLE.Core/Private/New-IdleEventSink.ps1
+++ b/src/IdLE.Core/Private/New-IdleEventSink.ps1
@@ -48,7 +48,7 @@ function New-IdleEventSink {
}
# Provide a stable, object-based contract to steps.
- # Steps call: $Context.EventSink.WriteEvent(Type, Message, StepName, Data)
+ # Steps call: $Context.EventSink.WriteEvent(Type, Message, StepName, Data[, Level])
# The engine stays in control of event shape and buffering.
$writeMethod = {
param(
@@ -66,10 +66,17 @@ function New-IdleEventSink {
[Parameter()]
[AllowNull()]
- [hashtable] $Data
+ [hashtable] $Data,
+
+ # Optional so that existing four-argument callers keep working.
+ [Parameter()]
+ [AllowNull()]
+ [string] $Level
)
- $evt = & $newIdleEventCmd -Type $Type -Message $Message -CorrelationId $CorrelationId -Actor $Actor -StepName $StepName -Data $Data
+ if ([string]::IsNullOrEmpty($Level)) { $Level = 'Information' }
+
+ $evt = & $newIdleEventCmd -Type $Type -Message $Message -CorrelationId $CorrelationId -Actor $Actor -StepName $StepName -Data $Data -Level $Level
& $writeIdleEventCmd -Event $evt -EventSink $ExternalEventSink -EventBuffer $EventBuffer
}.GetNewClosure()
diff --git a/src/IdLE.Core/Private/Test-IdleWorkflowSchema.ps1 b/src/IdLE.Core/Private/Test-IdleWorkflowSchema.ps1
index 4f9f5423..53156bdd 100644
--- a/src/IdLE.Core/Private/Test-IdleWorkflowSchema.ps1
+++ b/src/IdLE.Core/Private/Test-IdleWorkflowSchema.ps1
@@ -99,6 +99,15 @@ function Test-IdleWorkflowSchema {
if (-not $pcEvt.ContainsKey('Type') -or [string]::IsNullOrWhiteSpace([string]$pcEvt.Type)) {
$ErrorList.Add("'$StepPath.PreconditionEvent.Type' is required and must be a non-empty string.")
}
+ else {
+ $pcEvtTypeError = Get-IdleIdentifierNamespaceError -Kind WorkflowEventType -Identifier ([string]$pcEvt.Type)
+ if ($null -ne $pcEvtTypeError) {
+ $ErrorList.Add("'$StepPath.PreconditionEvent.Type': $pcEvtTypeError")
+ }
+ }
+ if ($pcEvt.ContainsKey('Level') -and [string]$pcEvt.Level -notin @('Information', 'Warning', 'Error')) {
+ $ErrorList.Add("'$StepPath.PreconditionEvent.Level' must be 'Information', 'Warning', or 'Error'.")
+ }
if (-not $pcEvt.ContainsKey('Message') -or [string]::IsNullOrWhiteSpace([string]$pcEvt.Message)) {
$ErrorList.Add("'$StepPath.PreconditionEvent.Message' is required and must be a non-empty string.")
}
diff --git a/src/IdLE.Core/Public/Invoke-IdlePlanObject.ps1 b/src/IdLE.Core/Public/Invoke-IdlePlanObject.ps1
index 146b1276..13bb4e1e 100644
--- a/src/IdLE.Core/Public/Invoke-IdlePlanObject.ps1
+++ b/src/IdLE.Core/Public/Invoke-IdlePlanObject.ps1
@@ -183,7 +183,7 @@ function Invoke-IdlePlanObject {
} -Force
$context.EventSink.WriteEvent(
- 'RunStarted',
+ 'IdLE.Run.Started',
'Plan execution started.',
$null,
@{
@@ -230,7 +230,7 @@ function Invoke-IdlePlanObject {
}
$context.EventSink.WriteEvent(
- 'StepNotApplicable',
+ 'IdLE.Step.NotApplicable',
"Step '$stepName' not applicable (condition not met).",
$stepName,
@{
@@ -315,14 +315,15 @@ function Invoke-IdlePlanObject {
# Always emit StepPreconditionFailed for engine observability.
$context.EventSink.WriteEvent(
- 'StepPreconditionFailed',
+ 'IdLE.Step.PreconditionFailed',
"Step '$stepName' precondition check failed.",
$stepName,
@{
StepType = $stepType
Index = $i
OnPreconditionFalse = $onPreconditionFalse
- }
+ },
+ 'Warning'
)
# Emit the caller-configured PreconditionEvent if present.
@@ -334,7 +335,8 @@ function Invoke-IdlePlanObject {
# PreconditionEvent.Data is validated as a hashtable at planning time and
# stored via Copy-IdleDataObject, so it will be a hashtable (IDictionary) here.
$pcEvtDataHt = if ($pcEvtData -is [System.Collections.IDictionary]) { [hashtable]$pcEvtData } else { $null }
- $context.EventSink.WriteEvent($pcEvtType, $pcEvtMsg, $stepName, $pcEvtDataHt)
+ $pcEvtLevel = [string](Get-IdlePropertyValue -Object $pcEvt -Name 'Level')
+ $context.EventSink.WriteEvent($pcEvtType, $pcEvtMsg, $stepName, $pcEvtDataHt, $pcEvtLevel)
}
if ($onPreconditionFalse -eq 'Fail') {
@@ -348,14 +350,15 @@ function Invoke-IdlePlanObject {
Attempts = 0
}
$context.EventSink.WriteEvent(
- 'StepFailed',
+ 'IdLE.Step.Failed',
"Step '$stepName' failed (precondition check failed).",
$stepName,
@{
StepType = $stepType
Index = $i
Error = 'Precondition check failed.'
- }
+ },
+ 'Error'
)
}
elseif ($onPreconditionFalse -eq 'Continue') {
@@ -385,13 +388,14 @@ function Invoke-IdlePlanObject {
Attempts = 0
}
$context.EventSink.WriteEvent(
- 'StepBlocked',
+ 'IdLE.Step.Blocked',
"Step '$stepName' blocked (precondition check failed).",
$stepName,
@{
StepType = $stepType
Index = $i
- }
+ },
+ 'Warning'
)
}
@@ -413,7 +417,7 @@ function Invoke-IdlePlanObject {
}
$context.EventSink.WriteEvent(
- 'StepStarted',
+ 'IdLE.Step.Started',
"Step '$stepName' started.",
$stepName,
@{
@@ -489,21 +493,22 @@ function Invoke-IdlePlanObject {
$failed = $true
$context.EventSink.WriteEvent(
- 'StepFailed',
+ 'IdLE.Step.Failed',
"Step '$stepName' failed.",
$stepName,
@{
StepType = $stepType
Index = $i
Error = $result.Error
- }
+ },
+ 'Error'
)
break
}
$context.EventSink.WriteEvent(
- 'StepCompleted',
+ 'IdLE.Step.Completed',
"Step '$stepName' completed.",
$stepName,
@{
@@ -527,14 +532,15 @@ function Invoke-IdlePlanObject {
}
$context.EventSink.WriteEvent(
- 'StepFailed',
+ 'IdLE.Step.Failed',
"Step '$stepName' failed.",
$stepName,
@{
StepType = $stepType
Index = $i
Error = $err.Exception.Message
- }
+ },
+ 'Error'
)
break
@@ -561,7 +567,7 @@ function Invoke-IdlePlanObject {
# OnFailureSteps run only for genuine failures, NOT for Blocked outcomes (policy gates).
if ($failed -and -not $blocked -and @($planOnFailureSteps).Count -gt 0) {
$context.EventSink.WriteEvent(
- 'OnFailureStarted',
+ 'IdLE.OnFailure.Started',
'Executing OnFailureSteps (best effort).',
$null,
@{
@@ -598,7 +604,7 @@ function Invoke-IdlePlanObject {
}
$context.EventSink.WriteEvent(
- 'OnFailureStepNotApplicable',
+ 'IdLE.OnFailure.StepNotApplicable',
"OnFailure step '$ofName' not applicable (condition not met).",
$ofName,
@{
@@ -634,14 +640,15 @@ function Invoke-IdlePlanObject {
# Always emit StepPreconditionFailed for engine observability.
$context.EventSink.WriteEvent(
- 'StepPreconditionFailed',
+ 'IdLE.Step.PreconditionFailed',
"OnFailure step '$ofName' precondition check failed.",
$ofName,
@{
StepType = $ofType
Index = $j
OnPreconditionFalse = $ofOnPreconditionFalse
- }
+ },
+ 'Warning'
)
# Emit the caller-configured PreconditionEvent if present.
@@ -651,7 +658,8 @@ function Invoke-IdlePlanObject {
$ofPcEvtMsg = [string](Get-IdlePropertyValue -Object $ofPcEvt -Name 'Message')
$ofPcEvtData = Get-IdlePropertyValue -Object $ofPcEvt -Name 'Data'
$ofPcEvtDataHt = if ($ofPcEvtData -is [System.Collections.IDictionary]) { [hashtable]$ofPcEvtData } else { $null }
- $context.EventSink.WriteEvent($ofPcEvtType, $ofPcEvtMsg, $ofName, $ofPcEvtDataHt)
+ $ofPcEvtLevel = [string](Get-IdlePropertyValue -Object $ofPcEvt -Name 'Level')
+ $context.EventSink.WriteEvent($ofPcEvtType, $ofPcEvtMsg, $ofName, $ofPcEvtDataHt, $ofPcEvtLevel)
}
if ($ofOnPreconditionFalse -eq 'Fail') {
@@ -665,14 +673,15 @@ function Invoke-IdlePlanObject {
Attempts = 0
}
$context.EventSink.WriteEvent(
- 'StepFailed',
+ 'IdLE.Step.Failed',
"OnFailure step '$ofName' failed (precondition check failed).",
$ofName,
@{
StepType = $ofType
Index = $j
Error = 'Precondition check failed.'
- }
+ },
+ 'Error'
)
}
else {
@@ -687,13 +696,14 @@ function Invoke-IdlePlanObject {
}
if ($ofOnPreconditionFalse -ne 'Continue') {
$context.EventSink.WriteEvent(
- 'StepBlocked',
+ 'IdLE.Step.Blocked',
"OnFailure step '$ofName' blocked (precondition check failed).",
$ofName,
@{
StepType = $ofType
Index = $j
- }
+ },
+ 'Warning'
)
}
}
@@ -704,7 +714,7 @@ function Invoke-IdlePlanObject {
}
$context.EventSink.WriteEvent(
- 'OnFailureStepStarted',
+ 'IdLE.OnFailure.StepStarted',
"OnFailure step '$ofName' started.",
$ofName,
@{
@@ -778,19 +788,20 @@ function Invoke-IdlePlanObject {
$onFailureHadFailures = $true
$context.EventSink.WriteEvent(
- 'OnFailureStepFailed',
+ 'IdLE.OnFailure.StepFailed',
"OnFailure step '$ofName' failed.",
$ofName,
@{
StepType = $ofType
Index = $j
Error = $result.Error
- }
+ },
+ 'Error'
)
}
else {
$context.EventSink.WriteEvent(
- 'OnFailureStepCompleted',
+ 'IdLE.OnFailure.StepCompleted',
"OnFailure step '$ofName' completed.",
$ofName,
@{
@@ -815,14 +826,15 @@ function Invoke-IdlePlanObject {
}
$context.EventSink.WriteEvent(
- 'OnFailureStepFailed',
+ 'IdLE.OnFailure.StepFailed',
"OnFailure step '$ofName' failed.",
$ofName,
@{
StepType = $ofType
Index = $j
Error = $err.Exception.Message
- }
+ },
+ 'Error'
)
}
@@ -838,25 +850,33 @@ function Invoke-IdlePlanObject {
}
$context.EventSink.WriteEvent(
- 'OnFailureCompleted',
+ 'IdLE.OnFailure.Completed',
"OnFailureSteps finished (status: $onFailureStatus).",
$null,
@{
Status = $onFailureStatus
StepCount = @($planOnFailureSteps).Count
- }
+ },
+ $(if ($onFailureHadFailures) { 'Warning' } else { 'Information' })
)
}
- # RunCompleted should always be the last event for deterministic event order.
+ $runLevel = switch ($runStatus) {
+ 'Failed' { 'Error' }
+ 'Blocked' { 'Warning' }
+ default { 'Information' }
+ }
+
+ # IdLE.Run.Completed should always be the last event for deterministic event order.
$context.EventSink.WriteEvent(
- 'RunCompleted',
+ 'IdLE.Run.Completed',
"Plan execution finished (status: $runStatus).",
$null,
@{
Status = $runStatus
StepCount = @($Plan.Steps).Count
- }
+ },
+ $runLevel
)
# Issue #48:
diff --git a/src/IdLE.Provider.AD/Public/New-IdleADIdentityProvider.ps1 b/src/IdLE.Provider.AD/Public/New-IdleADIdentityProvider.ps1
index ddc84cb1..8a9ded17 100644
--- a/src/IdLE.Provider.AD/Public/New-IdleADIdentityProvider.ps1
+++ b/src/IdLE.Provider.AD/Public/New-IdleADIdentityProvider.ps1
@@ -472,7 +472,7 @@ function New-IdleADIdentityProvider {
IdentityKey = $IdentityKey
Requested = $validationResult.Requested
}
- $this.EventSink.WriteEvent('Provider.AD.CreateIdentity.AttributesRequested', 'Attributes requested during identity creation', 'CreateIdentity', $eventData)
+ $this.EventSink.WriteEvent('IdLE.Provider.AD.AttributesRequested', 'Attributes requested during identity creation', 'CreateIdentity', $eventData)
}
# Build result with optional password generation info
@@ -643,7 +643,7 @@ function New-IdleADIdentityProvider {
OldValue = $currentValue
NewValue = $Value
}
- $this.EventSink.WriteEvent('Provider.AD.EnsureAttribute.AttributeChanged', "Attribute '$Name' changed", 'EnsureAttribute', $eventData)
+ $this.EventSink.WriteEvent('IdLE.Provider.AD.AttributeChanged', "Attribute '$Name' changed", 'EnsureAttribute', $eventData)
}
}
}
diff --git a/src/IdLE.Provider.ExchangeOnline/Public/New-IdleExchangeOnlineProvider.ps1 b/src/IdLE.Provider.ExchangeOnline/Public/New-IdleExchangeOnlineProvider.ps1
index c733bef5..4a51f420 100644
--- a/src/IdLE.Provider.ExchangeOnline/Public/New-IdleExchangeOnlineProvider.ps1
+++ b/src/IdLE.Provider.ExchangeOnline/Public/New-IdleExchangeOnlineProvider.ps1
@@ -459,7 +459,7 @@ function New-IdleExchangeOnlineProvider {
if ($hasEventSink) {
$null = $this.EventSink.WriteEvent(
- 'Provider.ExchangeOnline.Permissions.Evaluated',
+ 'IdLE.Provider.ExchangeOnline.PermissionsEvaluated',
"FullAccess current state evaluated for '$mailboxSmtp'",
'EnsureMailboxPermissions',
@{ MailboxSmtp = $mailboxSmtp; Right = 'FullAccess'; CurrentUsers = $currentFullAccessUsers }
@@ -473,7 +473,7 @@ function New-IdleExchangeOnlineProvider {
if ($entry.Ensure -eq 'Present' -and -not $isPresent) {
if ($hasEventSink) {
$null = $this.EventSink.WriteEvent(
- 'Provider.ExchangeOnline.Permissions.Applying',
+ 'IdLE.Provider.ExchangeOnline.PermissionChanging',
"Granting FullAccess on '$mailboxSmtp' to '$($entry.AssignedUser)'",
'EnsureMailboxPermissions',
@{ MailboxSmtp = $mailboxSmtp; Right = 'FullAccess'; User = [string]$entry.AssignedUser; Action = 'Add' }
@@ -485,7 +485,7 @@ function New-IdleExchangeOnlineProvider {
elseif ($entry.Ensure -eq 'Absent' -and $isPresent) {
if ($hasEventSink) {
$null = $this.EventSink.WriteEvent(
- 'Provider.ExchangeOnline.Permissions.Applying',
+ 'IdLE.Provider.ExchangeOnline.PermissionChanging',
"Revoking FullAccess on '$mailboxSmtp' from '$($entry.AssignedUser)'",
'EnsureMailboxPermissions',
@{ MailboxSmtp = $mailboxSmtp; Right = 'FullAccess'; User = [string]$entry.AssignedUser; Action = 'Remove' }
@@ -507,7 +507,7 @@ function New-IdleExchangeOnlineProvider {
if ($hasEventSink) {
$null = $this.EventSink.WriteEvent(
- 'Provider.ExchangeOnline.Permissions.Evaluated',
+ 'IdLE.Provider.ExchangeOnline.PermissionsEvaluated',
"SendAs current state evaluated for '$mailboxSmtp'",
'EnsureMailboxPermissions',
@{ MailboxSmtp = $mailboxSmtp; Right = 'SendAs'; CurrentUsers = $currentSendAsTrustees }
@@ -521,7 +521,7 @@ function New-IdleExchangeOnlineProvider {
if ($entry.Ensure -eq 'Present' -and -not $isPresent) {
if ($hasEventSink) {
$null = $this.EventSink.WriteEvent(
- 'Provider.ExchangeOnline.Permissions.Applying',
+ 'IdLE.Provider.ExchangeOnline.PermissionChanging',
"Granting SendAs on '$mailboxSmtp' to '$($entry.AssignedUser)'",
'EnsureMailboxPermissions',
@{ MailboxSmtp = $mailboxSmtp; Right = 'SendAs'; User = [string]$entry.AssignedUser; Action = 'Add' }
@@ -533,7 +533,7 @@ function New-IdleExchangeOnlineProvider {
elseif ($entry.Ensure -eq 'Absent' -and $isPresent) {
if ($hasEventSink) {
$null = $this.EventSink.WriteEvent(
- 'Provider.ExchangeOnline.Permissions.Applying',
+ 'IdLE.Provider.ExchangeOnline.PermissionChanging',
"Revoking SendAs on '$mailboxSmtp' from '$($entry.AssignedUser)'",
'EnsureMailboxPermissions',
@{ MailboxSmtp = $mailboxSmtp; Right = 'SendAs'; User = [string]$entry.AssignedUser; Action = 'Remove' }
@@ -553,7 +553,7 @@ function New-IdleExchangeOnlineProvider {
if ($hasEventSink) {
$null = $this.EventSink.WriteEvent(
- 'Provider.ExchangeOnline.Permissions.Evaluated',
+ 'IdLE.Provider.ExchangeOnline.PermissionsEvaluated',
"SendOnBehalf current state evaluated for '$mailboxSmtp'",
'EnsureMailboxPermissions',
@{ MailboxSmtp = $mailboxSmtp; Right = 'SendOnBehalf'; CurrentUsers = $currentDelegatesLower }
@@ -572,7 +572,7 @@ function New-IdleExchangeOnlineProvider {
if ($entry.Ensure -eq 'Present' -and -not $isPresent) {
if ($hasEventSink) {
$null = $this.EventSink.WriteEvent(
- 'Provider.ExchangeOnline.Permissions.Applying',
+ 'IdLE.Provider.ExchangeOnline.PermissionChanging',
"Granting SendOnBehalf on '$mailboxSmtp' to '$($entry.AssignedUser)'",
'EnsureMailboxPermissions',
@{ MailboxSmtp = $mailboxSmtp; Right = 'SendOnBehalf'; User = [string]$entry.AssignedUser; Action = 'Add' }
@@ -584,7 +584,7 @@ function New-IdleExchangeOnlineProvider {
elseif ($entry.Ensure -eq 'Absent' -and $isPresent) {
if ($hasEventSink) {
$null = $this.EventSink.WriteEvent(
- 'Provider.ExchangeOnline.Permissions.Applying',
+ 'IdLE.Provider.ExchangeOnline.PermissionChanging',
"Revoking SendOnBehalf on '$mailboxSmtp' from '$($entry.AssignedUser)'",
'EnsureMailboxPermissions',
@{ MailboxSmtp = $mailboxSmtp; Right = 'SendOnBehalf'; User = [string]$entry.AssignedUser; Action = 'Remove' }
@@ -605,7 +605,7 @@ function New-IdleExchangeOnlineProvider {
if ($hasEventSink) {
$null = $this.EventSink.WriteEvent(
- 'Provider.ExchangeOnline.Permissions.Result',
+ 'IdLE.Provider.ExchangeOnline.PermissionsEnsured',
"EnsureMailboxPermissions completed for '$mailboxSmtp': Changed=$changed",
'EnsureMailboxPermissions',
@{ MailboxSmtp = $mailboxSmtp; Changed = $changed }
diff --git a/src/IdLE.Steps.Common/Public/Invoke-IdleStepEmitEvent.ps1 b/src/IdLE.Steps.Common/Public/Invoke-IdleStepEmitEvent.ps1
index b8dc1e63..cbc3dda3 100644
--- a/src/IdLE.Steps.Common/Public/Invoke-IdleStepEmitEvent.ps1
+++ b/src/IdLE.Steps.Common/Public/Invoke-IdleStepEmitEvent.ps1
@@ -1,12 +1,19 @@
function Invoke-IdleStepEmitEvent {
<#
.SYNOPSIS
- Emits a custom event (demo step).
+ Emits a workflow-defined event.
.DESCRIPTION
- This step does not change external state. It emits a custom event message.
- The engine provides an EventSink on the execution context that the step can use
- to write structured events.
+ This step does not change external state. It writes one structured event to the
+ EventSink on the execution context (buffered in the execution result and forwarded
+ to the host event sink, if any).
+
+ Inputs (all optional):
+ - With.Message: event message. Defaults to "Event emitted by step ''.".
+ - With.Type: event type, e.g. 'Contoso.Joiner.Notified'. Must not start with 'IdLE.'
+ (reserved) and must not be 'Information', 'Warning', 'Error' or 'Custom'.
+ Defaults to 'IdLE.Step.EmitEvent.Emitted'.
+ - With.Level: 'Information' (default), 'Warning' or 'Error'.
.PARAMETER Context
Execution context created by IdLE.Core.
@@ -37,7 +44,26 @@ function Invoke-IdleStepEmitEvent {
[string]$with.Message
}
else {
- "Custom event emitted by step '$([string]$Step.Name)'."
+ "Event emitted by step '$([string]$Step.Name)'."
+ }
+
+ $eventType = 'IdLE.Step.EmitEvent.Emitted'
+ if ($with.ContainsKey('Type') -and -not [string]::IsNullOrWhiteSpace([string]$with.Type)) {
+ $eventType = [string]$with.Type
+ # 'IdLE.*' event types are reserved for events emitted by IdLE itself.
+ if ($eventType.StartsWith('IdLE.', [System.StringComparison]::OrdinalIgnoreCase)) {
+ throw [System.ArgumentException]::new(
+ "ReservedNamespace: Event type '$eventType' uses the reserved prefix 'IdLE.'. Workflow-defined event types must not start with 'IdLE.'.",
+ 'With.Type'
+ )
+ }
+ }
+
+ $level = if ($with.ContainsKey('Level') -and -not [string]::IsNullOrWhiteSpace([string]$with.Level)) {
+ [string]$with.Level
+ }
+ else {
+ 'Information'
}
# The engine provides an EventSink contract with a WriteEvent(...) method.
@@ -45,7 +71,7 @@ function Invoke-IdleStepEmitEvent {
# for the execution result. This keeps the step deterministic and host-agnostic.
if ($Context.PSObject.Properties.Name -contains 'EventSink' -and $null -ne $Context.EventSink) {
if ($Context.EventSink.PSObject.Methods.Name -contains 'WriteEvent') {
- $Context.EventSink.WriteEvent('Custom', $message, [string]$Step.Name, @{ StepType = [string]$Step.Type })
+ $Context.EventSink.WriteEvent($eventType, $message, [string]$Step.Name, @{ StepType = [string]$Step.Type }, $level)
}
}
diff --git a/src/IdLE.Steps.Common/Public/Invoke-IdleStepPruneEntitlements.ps1 b/src/IdLE.Steps.Common/Public/Invoke-IdleStepPruneEntitlements.ps1
index 2514a369..9703bc64 100644
--- a/src/IdLE.Steps.Common/Public/Invoke-IdleStepPruneEntitlements.ps1
+++ b/src/IdLE.Steps.Common/Public/Invoke-IdleStepPruneEntitlements.ps1
@@ -273,7 +273,7 @@ function Invoke-IdleStepPruneEntitlements {
# Emit plan intent event
if ($Context.PSObject.Properties.Name -contains 'EventSink' -and $null -ne $Context.EventSink -and
$Context.EventSink.PSObject.Methods.Name -contains 'WriteEvent') {
- $Context.EventSink.WriteEvent('Information', "PruneEntitlements: plan - keep=$(
+ $Context.EventSink.WriteEvent('IdLE.Step.PruneEntitlements.Planned', "PruneEntitlements: plan - keep=$(
@($toKeep).Count), remove=$(@($toRemove).Count)", $Step.Name, @{
Kind = $kind
KeepCount = @($toKeep).Count
@@ -302,18 +302,18 @@ function Invoke-IdleStepPruneEntitlements {
}
if ($Context.PSObject.Properties.Name -contains 'EventSink' -and $null -ne $Context.EventSink -and
$Context.EventSink.PSObject.Methods.Name -contains 'WriteEvent') {
- $Context.EventSink.WriteEvent('Warning', "PruneEntitlements: skipped non-removable entitlement '$($br.Entitlement.Id)': $($br.Error)", $Step.Name, @{
+ $Context.EventSink.WriteEvent('IdLE.Step.PruneEntitlements.EntitlementSkipped', "PruneEntitlements: skipped non-removable entitlement '$($br.Entitlement.Id)': $($br.Error)", $Step.Name, @{
Kind = $kind
EntitlementId = [string]$br.Entitlement.Id
Reason = [string]$br.Error
- }
+ }, 'Warning'
)
}
} else {
if ($br.Changed) { $changed = $true }
if ($Context.PSObject.Properties.Name -contains 'EventSink' -and $null -ne $Context.EventSink -and
$Context.EventSink.PSObject.Methods.Name -contains 'WriteEvent') {
- $Context.EventSink.WriteEvent('Information', "PruneEntitlements: revoked entitlement '$($br.Entitlement.Id)'", $Step.Name, @{
+ $Context.EventSink.WriteEvent('IdLE.Step.PruneEntitlements.EntitlementRevoked', "PruneEntitlements: revoked entitlement '$($br.Entitlement.Id)'", $Step.Name, @{
Kind = $kind
EntitlementId = [string]$br.Entitlement.Id
}
@@ -336,7 +336,7 @@ function Invoke-IdleStepPruneEntitlements {
if ($Context.PSObject.Properties.Name -contains 'EventSink' -and $null -ne $Context.EventSink -and
$Context.EventSink.PSObject.Methods.Name -contains 'WriteEvent') {
- $Context.EventSink.WriteEvent('Information', "PruneEntitlements: revoked entitlement '$($ent.Id)'", $Step.Name, @{
+ $Context.EventSink.WriteEvent('IdLE.Step.PruneEntitlements.EntitlementRevoked', "PruneEntitlements: revoked entitlement '$($ent.Id)'", $Step.Name, @{
Kind = $kind
EntitlementId = [string]$ent.Id
}
@@ -353,11 +353,11 @@ function Invoke-IdleStepPruneEntitlements {
if ($Context.PSObject.Properties.Name -contains 'EventSink' -and $null -ne $Context.EventSink -and
$Context.EventSink.PSObject.Methods.Name -contains 'WriteEvent') {
- $Context.EventSink.WriteEvent('Warning', "PruneEntitlements: skipped non-removable entitlement '$($ent.Id)': $reason", $Step.Name, @{
+ $Context.EventSink.WriteEvent('IdLE.Step.PruneEntitlements.EntitlementSkipped', "PruneEntitlements: skipped non-removable entitlement '$($ent.Id)': $reason", $Step.Name, @{
Kind = $kind
EntitlementId = [string]$ent.Id
Reason = $reason
- }
+ }, 'Warning'
)
}
}
@@ -390,18 +390,18 @@ function Invoke-IdleStepPruneEntitlements {
}
if ($Context.PSObject.Properties.Name -contains 'EventSink' -and $null -ne $Context.EventSink -and
$Context.EventSink.PSObject.Methods.Name -contains 'WriteEvent') {
- $Context.EventSink.WriteEvent('Warning', "PruneEntitlements: failed to grant keep entitlement '$($br.Entitlement.Id)': $($br.Error)", $Step.Name, @{
+ $Context.EventSink.WriteEvent('IdLE.Step.PruneEntitlements.KeepGrantFailed', "PruneEntitlements: failed to grant keep entitlement '$($br.Entitlement.Id)': $($br.Error)", $Step.Name, @{
Kind = $kind
EntitlementId = [string]$br.Entitlement.Id
Reason = [string]$br.Error
- }
+ }, 'Warning'
)
}
} else {
if ($br.Changed) { $changed = $true }
if ($Context.PSObject.Properties.Name -contains 'EventSink' -and $null -ne $Context.EventSink -and
$Context.EventSink.PSObject.Methods.Name -contains 'WriteEvent') {
- $Context.EventSink.WriteEvent('Information', "PruneEntitlements: granted keep entitlement '$($br.Entitlement.Id)'", $Step.Name, @{
+ $Context.EventSink.WriteEvent('IdLE.Step.PruneEntitlements.KeepGranted', "PruneEntitlements: granted keep entitlement '$($br.Entitlement.Id)'", $Step.Name, @{
Kind = $kind
EntitlementId = [string]$br.Entitlement.Id
}
@@ -427,7 +427,7 @@ function Invoke-IdleStepPruneEntitlements {
}
if ($Context.PSObject.Properties.Name -contains 'EventSink' -and $null -ne $Context.EventSink -and
$Context.EventSink.PSObject.Methods.Name -contains 'WriteEvent') {
- $Context.EventSink.WriteEvent('Information', "PruneEntitlements: granted keep entitlement '$($k.Id)'", $Step.Name, @{
+ $Context.EventSink.WriteEvent('IdLE.Step.PruneEntitlements.KeepGranted', "PruneEntitlements: granted keep entitlement '$($k.Id)'", $Step.Name, @{
Kind = $kind
EntitlementId = [string]$k.Id
}
diff --git a/src/IdLE.Steps.Common/StepMetadataCatalog.psd1 b/src/IdLE.Steps.Common/StepMetadataCatalog.psd1
index ec95fadc..239f6bae 100644
--- a/src/IdLE.Steps.Common/StepMetadataCatalog.psd1
+++ b/src/IdLE.Steps.Common/StepMetadataCatalog.psd1
@@ -20,7 +20,7 @@
RequiredCapabilities = @()
WithSchema = @{
RequiredKeys = @()
- OptionalKeys = @('Message', 'Provider', 'AuthSessionName', 'AuthSessionOptions')
+ OptionalKeys = @('Message', 'Type', 'Level', 'Provider', 'AuthSessionName', 'AuthSessionOptions')
}
}
diff --git a/src/IdLE.Steps.DirectorySync/Public/Invoke-IdleStepTriggerDirectorySync.ps1 b/src/IdLE.Steps.DirectorySync/Public/Invoke-IdleStepTriggerDirectorySync.ps1
index cac31134..ff1a5499 100644
--- a/src/IdLE.Steps.DirectorySync/Public/Invoke-IdleStepTriggerDirectorySync.ps1
+++ b/src/IdLE.Steps.DirectorySync/Public/Invoke-IdleStepTriggerDirectorySync.ps1
@@ -104,7 +104,7 @@ function Invoke-IdleStepTriggerDirectorySync {
"Triggering $policyTypeText sync cycle"
}
- $Context.EventSink.WriteEvent('DirectorySyncTriggered', $triggerMessage, $stepName, @{
+ $Context.EventSink.WriteEvent('IdLE.Step.DirectorySync.Triggered', $triggerMessage, $stepName, @{
PolicyType = $policyType
ComputerName = $computerName
})
@@ -123,7 +123,7 @@ function Invoke-IdleStepTriggerDirectorySync {
# If wait is requested, poll until complete or timeout
if ($wait) {
- $Context.EventSink.WriteEvent('DirectorySyncWaiting', "Waiting for sync cycle to complete (timeout: ${timeoutSeconds}s)", $stepName, @{
+ $Context.EventSink.WriteEvent('IdLE.Step.DirectorySync.Waiting', "Waiting for sync cycle to complete (timeout: ${timeoutSeconds}s)", $stepName, @{
TimeoutSeconds = $timeoutSeconds
PollIntervalSeconds = $pollIntervalSeconds
})
@@ -146,11 +146,11 @@ function Invoke-IdleStepTriggerDirectorySync {
$lastState = if ($null -ne $stateResult) { $stateResult.State } else { 'Unknown' }
- $Context.EventSink.WriteEvent('DirectorySyncFailed', "Sync cycle wait timeout after ${timeoutSeconds}s", $stepName, @{
+ $Context.EventSink.WriteEvent('IdLE.Step.DirectorySync.Failed', "Sync cycle wait timeout after ${timeoutSeconds}s", $stepName, @{
TimeoutSeconds = $timeoutSeconds
ElapsedSeconds = [int]$elapsed
LastKnownState = $lastState
- })
+ }, 'Error')
throw "TriggerDirectorySync: Timeout waiting for sync cycle to complete after ${timeoutSeconds}s. Last known state: $lastState"
}
@@ -170,7 +170,7 @@ function Invoke-IdleStepTriggerDirectorySync {
$currentState = if ($null -ne $stateResult) { $stateResult.State } else { 'Unknown' }
- $Context.EventSink.WriteEvent('DirectorySyncPoll', "Poll attempt $attempt - State: $currentState", $stepName, @{
+ $Context.EventSink.WriteEvent('IdLE.Step.DirectorySync.Polled', "Poll attempt $attempt - State: $currentState", $stepName, @{
Attempt = $attempt
State = $currentState
InProgress = $inProgress
@@ -179,7 +179,7 @@ function Invoke-IdleStepTriggerDirectorySync {
if (-not $inProgress) {
# Sync cycle completed
- $Context.EventSink.WriteEvent('DirectorySyncCompleted', "Sync cycle completed", $stepName, @{
+ $Context.EventSink.WriteEvent('IdLE.Step.DirectorySync.Completed', "Sync cycle completed", $stepName, @{
Attempts = $attempt
ElapsedSeconds = [int]$elapsed
})
@@ -192,7 +192,7 @@ function Invoke-IdleStepTriggerDirectorySync {
}
else {
# Not waiting - sync triggered successfully
- $Context.EventSink.WriteEvent('DirectorySyncCompleted', "Sync cycle triggered (not waiting)", $stepName, @{
+ $Context.EventSink.WriteEvent('IdLE.Step.DirectorySync.Completed', "Sync cycle triggered (not waiting)", $stepName, @{
PolicyType = $policyType
})
}
@@ -207,9 +207,9 @@ function Invoke-IdleStepTriggerDirectorySync {
}
}
catch {
- $Context.EventSink.WriteEvent('DirectorySyncFailed', "Failed to trigger or wait for sync cycle: $_", $stepName, @{
+ $Context.EventSink.WriteEvent('IdLE.Step.DirectorySync.Failed', "Failed to trigger or wait for sync cycle: $_", $stepName, @{
Error = $_.Exception.Message
- })
+ }, 'Error')
throw
}
}
diff --git a/tests/Core/EventTypes.Tests.ps1 b/tests/Core/EventTypes.Tests.ps1
new file mode 100644
index 00000000..471f0925
--- /dev/null
+++ b/tests/Core/EventTypes.Tests.ps1
@@ -0,0 +1,269 @@
+Set-StrictMode -Version Latest
+
+BeforeAll {
+ . (Join-Path (Split-Path -Path $PSScriptRoot -Parent) '_testHelpers.ps1')
+ Import-IdleTestModule
+
+ function global:Invoke-IdleEventTypesFailStep {
+ [CmdletBinding()]
+ param(
+ [Parameter(Mandatory)] [object] $Context,
+ [Parameter(Mandatory)] [object] $Step
+ )
+
+ throw 'Boom'
+ }
+
+ function Invoke-EventTypesWorkflow {
+ param(
+ [Parameter(Mandatory)]
+ [string] $Content,
+
+ [Parameter()]
+ [string] $LifecycleEvent = 'Joiner',
+
+ [Parameter()]
+ [hashtable] $Providers = @{}
+ )
+
+ $wfPath = New-IdleTestWorkflowFile -FileName 'event-types.psd1' -Content $Content
+ $req = New-IdleTestRequest -LifecycleEvent $LifecycleEvent
+ $plan = New-IdlePlan -WorkflowPath $wfPath -Request $req -Providers $Providers
+ return Invoke-IdlePlan -Plan $plan -Providers $Providers
+ }
+
+ function Get-PreconditionEventWorkflow {
+ param(
+ [Parameter(Mandatory)]
+ [string] $EventBody
+ )
+
+ return @"
+@{
+ Name = 'Precondition event'
+ LifecycleEvent = 'Leaver'
+ Steps = @(
+ @{
+ Name = 'Emit'
+ Type = 'IdLE.Step.EmitEvent'
+ Precondition = @{ Equals = @{ Path = 'Plan.LifecycleEvent'; Value = 'Joiner' } }
+ OnPreconditionFalse = 'Continue'
+ PreconditionEvent = @{ $EventBody }
+ }
+ )
+}
+"@
+ }
+}
+
+AfterAll {
+ Remove-Item -Path 'Function:\Invoke-IdleEventTypesFailStep' -ErrorAction SilentlyContinue
+}
+
+Describe 'Event types and levels' {
+ Context 'Event object (New-IdleEvent)' {
+ It 'defaults Level to Information' {
+ InModuleScope 'IdLE.Core' {
+ $evt = New-IdleEvent -Type 'IdLE.Run.Started' -Message 'm'
+ $evt.Level | Should -Be 'Information'
+ }
+ }
+
+ It 'rejects the catch-all type <_>' -ForEach @('Information', 'Warning', 'Error', 'Custom') {
+ InModuleScope 'IdLE.Core' -Parameters @{ Type = $_ } {
+ param($Type)
+ { New-IdleEvent -Type $Type -Message 'm' } | Should -Throw -ExceptionType ([System.ArgumentException])
+ }
+ }
+
+ It 'rejects an unknown level' {
+ InModuleScope 'IdLE.Core' {
+ { New-IdleEvent -Type 'IdLE.Run.Started' -Message 'm' -Level 'Critical' } |
+ Should -Throw -ErrorId 'ParameterArgumentValidationError,New-IdleEvent'
+ }
+ }
+ }
+
+ Context 'Context.EventSink.WriteEvent' {
+ It 'keeps four-argument calls working and accepts an optional Level' {
+ InModuleScope 'IdLE.Core' {
+ $buffer = [System.Collections.Generic.List[object]]::new()
+ $sink = New-IdleEventSink -CorrelationId 'c1' -EventBuffer $buffer
+
+ $sink.WriteEvent('Contoso.IdLE.Hr.ManagerSynced', 'm', 'S1', @{})
+ $sink.WriteEvent('Contoso.IdLE.Hr.ManagerMissing', 'm', 'S1', @{}, 'Warning')
+
+ $buffer[0].Level | Should -Be 'Information'
+ $buffer[1].Level | Should -Be 'Warning'
+ }
+ }
+ }
+
+ Context 'Engine event levels' {
+ It 'emits Information events for a successful run' {
+ $result = Invoke-EventTypesWorkflow -Content @'
+@{
+ Name = 'Ok'
+ LifecycleEvent = 'Joiner'
+ Steps = @( @{ Name = 'Emit'; Type = 'IdLE.Step.EmitEvent' } )
+}
+'@
+
+ $result.Status | Should -Be 'Completed'
+ @($result.Events | ForEach-Object Type) | Should -Be @('IdLE.Run.Started', 'IdLE.Step.Started', 'IdLE.Step.EmitEvent.Emitted', 'IdLE.Step.Completed', 'IdLE.Run.Completed')
+ @($result.Events | Where-Object Level -ne 'Information').Count | Should -Be 0
+ }
+
+ It 'emits Error levels for a failed step and run' {
+ $providers = @{
+ StepRegistry = @{ 'Test.IdLE.Step.Fail' = 'Invoke-IdleEventTypesFailStep' }
+ StepMetadata = New-IdleTestStepMetadata -StepTypes @('Test.IdLE.Step.Fail')
+ }
+
+ $result = Invoke-EventTypesWorkflow -Providers $providers -Content @'
+@{
+ Name = 'Fail'
+ LifecycleEvent = 'Joiner'
+ Steps = @( @{ Name = 'Fail'; Type = 'Test.IdLE.Step.Fail' } )
+ OnFailureSteps = @( @{ Name = 'Cleanup'; Type = 'Test.IdLE.Step.Fail' } )
+}
+'@
+
+ $result.Status | Should -Be 'Failed'
+ ($result.Events | Where-Object Type -eq 'IdLE.Step.Failed').Level | Should -Be 'Error'
+ ($result.Events | Where-Object Type -eq 'IdLE.OnFailure.StepFailed').Level | Should -Be 'Error'
+ ($result.Events | Where-Object Type -eq 'IdLE.OnFailure.Completed').Level | Should -Be 'Warning'
+ ($result.Events | Where-Object Type -eq 'IdLE.Run.Completed').Level | Should -Be 'Error'
+ }
+
+ It 'emits Warning levels for a blocked step and run' {
+ $result = Invoke-EventTypesWorkflow -LifecycleEvent 'Leaver' -Content @'
+@{
+ Name = 'Blocked'
+ LifecycleEvent = 'Leaver'
+ Steps = @(
+ @{
+ Name = 'Emit'
+ Type = 'IdLE.Step.EmitEvent'
+ Precondition = @{ Equals = @{ Path = 'Plan.LifecycleEvent'; Value = 'Joiner' } }
+ }
+ )
+}
+'@
+
+ $result.Status | Should -Be 'Blocked'
+ ($result.Events | Where-Object Type -eq 'IdLE.Step.PreconditionFailed').Level | Should -Be 'Warning'
+ ($result.Events | Where-Object Type -eq 'IdLE.Step.Blocked').Level | Should -Be 'Warning'
+ ($result.Events | Where-Object Type -eq 'IdLE.Run.Completed').Level | Should -Be 'Warning'
+ }
+ }
+
+ Context 'Workflow-defined event types' {
+ It 'emits a PreconditionEvent with the configured Level' {
+ $content = Get-PreconditionEventWorkflow -EventBody "Type = 'Contoso.ManualActionRequired'; Message = 'Wipe device'; Level = 'Warning'"
+ $result = Invoke-EventTypesWorkflow -LifecycleEvent 'Leaver' -Content $content
+
+ $evt = $result.Events | Where-Object Type -eq 'Contoso.ManualActionRequired'
+ $evt.Level | Should -Be 'Warning'
+ }
+
+ It 'defaults the PreconditionEvent Level to Information' {
+ $content = Get-PreconditionEventWorkflow -EventBody "Type = 'Contoso.ManualActionRequired'; Message = 'Wipe device'"
+ $result = Invoke-EventTypesWorkflow -LifecycleEvent 'Leaver' -Content $content
+
+ ($result.Events | Where-Object Type -eq 'Contoso.ManualActionRequired').Level | Should -Be 'Information'
+ }
+
+ It 'rejects PreconditionEvent.Type at planning time ()' -ForEach @(
+ @{ Type = 'IdLE.Step.Blocked'; Code = 'ReservedNamespace' }
+ @{ Type = 'Warning'; Code = 'InvalidEventType' }
+ @{ Type = 'Custom'; Code = 'InvalidEventType' }
+ ) {
+ $content = Get-PreconditionEventWorkflow -EventBody "Type = '$Type'; Message = 'm'"
+ $wfPath = New-IdleTestWorkflowFile -FileName 'event-types-invalid.psd1' -Content $content
+ $req = New-IdleTestRequest -LifecycleEvent 'Leaver'
+
+ { New-IdlePlan -WorkflowPath $wfPath -Request $req } | Should -Throw "*PreconditionEvent.Type*${Code}:*"
+ }
+
+ It 'rejects an unknown PreconditionEvent.Level at planning time' {
+ $content = Get-PreconditionEventWorkflow -EventBody "Type = 'Contoso.ManualActionRequired'; Message = 'm'; Level = 'Critical'"
+ $wfPath = New-IdleTestWorkflowFile -FileName 'event-types-invalid.psd1' -Content $content
+ $req = New-IdleTestRequest -LifecycleEvent 'Leaver'
+
+ { New-IdlePlan -WorkflowPath $wfPath -Request $req } | Should -Throw '*PreconditionEvent.Level*'
+ }
+
+ It 'emits EmitEvent with the workflow-defined Type and Level' {
+ $result = Invoke-EventTypesWorkflow -Content @'
+@{
+ Name = 'Emit'
+ LifecycleEvent = 'Joiner'
+ Steps = @( @{ Name = 'Emit'; Type = 'IdLE.Step.EmitEvent'; With = @{ Type = 'Contoso.Joiner.Notified'; Level = 'Warning'; Message = 'Hi' } } )
+}
+'@
+
+ $evt = $result.Events | Where-Object Type -eq 'Contoso.Joiner.Notified'
+ $evt.Level | Should -Be 'Warning'
+ $evt.Message | Should -Be 'Hi'
+ }
+
+ It 'fails the EmitEvent step for a reserved or catch-all With.Type (<_>)' -ForEach @('IdLE.Run.Completed', 'Custom') {
+ $content = @"
+@{
+ Name = 'Emit'
+ LifecycleEvent = 'Joiner'
+ Steps = @( @{ Name = 'Emit'; Type = 'IdLE.Step.EmitEvent'; With = @{ Type = '$_' } } )
+}
+"@
+ $result = Invoke-EventTypesWorkflow -Content $content
+
+ $result.Status | Should -Be 'Failed'
+ $result.Steps[0].Status | Should -Be 'Failed'
+ }
+
+ It 'checks -> ' -ForEach @(
+ @{ Identifier = 'Contoso.ManualActionRequired'; Expected = $null }
+ @{ Identifier = 'ManualActionRequired'; Expected = $null }
+ @{ Identifier = 'IdLE.Step.Failed'; Expected = 'ReservedNamespace' }
+ @{ Identifier = 'idle.custom'; Expected = 'ReservedNamespace' }
+ @{ Identifier = 'Information'; Expected = 'InvalidEventType' }
+ @{ Identifier = 'Error'; Expected = 'InvalidEventType' }
+ ) {
+ InModuleScope 'IdLE.Core' -Parameters $_ {
+ param($Identifier, $Expected)
+
+ $namespaceError = Get-IdleIdentifierNamespaceError -Kind WorkflowEventType -Identifier $Identifier
+
+ if ($null -eq $Expected) {
+ $namespaceError | Should -BeNullOrEmpty
+ }
+ else {
+ $namespaceError | Should -BeLike "${Expected}:*"
+ }
+ }
+ }
+ }
+
+ Context 'Documentation' {
+ It 'documents every first-party event type emitted in src in docs/extend/events.md' {
+ $repoRoot = Get-RepoRootPath
+ $doc = Get-Content -Path (Join-Path $repoRoot 'docs/extend/events.md') -Raw
+
+ # Event types are the first literal of a WriteEvent(...) call (same line or the next one).
+ $emitted = foreach ($file in Get-ChildItem -Path (Join-Path $repoRoot 'src') -Filter '*.ps1' -Recurse -File) {
+ $lines = @(Get-Content -Path $file.FullName)
+ for ($i = 0; $i -lt $lines.Count; $i++) {
+ if ($lines[$i] -notmatch 'WriteEvent\(') { continue }
+ $window = $lines[$i] + ' ' + $(if ($i + 1 -lt $lines.Count) { $lines[$i + 1] } else { '' })
+ if ($window -match "WriteEvent\(\s*'(IdLE\.[A-Za-z.]+)'") { $Matches[1] }
+ }
+ }
+ $emitted = @($emitted | Sort-Object -Unique)
+
+ $emitted.Count | Should -BeGreaterThan 20
+ $undocumented = @($emitted | Where-Object { $doc -notmatch [regex]::Escape("``$_``") })
+ $undocumented | Should -BeNullOrEmpty
+ }
+ }
+}
diff --git a/tests/Core/Invoke-IdlePlan.Condition.Tests.ps1 b/tests/Core/Invoke-IdlePlan.Condition.Tests.ps1
index 2f22387b..a0dbce35 100644
--- a/tests/Core/Invoke-IdlePlan.Condition.Tests.ps1
+++ b/tests/Core/Invoke-IdlePlan.Condition.Tests.ps1
@@ -38,8 +38,8 @@ InModuleScope 'IdLE.Core' {
$result.Status | Should -Be 'Completed'
$result.Steps[0].Status | Should -Be 'NotApplicable'
- @($result.Events | Where-Object Type -eq 'Custom').Count | Should -Be 0
- @($result.Events | Where-Object Type -eq 'StepNotApplicable').Count | Should -Be 1
+ @($result.Events | Where-Object Type -eq 'IdLE.Step.EmitEvent.Emitted').Count | Should -Be 0
+ @($result.Events | Where-Object Type -eq 'IdLE.Step.NotApplicable').Count | Should -Be 1
}
It 'runs a step when condition is met' {
@@ -72,7 +72,7 @@ InModuleScope 'IdLE.Core' {
$result.Status | Should -Be 'Completed'
$result.Steps[0].Status | Should -Be 'Completed'
- ($result.Events | Where-Object Type -eq 'Custom').Count | Should -Be 1
+ ($result.Events | Where-Object Type -eq 'IdLE.Step.EmitEvent.Emitted').Count | Should -Be 1
}
}
}
diff --git a/tests/Core/Invoke-IdlePlan.ExecutionOptions.Tests.ps1 b/tests/Core/Invoke-IdlePlan.ExecutionOptions.Tests.ps1
index 39ea82d4..f3094874 100644
--- a/tests/Core/Invoke-IdlePlan.ExecutionOptions.Tests.ps1
+++ b/tests/Core/Invoke-IdlePlan.ExecutionOptions.Tests.ps1
@@ -262,7 +262,7 @@ Describe 'Invoke-IdlePlan - ExecutionOptions' {
$result.Status | Should -Be 'Completed'
$result.Steps[0].Status | Should -Be 'Completed'
$result.Steps[0].Attempts | Should -Be 2
- @($result.Events | Where-Object Type -eq 'StepRetrying').Count | Should -Be 1
+ @($result.Events | Where-Object Type -eq 'IdLE.Step.Retrying').Count | Should -Be 1
}
It 'uses DefaultRetryProfile when step does not specify RetryProfile' {
@@ -353,7 +353,7 @@ Describe 'Invoke-IdlePlan - ExecutionOptions' {
$result.Status | Should -Be 'Failed'
$result.Steps[0].Status | Should -Be 'Failed'
$result.Steps[0].Attempts | Should -Be 1
- @($result.Events | Where-Object Type -eq 'StepRetrying').Count | Should -Be 0
+ @($result.Events | Where-Object Type -eq 'IdLE.Step.Retrying').Count | Should -Be 0
Should -Invoke -ModuleName IdLE.Core -CommandName Start-Sleep -Times 0
}
diff --git a/tests/Core/Invoke-IdlePlan.Preconditions.Tests.ps1 b/tests/Core/Invoke-IdlePlan.Preconditions.Tests.ps1
index fdb57d9d..98b62892 100644
--- a/tests/Core/Invoke-IdlePlan.Preconditions.Tests.ps1
+++ b/tests/Core/Invoke-IdlePlan.Preconditions.Tests.ps1
@@ -95,7 +95,7 @@ Describe 'Invoke-IdlePlan - Runtime Preconditions' {
$result.Status | Should -Be 'Completed'
$result.Steps[0].Status | Should -Be 'Completed'
- @($result.Events | Where-Object Type -eq 'StepPreconditionFailed').Count | Should -Be 0
+ @($result.Events | Where-Object Type -eq 'IdLE.Step.PreconditionFailed').Count | Should -Be 0
}
}
@@ -113,7 +113,7 @@ Describe 'Invoke-IdlePlan - Runtime Preconditions' {
$result.Status | Should -Be 'Completed'
$result.Steps[0].Status | Should -Be 'Completed'
- @($result.Events | Where-Object Type -eq 'StepPreconditionFailed').Count | Should -Be 0
+ @($result.Events | Where-Object Type -eq 'IdLE.Step.PreconditionFailed').Count | Should -Be 0
}
}
@@ -136,8 +136,8 @@ Describe 'Invoke-IdlePlan - Runtime Preconditions' {
$result.Steps.Count | Should -Be 1
$result.Steps[0].Name | Should -Be 'Step1'
$result.Steps[0].Status | Should -Be 'Blocked'
- @($result.Events | Where-Object Type -eq 'StepPreconditionFailed').Count | Should -Be 1
- @($result.Events | Where-Object Type -eq 'StepBlocked').Count | Should -Be 1
+ @($result.Events | Where-Object Type -eq 'IdLE.Step.PreconditionFailed').Count | Should -Be 1
+ @($result.Events | Where-Object Type -eq 'IdLE.Step.Blocked').Count | Should -Be 1
@($result.Events | Where-Object Type -eq 'SecondStepRan').Count | Should -Be 0
}
@@ -176,8 +176,8 @@ Describe 'Invoke-IdlePlan - Runtime Preconditions' {
$result.Steps.Count | Should -Be 1
$result.Steps[0].Status | Should -Be 'Failed'
$result.Steps[0].Error | Should -Not -BeNullOrEmpty
- @($result.Events | Where-Object Type -eq 'StepPreconditionFailed').Count | Should -Be 1
- @($result.Events | Where-Object Type -eq 'StepFailed').Count | Should -Be 1
+ @($result.Events | Where-Object Type -eq 'IdLE.Step.PreconditionFailed').Count | Should -Be 1
+ @($result.Events | Where-Object Type -eq 'IdLE.Step.Failed').Count | Should -Be 1
@($result.Events | Where-Object Type -eq 'SecondStepRan').Count | Should -Be 0
}
}
@@ -206,7 +206,7 @@ Describe 'Invoke-IdlePlan - Runtime Preconditions' {
$result.Steps[1].Name | Should -Be 'Step2'
$result.Steps[1].Status | Should -Be 'Completed'
# Engine event is emitted for observability
- @($result.Events | Where-Object Type -eq 'StepPreconditionFailed').Count | Should -Be 1
+ @($result.Events | Where-Object Type -eq 'IdLE.Step.PreconditionFailed').Count | Should -Be 1
# Subsequent step ran
@($result.Events | Where-Object Type -eq 'SecondStepRan').Count | Should -Be 1
}
@@ -283,8 +283,8 @@ Describe 'Invoke-IdlePlan - Runtime Preconditions' {
$result.Status | Should -Be 'Blocked'
- # StepPreconditionFailed must be emitted
- $pcFailedEvent = $result.Events | Where-Object Type -eq 'StepPreconditionFailed'
+ # IdLE.Step.PreconditionFailed must be emitted
+ $pcFailedEvent = $result.Events | Where-Object Type -eq 'IdLE.Step.PreconditionFailed'
$pcFailedEvent | Should -Not -BeNullOrEmpty
# Configured PreconditionEvent should also be emitted with the declared Type/Message
@@ -348,7 +348,7 @@ Describe 'Invoke-IdlePlan - Runtime Preconditions' {
# OnFailure cleanup step was blocked by its precondition (Leaver != Joiner)
$result.OnFailure.Steps.Count | Should -Be 1
$result.OnFailure.Steps[0].Status | Should -Be 'Blocked'
- @($result.Events | Where-Object Type -eq 'StepPreconditionFailed').Count | Should -Be 2
+ @($result.Events | Where-Object Type -eq 'IdLE.Step.PreconditionFailed').Count | Should -Be 2
@($result.Events | Where-Object Type -eq 'OnFailureRan').Count | Should -Be 0
}
@@ -370,7 +370,7 @@ Describe 'Invoke-IdlePlan - Runtime Preconditions' {
# OnFailure cleanup step was skipped via Continue
$result.OnFailure.Steps.Count | Should -Be 1
$result.OnFailure.Steps[0].Status | Should -Be 'PreconditionSkipped'
- @($result.Events | Where-Object Type -eq 'StepPreconditionFailed').Count | Should -Be 2
+ @($result.Events | Where-Object Type -eq 'IdLE.Step.PreconditionFailed').Count | Should -Be 2
@($result.Events | Where-Object Type -eq 'OnFailureRan').Count | Should -Be 0
}
}
diff --git a/tests/Core/Invoke-IdlePlan.Retry.Tests.ps1 b/tests/Core/Invoke-IdlePlan.Retry.Tests.ps1
index 9b6eaafa..8bd58a33 100644
--- a/tests/Core/Invoke-IdlePlan.Retry.Tests.ps1
+++ b/tests/Core/Invoke-IdlePlan.Retry.Tests.ps1
@@ -122,7 +122,7 @@ Describe 'Invoke-IdlePlan - safe retries for transient failures (fail-fast)' {
$result.Status | Should -Be 'Completed'
$result.Steps[0].Status | Should -Be 'Completed'
- @($result.Events | Where-Object Type -eq 'StepRetrying').Count | Should -Be 1
+ @($result.Events | Where-Object Type -eq 'IdLE.Step.Retrying').Count | Should -Be 1
Should -Invoke -ModuleName IdLE.Core -CommandName Start-Sleep -Times 1 -Exactly
(& "$script:RetryTestModuleName\Get-IdleRetryTestTransientCallCount") | Should -Be 2
@@ -161,7 +161,7 @@ Describe 'Invoke-IdlePlan - safe retries for transient failures (fail-fast)' {
$result = Invoke-IdlePlan -Plan $plan -Providers $providers
$result.Status | Should -Be 'Failed'
- @($result.Events | Where-Object Type -eq 'StepRetrying').Count | Should -Be 0
+ @($result.Events | Where-Object Type -eq 'IdLE.Step.Retrying').Count | Should -Be 0
Should -Invoke -ModuleName IdLE.Core -CommandName Start-Sleep -Times 0
}
}
diff --git a/tests/Core/Invoke-IdlePlan.StepRegistry.Tests.ps1 b/tests/Core/Invoke-IdlePlan.StepRegistry.Tests.ps1
index 931df6d0..ca404068 100644
--- a/tests/Core/Invoke-IdlePlan.StepRegistry.Tests.ps1
+++ b/tests/Core/Invoke-IdlePlan.StepRegistry.Tests.ps1
@@ -35,7 +35,7 @@ Describe 'Invoke-IdlePlan - StepRegistry' {
$result.Status | Should -Be 'Completed'
@($result.Steps).Count | Should -Be 1
$result.Steps[0].Status | Should -Be 'Completed'
- ($result.Events | Where-Object Type -eq 'Custom').Count | Should -Be 1
+ ($result.Events | Where-Object Type -eq 'IdLE.Step.EmitEvent.Emitted').Count | Should -Be 1
}
}
}
diff --git a/tests/Core/Invoke-IdlePlan.Tests.ps1 b/tests/Core/Invoke-IdlePlan.Tests.ps1
index 18380566..af510ec9 100644
--- a/tests/Core/Invoke-IdlePlan.Tests.ps1
+++ b/tests/Core/Invoke-IdlePlan.Tests.ps1
@@ -40,7 +40,7 @@ BeforeAll {
[object] $Step
)
- $Context.EventSink.WriteEvent('Custom', 'Hello from test step', $Step.Name, @{ StepType = $Step.Type })
+ $Context.EventSink.WriteEvent('Test.IdLE.Emit.Emitted', 'Hello from test step', $Step.Name, @{ StepType = $Step.Type })
return [pscustomobject]@{
PSTypeName = 'IdLE.StepResult'
@@ -173,8 +173,8 @@ Describe 'Invoke-IdlePlan' {
@($result.Steps).Count | Should -Be 2
@($result.Events).Count | Should -BeGreaterThan 0
- $result.Events[0].Type | Should -Be 'RunStarted'
- $result.Events[-1].Type | Should -Be 'RunCompleted'
+ $result.Events[0].Type | Should -Be 'IdLE.Run.Started'
+ $result.Events[-1].Type | Should -Be 'IdLE.Run.Completed'
$result.Steps[0].Status | Should -Be 'Completed'
$result.Steps[1].Status | Should -Be 'Completed'
@@ -229,7 +229,7 @@ Describe 'Invoke-IdlePlan' {
$sinkEvents.Count | Should -BeGreaterThan 0
$sinkEvents[0].PSTypeNames | Should -Contain 'IdLE.Event'
- $result.Events[0].Type | Should -Be 'RunStarted'
+ $result.Events[0].Type | Should -Be 'IdLE.Run.Started'
}
}
@@ -260,7 +260,7 @@ Describe 'Invoke-IdlePlan' {
$result.Status | Should -Be 'Completed'
$result.Steps[0].Status | Should -Be 'Completed'
- ($result.Events | Where-Object Type -eq 'Custom').Count | Should -Be 1
+ ($result.Events | Where-Object Type -eq 'Test.IdLE.Emit.Emitted').Count | Should -Be 1
}
}
@@ -305,13 +305,13 @@ Describe 'Invoke-IdlePlan' {
$result.OnFailure.Steps[0].Status | Should -Be 'Completed'
$types = @($result.Events | ForEach-Object { $_.Type })
- $types | Should -Contain 'StepFailed'
- $types | Should -Contain 'OnFailureStarted'
- $types | Should -Contain 'OnFailureCompleted'
+ $types | Should -Contain 'IdLE.Step.Failed'
+ $types | Should -Contain 'IdLE.OnFailure.Started'
+ $types | Should -Contain 'IdLE.OnFailure.Completed'
- [array]::IndexOf($types, 'StepFailed') | Should -BeLessThan ([array]::IndexOf($types, 'OnFailureStarted'))
+ [array]::IndexOf($types, 'IdLE.Step.Failed') | Should -BeLessThan ([array]::IndexOf($types, 'IdLE.OnFailure.Started'))
- ($result.Events | Where-Object Type -eq 'Custom').Count | Should -Be 1
+ ($result.Events | Where-Object Type -eq 'Test.IdLE.Emit.Emitted').Count | Should -Be 1
}
It 'continues OnFailureSteps when an OnFailure step fails (best effort)' {
@@ -350,9 +350,9 @@ Describe 'Invoke-IdlePlan' {
$result.OnFailure.Steps[0].Status | Should -Be 'Failed'
$result.OnFailure.Steps[1].Status | Should -Be 'Completed'
- ($result.Events | Where-Object Type -eq 'OnFailureStepStarted').Count | Should -Be 2
- ($result.Events | Where-Object Type -eq 'OnFailureStepFailed').Count | Should -Be 1
- ($result.Events | Where-Object Type -eq 'OnFailureStepCompleted').Count | Should -Be 1
+ ($result.Events | Where-Object Type -eq 'IdLE.OnFailure.StepStarted').Count | Should -Be 2
+ ($result.Events | Where-Object Type -eq 'IdLE.OnFailure.StepFailed').Count | Should -Be 1
+ ($result.Events | Where-Object Type -eq 'IdLE.OnFailure.StepCompleted').Count | Should -Be 1
}
It 'does not execute OnFailureSteps when run completes successfully' {
@@ -387,8 +387,8 @@ Describe 'Invoke-IdlePlan' {
$result.OnFailure.Status | Should -Be 'NotRun'
@($result.OnFailure.Steps).Count | Should -Be 0
- @($result.Events | Where-Object Type -like 'OnFailure*').Count | Should -Be 0
- @($result.Events | Where-Object Type -eq 'Custom').Count | Should -Be 0
+ @($result.Events | Where-Object Type -like 'IdLE.OnFailure.*').Count | Should -Be 0
+ @($result.Events | Where-Object Type -eq 'Test.IdLE.Emit.Emitted').Count | Should -Be 0
}
}
diff --git a/tests/Core/StepPackHandlerRegistration.Tests.ps1 b/tests/Core/StepPackHandlerRegistration.Tests.ps1
index 1db78632..3c1a5cf2 100644
--- a/tests/Core/StepPackHandlerRegistration.Tests.ps1
+++ b/tests/Core/StepPackHandlerRegistration.Tests.ps1
@@ -39,7 +39,7 @@ function Invoke-ContosoStepHello {
[Parameter(Mandatory)] [object] $Step
)
- $Context.EventSink.WriteEvent('Custom', 'Hello from step pack', $Step.Name, @{})
+ $Context.EventSink.WriteEvent('Test.IdLE.StepPack.Hello', 'Hello from step pack', $Step.Name, @{})
return [pscustomobject]@{
PSTypeName = 'IdLE.StepResult'
diff --git a/tests/Providers/ExchangeOnlineProvider.Tests.ps1 b/tests/Providers/ExchangeOnlineProvider.Tests.ps1
index aff6119a..93cb8ea7 100644
--- a/tests/Providers/ExchangeOnlineProvider.Tests.ps1
+++ b/tests/Providers/ExchangeOnlineProvider.Tests.ps1
@@ -878,9 +878,9 @@ Describe 'ExchangeOnline provider - Unit tests' {
$provider.EventSink = $null
- $evalEvents = @($script:capturedEvents | Where-Object { $_.Type -eq 'Provider.ExchangeOnline.Permissions.Evaluated' })
- $applyEvents = @($script:capturedEvents | Where-Object { $_.Type -eq 'Provider.ExchangeOnline.Permissions.Applying' })
- $resultEvents = @($script:capturedEvents | Where-Object { $_.Type -eq 'Provider.ExchangeOnline.Permissions.Result' })
+ $evalEvents = @($script:capturedEvents | Where-Object { $_.Type -eq 'IdLE.Provider.ExchangeOnline.PermissionsEvaluated' })
+ $applyEvents = @($script:capturedEvents | Where-Object { $_.Type -eq 'IdLE.Provider.ExchangeOnline.PermissionChanging' })
+ $resultEvents = @($script:capturedEvents | Where-Object { $_.Type -eq 'IdLE.Provider.ExchangeOnline.PermissionsEnsured' })
$evalEvents.Count | Should -BeGreaterOrEqual 1
$applyEvents.Count | Should -Be 1
diff --git a/tests/Steps/Invoke-IdleStepPruneEntitlements.Tests.ps1 b/tests/Steps/Invoke-IdleStepPruneEntitlements.Tests.ps1
index 270570d2..b40865f4 100644
--- a/tests/Steps/Invoke-IdleStepPruneEntitlements.Tests.ps1
+++ b/tests/Steps/Invoke-IdleStepPruneEntitlements.Tests.ps1
@@ -252,7 +252,7 @@ Describe 'Invoke-IdleStepPruneEntitlements (built-in step)' {
$script:Context.EventSink = [pscustomobject]@{
WriteEvent = {
param($Type, $Message, $StepName, $Data)
- if ($Type -eq 'Warning') {
+ if ($Type -eq 'IdLE.Step.PruneEntitlements.EntitlementSkipped') {
$script:warningEvents += $Message
}
}.GetNewClosure()
diff --git a/tests/Steps/Invoke-IdleStepTriggerDirectorySync.Tests.ps1 b/tests/Steps/Invoke-IdleStepTriggerDirectorySync.Tests.ps1
index 8c246765..690a54f9 100644
--- a/tests/Steps/Invoke-IdleStepTriggerDirectorySync.Tests.ps1
+++ b/tests/Steps/Invoke-IdleStepTriggerDirectorySync.Tests.ps1
@@ -351,7 +351,7 @@ Describe 'Invoke-IdleStepTriggerDirectorySync (DirectorySync step)' {
}
Context 'Event emission' {
- It 'emits DirectorySyncTriggered event' {
+ It 'emits IdLE.Step.DirectorySync.Triggered event' {
$capturedEvents = [System.Collections.ArrayList]::new()
$script:Context.EventSink = [pscustomobject]@{}
$script:Context.EventSink | Add-Member -MemberType ScriptMethod -Name WriteEvent -Value {
@@ -362,7 +362,7 @@ Describe 'Invoke-IdleStepTriggerDirectorySync (DirectorySync step)' {
$handler = 'IdLE.Steps.DirectorySync\Invoke-IdleStepTriggerDirectorySync'
$null = & $handler -Context $script:Context -Step $script:StepTemplate
- $capturedEvents.Type | Should -Contain 'DirectorySyncTriggered'
+ $capturedEvents.Type | Should -Contain 'IdLE.Step.DirectorySync.Triggered'
}
It 'emits readable trigger message when With.PolicyType is omitted' {
@@ -380,11 +380,11 @@ Describe 'Invoke-IdleStepTriggerDirectorySync (DirectorySync step)' {
$handler = 'IdLE.Steps.DirectorySync\Invoke-IdleStepTriggerDirectorySync'
$null = & $handler -Context $script:Context -Step $step
- $triggerEvent = $capturedEvents | Where-Object { $_.Type -eq 'DirectorySyncTriggered' } | Select-Object -First 1
+ $triggerEvent = $capturedEvents | Where-Object { $_.Type -eq 'IdLE.Step.DirectorySync.Triggered' } | Select-Object -First 1
$triggerEvent.Message | Should -Be 'Triggering directory sync cycle'
}
- It 'emits string values in DirectorySyncTriggered event data for PolicyType and ComputerName' {
+ It 'emits string values in IdLE.Step.DirectorySync.Triggered event data for PolicyType and ComputerName' {
$capturedEvents = [System.Collections.ArrayList]::new()
$script:Context.EventSink = [pscustomobject]@{}
$script:Context.EventSink | Add-Member -MemberType ScriptMethod -Name WriteEvent -Value {
@@ -399,12 +399,12 @@ Describe 'Invoke-IdleStepTriggerDirectorySync (DirectorySync step)' {
$handler = 'IdLE.Steps.DirectorySync\Invoke-IdleStepTriggerDirectorySync'
$null = & $handler -Context $script:Context -Step $step
- $triggerEvent = $capturedEvents | Where-Object { $_.Type -eq 'DirectorySyncTriggered' } | Select-Object -First 1
+ $triggerEvent = $capturedEvents | Where-Object { $_.Type -eq 'IdLE.Step.DirectorySync.Triggered' } | Select-Object -First 1
$triggerEvent.Data.PolicyType | Should -Be '123'
$triggerEvent.Data.ComputerName | Should -Be '456'
}
- It 'emits DirectorySyncCompleted event' {
+ It 'emits IdLE.Step.DirectorySync.Completed event' {
$capturedEvents = [System.Collections.ArrayList]::new()
$script:Context.EventSink = [pscustomobject]@{}
$script:Context.EventSink | Add-Member -MemberType ScriptMethod -Name WriteEvent -Value {
@@ -415,10 +415,10 @@ Describe 'Invoke-IdleStepTriggerDirectorySync (DirectorySync step)' {
$handler = 'IdLE.Steps.DirectorySync\Invoke-IdleStepTriggerDirectorySync'
$null = & $handler -Context $script:Context -Step $script:StepTemplate
- $capturedEvents.Type | Should -Contain 'DirectorySyncCompleted'
+ $capturedEvents.Type | Should -Contain 'IdLE.Step.DirectorySync.Completed'
}
- It 'emits DirectorySyncWaiting event when waiting' {
+ It 'emits IdLE.Step.DirectorySync.Waiting event when waiting' {
$capturedEvents = [System.Collections.ArrayList]::new()
$script:Context.EventSink = [pscustomobject]@{}
$script:Context.EventSink | Add-Member -MemberType ScriptMethod -Name WriteEvent -Value {
@@ -433,7 +433,7 @@ Describe 'Invoke-IdleStepTriggerDirectorySync (DirectorySync step)' {
$handler = 'IdLE.Steps.DirectorySync\Invoke-IdleStepTriggerDirectorySync'
$null = & $handler -Context $script:Context -Step $step
- $capturedEvents.Type | Should -Contain 'DirectorySyncWaiting'
+ $capturedEvents.Type | Should -Contain 'IdLE.Step.DirectorySync.Waiting'
}
}
}