| 111 | }; |
| 112 | |
| 113 | const frameFor = (report, target) => { |
| 114 | const payload = report.ok |
| 115 | ? report.scope === "realm" |
| 116 | ? { tiers: report.tiers } |
| 117 | : { variants: report.variants } |
| 118 | : null; |
| 119 | |
| 120 | return { |
| 121 | scope: target.scope, |
| 122 | realm: target.realm, |
| 123 | niche: target.niche ?? null, |
| 124 | family: target.family, |
| 125 | opsVersion: report.opsVersion ?? 1, |
| 126 | level: report.level ?? target.level ?? null, |
| 127 | sourceHash: report.sourceHash ?? null, |
| 128 | payloadHash: payload ? hashSource(JSON.stringify(payload)) : null, |
| 129 | budget: report.budget ?? null, |
| 130 | usage: report.usage ?? null, |
| 131 | warnings: report.warnings ?? [], |
| 132 | errors: report.errors ?? [], |
| 133 | ...(payload ? { payload } : null), |
| 134 | }; |
| 135 | }; |
| 136 | |
| 137 | const withoutPayload = ({ payload: _payload, ...report }) => report; |
| 138 | |