TenantAtlas/apps/platform/.pnpm-store/v10/files/08/0e2392447ee8834965317df7a975d9f7e3610228194cb755bd1106f4a72a54c7399a0e4c6e6c56164ab03251c083ef6e7627969df69bcd45253dfc9f39da9b
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

72 lines
2.2 KiB
Plaintext

import { MonoTypeOperatorFunction } from '../types';
import { EMPTY } from '../observable/empty';
import { operate } from '../util/lift';
import { createOperatorSubscriber } from './OperatorSubscriber';
/**
* Emits only the first `count` values emitted by the source Observable.
*
* <span class="informal">Takes the first `count` values from the source, then
* completes.</span>
*
* ![](take.png)
*
* `take` returns an Observable that emits only the first `count` values emitted
* by the source Observable. If the source emits fewer than `count` values then
* all of its values are emitted. After that, it completes, regardless if the
* source completes.
*
* ## Example
*
* Take the first 5 seconds of an infinite 1-second interval Observable
*
* ```ts
* import { interval, take } from 'rxjs';
*
* const intervalCount = interval(1000);
* const takeFive = intervalCount.pipe(take(5));
* takeFive.subscribe(x => console.log(x));
*
* // Logs:
* // 0
* // 1
* // 2
* // 3
* // 4
* ```
*
* @see {@link takeLast}
* @see {@link takeUntil}
* @see {@link takeWhile}
* @see {@link skip}
*
* @param count The maximum number of `next` values to emit.
* @return A function that returns an Observable that emits only the first
* `count` values emitted by the source Observable, or all of the values from
* the source if the source emits fewer than `count` values.
*/
export function take<T>(count: number): MonoTypeOperatorFunction<T> {
return count <= 0
? // If we are taking no values, that's empty.
() => EMPTY
: operate((source, subscriber) => {
let seen = 0;
source.subscribe(
createOperatorSubscriber(subscriber, (value) => {
// Increment the number of values we have seen,
// then check it against the allowed count to see
// if we are still letting values through.
if (++seen <= count) {
subscriber.next(value);
// If we have met or passed our allowed count,
// we need to complete. We have to do <= here,
// because re-entrant code will increment `seen` twice.
if (count <= seen) {
subscriber.complete();
}
}
})
);
});
}