@@ -756,33 +756,15 @@ export interface DeclaredSecretValue {
756756}
757757
758758/**
759- * The secret values of a list section's declared value, one `extract` per entry. The engine hands it zod's output
760- * (engine/validate.ts after the shape parse, engine/secrets.ts the validated document), but the erased list
761- * declaration and a library caller of sectionModule() reach it as `unknown`, so a malformed container or entry
762- * contributes nothing rather than throwing, and the actionable error always comes from validation.
763- */
764- export function secretValuesOf (
765- declared : unknown ,
766- extract : ( entry : Readonly < Record < string , unknown > > ) => readonly DeclaredSecretValue [ ] ,
759+ * The secret values of a list section's declared value in either form, one `extract` per entry. Every caller hands
760+ * it zod's output (engine/validate.ts after the shape parse, engine/secrets.ts the validated document), so the
761+ * entries are the section's own type and a malformed value is validation's to report, never this walk's.
762+ */
763+ export function secretValuesOf < E > (
764+ declared : readonly E [ ] | { readonly entries : readonly E [ ] } ,
765+ extract : ( entry : E ) => readonly DeclaredSecretValue [ ] ,
767766) : DeclaredSecretValue [ ] {
768- const isWrapper =
769- typeof declared === "object" &&
770- declared !== null &&
771- ! Array . isArray ( declared ) &&
772- Array . isArray ( ( declared as { entries ?: unknown } ) . entries ) ;
773- if ( ! Array . isArray ( declared ) && ! isWrapper ) {
774- return [ ] ;
775- }
776- // "keep" is a placeholder: only the entries are read.
777- const { entries } = undeclaredPolicy (
778- declared as readonly unknown [ ] | UndeclaredPolicyList < unknown > ,
779- "keep" ,
780- ) ;
781- return entries . flatMap ( ( entry ) =>
782- typeof entry === "object" && entry !== null && ! Array . isArray ( entry )
783- ? [ ...extract ( entry as Readonly < Record < string , unknown > > ) ]
784- : [ ] ,
785- ) ;
767+ return listEntries ( declared ) . flatMap ( ( entry ) => [ ...extract ( entry ) ] ) ;
786768}
787769
788770/**
0 commit comments