@remit/backend 2.2.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { ClassificationConfigured, ClassificationNotConfigured, ClassificationPreset, UpdateUserSettingsInput } from "@remit/api-openapi-types";
|
|
2
2
|
import type { IAccountSettingRepository } from "@remit/data-ports";
|
|
3
|
+
import { type ClassificationLabelDeps } from "@remit/mailbox-service";
|
|
3
4
|
import { type SecretsService } from "@remit/secrets-service";
|
|
4
5
|
import type { UserSettingsOutcome } from "./user-settings.js";
|
|
5
6
|
export declare const CLASSIFICATION_SETTING_NAMES: readonly ["ClassificationPresetId", "ClassificationModel", "ClassificationBaseUrl", "ClassificationApiKey", "ClassificationEnabled", "ClassificationDailyLimit"];
|
|
6
7
|
export type ClassificationSettingsDeps = {
|
|
7
8
|
accountSetting: Pick<IAccountSettingRepository, "getMany" | "upsert" | "delete">;
|
|
8
9
|
secrets: Pick<SecretsService, "encrypt">;
|
|
10
|
+
label: ClassificationLabelDeps;
|
|
9
11
|
};
|
|
10
12
|
export type StoredClassification = ClassificationNotConfigured | ClassificationConfigured;
|
|
11
13
|
type Refusal = Extract<UserSettingsOutcome, {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { parseAccountSettingValue } from "@remit/data-ports/account-settings";
|
|
2
2
|
import { CLASSIFICATION_PRESETS, DEFAULT_CLASSIFICATION_DAILY_LIMIT, isClassificationPresetId, } from "@remit/data-ports/classification-presets";
|
|
3
3
|
import { AccountSettingName } from "@remit/domain-enums";
|
|
4
|
+
import { ensureClassificationLabels, } from "@remit/mailbox-service";
|
|
4
5
|
import { serializeEncryptedPayload, } from "@remit/secrets-service";
|
|
5
6
|
export const CLASSIFICATION_SETTING_NAMES = [
|
|
6
7
|
AccountSettingName.ClassificationPresetId,
|
|
@@ -167,6 +168,9 @@ export const writeClassificationChange = async (deps, accountConfigId, change) =
|
|
|
167
168
|
value: { kind: "Boolean", value: change.enabled },
|
|
168
169
|
});
|
|
169
170
|
}
|
|
171
|
+
if (change.enabled === true) {
|
|
172
|
+
await ensureClassificationLabels(deps.label, accountConfigId);
|
|
173
|
+
}
|
|
170
174
|
if (change.dailyLimit !== undefined) {
|
|
171
175
|
await deps.accountSetting.upsert({
|
|
172
176
|
accountConfigId,
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { UpdateUserSettingsInput, UserSettingsResponse } from "@remit/api-openapi-types";
|
|
2
2
|
import type { IAccountRepository, IAccountSettingRepository } from "@remit/data-ports";
|
|
3
|
+
import type { ClassificationLabelDeps } from "@remit/mailbox-service";
|
|
3
4
|
import type { SecretsService } from "@remit/secrets-service";
|
|
4
5
|
import type { OperationHandler, UserSettingsOperationIds } from "../types.js";
|
|
5
6
|
export interface UserSettingsDeps {
|
|
6
7
|
accountSetting: Pick<IAccountSettingRepository, "get" | "getMany" | "upsert" | "delete">;
|
|
7
8
|
accounts: Pick<IAccountRepository, "listAllByAccountConfig">;
|
|
8
9
|
secrets: Pick<SecretsService, "encrypt">;
|
|
10
|
+
label: ClassificationLabelDeps;
|
|
9
11
|
}
|
|
10
12
|
/** The account the reader chose to send invitations from, if they chose one. */
|
|
11
13
|
export declare const chosenInvitationSender: (accountSetting: Pick<IAccountSettingRepository, "get">, accountConfigId: string) => Promise<string | undefined>;
|
|
@@ -48,6 +48,7 @@ const depsOf = (ctx) => ({
|
|
|
48
48
|
accountSetting: ctx.client.accountSetting,
|
|
49
49
|
accounts: ctx.client.account,
|
|
50
50
|
secrets: ctx.client.secrets,
|
|
51
|
+
label: ctx.client.label,
|
|
51
52
|
});
|
|
52
53
|
export const UserSettingsOperations = {
|
|
53
54
|
UserSettingsOperations_getUserSettings: async (_context, ctx) => readUserSettings(depsOf(ctx), ctx.identity.accountConfigId),
|