mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-02 22:52:58 +00:00
refactor(server): the legacy featureValues folds take one named-input object
This commit is contained in:
@@ -1377,7 +1377,10 @@ export class AgentManager {
|
||||
});
|
||||
// COMPAT(featureValues): added in v0.15.0, remove after 2027-05-01. A plugin written
|
||||
// against the previous SDK edits `config.featureValues`.
|
||||
config = { ...foldHookFeatureValues(request.config, sent), internal: config.internal };
|
||||
config = {
|
||||
...foldHookFeatureValues({ returned: request.config, sent }),
|
||||
internal: config.internal,
|
||||
};
|
||||
options = { ...options, env: request.env };
|
||||
}
|
||||
await this.deleteAgentState(resolvedAgentId);
|
||||
|
||||
@@ -67,7 +67,8 @@ export function exposeFeatureValuesToHook<
|
||||
|
||||
export function foldHookFeatureValues<
|
||||
T extends { providerOptions?: ProviderOptions | null; featureValues?: Record<string, unknown> },
|
||||
>(returned: T, sent: T): Omit<T, "featureValues"> {
|
||||
>(input: { returned: T; sent: T }): Omit<T, "featureValues"> {
|
||||
const { returned, sent } = input;
|
||||
const { featureValues, ...rest } = returned;
|
||||
const before = sent.featureValues;
|
||||
if (!before) {
|
||||
@@ -104,11 +105,12 @@ interface ProfileOptionFields {
|
||||
* moved to another provider starts from no options, because the old provider's keys mean
|
||||
* nothing to the new one.
|
||||
*/
|
||||
export function foldProfileFeatureValues<T extends ProfileOptionFields>(
|
||||
profile: T,
|
||||
stored: ProfileOptionFields | undefined,
|
||||
source: "stored" | "client write" = "stored",
|
||||
): Omit<T, "featureValues"> {
|
||||
export function foldProfileFeatureValues<T extends ProfileOptionFields>(input: {
|
||||
profile: T;
|
||||
stored: ProfileOptionFields | undefined;
|
||||
source: "stored" | "client write";
|
||||
}): Omit<T, "featureValues"> {
|
||||
const { profile, stored, source } = input;
|
||||
const { featureValues, ...rest } = profile;
|
||||
if (source === "stored") {
|
||||
return featureValues ? { ...rest, options: { ...featureValues, ...rest.options } } : rest;
|
||||
|
||||
@@ -183,11 +183,11 @@ function foldConfigProfiles<T extends { agentProfiles?: AgentProfile[] }>(
|
||||
return {
|
||||
...config,
|
||||
agentProfiles: config.agentProfiles.map((profile) =>
|
||||
foldProfileFeatureValues(
|
||||
foldProfileFeatureValues({
|
||||
profile,
|
||||
held.find((candidate) => candidate.id === profile.id),
|
||||
stored: held.find((candidate) => candidate.id === profile.id),
|
||||
source,
|
||||
),
|
||||
}),
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user