TenantAtlas/apps/platform/.pnpm-store/v10/files/78/cd48692ccd3e27579bfb55438256aa7961411dc6f53b39e7c63210fb8664fd53d8b1c745fbaf1872fbfe5c2303649ccd7620751e614aff4f12cddddf5a9f57
ahmido 1fec9c6f9d
Some checks failed
Main Confidence / confidence (push) Failing after 45s
feat: compress governance operator outcomes (#253)
## Summary
- introduce surface-aware compressed governance outcomes and reuse the shared truth/explanation seams for operator-first summaries
- apply the compressed outcome hierarchy across baseline, evidence, review, review-pack, canonical review/evidence, and artifact-oriented operation-run surfaces
- expand spec 214 fixtures and Pest coverage, and fix tenant-panel route assertions by generating explicit tenant-panel URLs in the affected Filament tests

## Validation
- `cd apps/platform && ./vendor/bin/sail bin pint --dirty --format agent`
- focused governance compression suite from `specs/214-governance-outcome-compression/quickstart.md` passed (`68` tests, `445` assertions)
- `cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Feature/Filament/InventoryItemResourceTest.php tests/Feature/Filament/BackupSetUiEnforcementTest.php tests/Feature/Filament/RestoreRunUiEnforcementTest.php` passed (`18` tests, `81` assertions)

Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de>
Reviewed-on: #253
2026-04-19 12:30:36 +00:00

73 lines
2.2 KiB
Plaintext

import { innerFrom } from '../observable/innerFrom';
import { MonoTypeOperatorFunction, ObservableInput } from '../types';
import { operate } from '../util/lift';
import { noop } from '../util/noop';
import { createOperatorSubscriber } from './OperatorSubscriber';
/**
* Emits the most recently emitted value from the source Observable whenever
* another Observable, the `notifier`, emits.
*
* <span class="informal">It's like {@link sampleTime}, but samples whenever
* the `notifier` `ObservableInput` emits something.</span>
*
* ![](sample.png)
*
* Whenever the `notifier` `ObservableInput` emits a value, `sample`
* looks at the source Observable and emits whichever value it has most recently
* emitted since the previous sampling, unless the source has not emitted
* anything since the previous sampling. The `notifier` is subscribed to as soon
* as the output Observable is subscribed.
*
* ## Example
*
* On every click, sample the most recent `seconds` timer
*
* ```ts
* import { fromEvent, interval, sample } from 'rxjs';
*
* const seconds = interval(1000);
* const clicks = fromEvent(document, 'click');
* const result = seconds.pipe(sample(clicks));
*
* result.subscribe(x => console.log(x));
* ```
*
* @see {@link audit}
* @see {@link debounce}
* @see {@link sampleTime}
* @see {@link throttle}
*
* @param notifier The `ObservableInput` to use for sampling the
* source Observable.
* @return A function that returns an Observable that emits the results of
* sampling the values emitted by the source Observable whenever the notifier
* Observable emits value or completes.
*/
export function sample<T>(notifier: ObservableInput<any>): MonoTypeOperatorFunction<T> {
return operate((source, subscriber) => {
let hasValue = false;
let lastValue: T | null = null;
source.subscribe(
createOperatorSubscriber(subscriber, (value) => {
hasValue = true;
lastValue = value;
})
);
innerFrom(notifier).subscribe(
createOperatorSubscriber(
subscriber,
() => {
if (hasValue) {
hasValue = false;
const value = lastValue!;
lastValue = null;
subscriber.next(value);
}
},
noop
)
);
});
}