@fiado/type-kit 3.508.0 → 3.510.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.
- package/_test_/unit/dynamicForm/dynamicForm.test.ts +78 -0
- package/_test_/unit/platformRbac/dtos/roleAssignmentsByScopeRefsDtos.test.ts +49 -0
- package/_test_/unit/retailOrg/dtos/sellerTableSources.test.ts +17 -0
- package/_test_/unit/retailWizard/sellerTableShapes.test.ts +9 -2
- package/_test_/unit/rewards/enums.test.ts +87 -0
- package/_test_/unit/rewards/grantMessages.test.ts +123 -0
- package/_test_/unit/rewards/readResponses.test.ts +136 -0
- package/_test_/unit/rewardsEligibility/events.test.ts +130 -0
- package/bin/benefitCenter/dtos/InputField.d.ts +1 -13
- package/bin/benefitCenter/dtos/InputField.js +3 -3
- package/bin/benefitCenter/dtos/InputSchema.d.ts +1 -6
- package/bin/benefitCenter/dtos/InputSchema.js +3 -3
- package/bin/benefitCenter/dtos/InputValidation.d.ts +1 -8
- package/bin/benefitCenter/dtos/InputValidation.js +3 -3
- package/bin/benefitCenter/dtos/SelectOption.d.ts +1 -4
- package/bin/benefitCenter/dtos/SelectOption.js +3 -3
- package/bin/benefitCenter/enums/InputFieldTypeEnum.d.ts +1 -10
- package/bin/benefitCenter/enums/InputFieldTypeEnum.js +3 -11
- package/bin/common/index.d.ts +1 -0
- package/bin/common/index.js +2 -0
- package/bin/common/types/JsonValue.d.ts +7 -0
- package/bin/common/types/JsonValue.js +2 -0
- package/bin/dynamicForm/dtos/InputField.d.ts +15 -0
- package/bin/dynamicForm/dtos/InputField.js +6 -0
- package/bin/dynamicForm/dtos/InputSchema.d.ts +6 -0
- package/bin/dynamicForm/dtos/InputSchema.js +6 -0
- package/bin/dynamicForm/dtos/InputValidation.d.ts +8 -0
- package/bin/dynamicForm/dtos/InputValidation.js +6 -0
- package/bin/dynamicForm/dtos/SelectOption.d.ts +4 -0
- package/bin/dynamicForm/dtos/SelectOption.js +6 -0
- package/bin/dynamicForm/enums/InputFieldTypeEnum.d.ts +18 -0
- package/bin/dynamicForm/enums/InputFieldTypeEnum.js +22 -0
- package/bin/dynamicForm/helpers/isDynamicFormValue.d.ts +7 -0
- package/bin/dynamicForm/helpers/isDynamicFormValue.js +19 -0
- package/bin/dynamicForm/index.d.ts +8 -0
- package/bin/dynamicForm/index.js +29 -0
- package/bin/dynamicForm/types/DynamicFormValue.d.ts +10 -0
- package/bin/dynamicForm/types/DynamicFormValue.js +2 -0
- package/bin/dynamicForm/validators/IsDynamicFormValues.d.ts +7 -0
- package/bin/dynamicForm/validators/IsDynamicFormValues.js +26 -0
- package/bin/index.d.ts +3 -0
- package/bin/index.js +12 -1
- package/bin/platformRbac/dtos/RoleAssignmentsByScopeRefsRequest.d.ts +4 -0
- package/bin/platformRbac/dtos/RoleAssignmentsByScopeRefsRequest.js +25 -0
- package/bin/platformRbac/dtos/RoleAssignmentsByScopeRefsResponse.d.ts +16 -0
- package/bin/platformRbac/dtos/RoleAssignmentsByScopeRefsResponse.js +2 -0
- package/bin/platformRbac/enums/ScopeRefLookupStatusEnum.d.ts +5 -0
- package/bin/platformRbac/enums/ScopeRefLookupStatusEnum.js +9 -0
- package/bin/platformRbac/index.d.ts +3 -0
- package/bin/platformRbac/index.js +3 -0
- package/bin/retailOrg/dtos/validation/PrivateSellerListResponse.d.ts +5 -1
- package/bin/retailWizard/dtos/responses/BackofficeSellerTableResponse.d.ts +21 -2
- package/bin/retailWizard/enums/SellerTableSourceStatusEnum.d.ts +3 -2
- package/bin/retailWizard/enums/SellerTableSourceStatusEnum.js +2 -1
- package/bin/rewards/constants/RewardsLimits.d.ts +2 -0
- package/bin/rewards/constants/RewardsLimits.js +5 -0
- package/bin/rewards/dtos/GrantFailedMessage.d.ts +13 -0
- package/bin/rewards/dtos/GrantFailedMessage.js +46 -0
- package/bin/rewards/dtos/GrantRequestedMessage.d.ts +21 -0
- package/bin/rewards/dtos/GrantRequestedMessage.js +61 -0
- package/bin/rewards/dtos/RewardChargeTo.d.ts +5 -0
- package/bin/rewards/dtos/RewardChargeTo.js +7 -0
- package/bin/rewards/dtos/RewardCost.d.ts +6 -0
- package/bin/rewards/dtos/RewardCost.js +7 -0
- package/bin/rewards/dtos/RewardDependency.d.ts +17 -0
- package/bin/rewards/dtos/RewardDependency.js +12 -0
- package/bin/rewards/dtos/RewardSource.d.ts +12 -0
- package/bin/rewards/dtos/RewardSource.js +40 -0
- package/bin/rewards/dtos/responses/GrantAttemptResponse.d.ts +15 -0
- package/bin/rewards/dtos/responses/GrantAttemptResponse.js +10 -0
- package/bin/rewards/dtos/responses/GrantItemResponse.d.ts +20 -0
- package/bin/rewards/dtos/responses/GrantItemResponse.js +6 -0
- package/bin/rewards/dtos/responses/GrantResponse.d.ts +23 -0
- package/bin/rewards/dtos/responses/GrantResponse.js +7 -0
- package/bin/rewards/dtos/responses/PackageContractItem.d.ts +12 -0
- package/bin/rewards/dtos/responses/PackageContractItem.js +7 -0
- package/bin/rewards/dtos/responses/PackageContractResponse.d.ts +13 -0
- package/bin/rewards/dtos/responses/PackageContractResponse.js +7 -0
- package/bin/rewards/enums/DependencyIfMissingEnum.d.ts +5 -0
- package/bin/rewards/enums/DependencyIfMissingEnum.js +9 -0
- package/bin/rewards/enums/GrantFailedReasonEnum.d.ts +11 -0
- package/bin/rewards/enums/GrantFailedReasonEnum.js +15 -0
- package/bin/rewards/enums/GrantItemStatusEnum.d.ts +6 -0
- package/bin/rewards/enums/GrantItemStatusEnum.js +10 -0
- package/bin/rewards/enums/GrantRejectReasonEnum.d.ts +6 -0
- package/bin/rewards/enums/GrantRejectReasonEnum.js +10 -0
- package/bin/rewards/enums/GrantStatusEnum.d.ts +8 -0
- package/bin/rewards/enums/GrantStatusEnum.js +12 -0
- package/bin/rewards/enums/ItemErrorCategoryEnum.d.ts +7 -0
- package/bin/rewards/enums/ItemErrorCategoryEnum.js +11 -0
- package/bin/rewards/enums/RewardStatusEnum.d.ts +4 -0
- package/bin/rewards/enums/RewardStatusEnum.js +8 -0
- package/bin/rewards/enums/RewardsErrorCodeEnum.d.ts +5 -0
- package/bin/rewards/enums/RewardsErrorCodeEnum.js +9 -0
- package/bin/rewards/enums/RewardsMessageTypeEnum.d.ts +4 -0
- package/bin/rewards/enums/RewardsMessageTypeEnum.js +8 -0
- package/bin/rewards/index.d.ts +24 -0
- package/bin/rewards/index.js +47 -0
- package/bin/rewards/types/RewardInputs.d.ts +3 -0
- package/bin/rewards/types/RewardInputs.js +2 -0
- package/bin/rewards/validators/IsRewardInputs.d.ts +7 -0
- package/bin/rewards/validators/IsRewardInputs.js +26 -0
- package/bin/rewards/validators/IsRewardTags.d.ts +7 -0
- package/bin/rewards/validators/IsRewardTags.js +28 -0
- package/bin/rewardsEligibility/dtos/EventRunResult.d.ts +11 -0
- package/bin/rewardsEligibility/dtos/EventRunResult.js +7 -0
- package/bin/rewardsEligibility/dtos/EventSource.d.ts +5 -0
- package/bin/rewardsEligibility/dtos/EventSource.js +30 -0
- package/bin/rewardsEligibility/dtos/GetRunResponse.d.ts +22 -0
- package/bin/rewardsEligibility/dtos/GetRunResponse.js +7 -0
- package/bin/rewardsEligibility/dtos/PostEventRequest.d.ts +14 -0
- package/bin/rewardsEligibility/dtos/PostEventRequest.js +47 -0
- package/bin/rewardsEligibility/dtos/PostEventResponse.d.ts +5 -0
- package/bin/rewardsEligibility/dtos/PostEventResponse.js +7 -0
- package/bin/rewardsEligibility/dtos/RunCounts.d.ts +12 -0
- package/bin/rewardsEligibility/dtos/RunCounts.js +7 -0
- package/bin/rewardsEligibility/dtos/RunResultItem.d.ts +16 -0
- package/bin/rewardsEligibility/dtos/RunResultItem.js +7 -0
- package/bin/rewardsEligibility/enums/EvaluationOutcomeEnum.d.ts +11 -0
- package/bin/rewardsEligibility/enums/EvaluationOutcomeEnum.js +15 -0
- package/bin/rewardsEligibility/enums/GrantRequestStatusEnum.d.ts +11 -0
- package/bin/rewardsEligibility/enums/GrantRequestStatusEnum.js +15 -0
- package/bin/rewardsEligibility/enums/RewardsEligibilityErrorCodeEnum.d.ts +8 -0
- package/bin/rewardsEligibility/enums/RewardsEligibilityErrorCodeEnum.js +12 -0
- package/bin/rewardsEligibility/enums/RunModeEnum.d.ts +4 -0
- package/bin/rewardsEligibility/enums/RunModeEnum.js +8 -0
- package/bin/rewardsEligibility/enums/RunStatusEnum.d.ts +9 -0
- package/bin/rewardsEligibility/enums/RunStatusEnum.js +13 -0
- package/bin/rewardsEligibility/enums/TriggerTypeEnum.d.ts +5 -0
- package/bin/rewardsEligibility/enums/TriggerTypeEnum.js +9 -0
- package/bin/rewardsEligibility/index.d.ts +13 -0
- package/bin/rewardsEligibility/index.js +31 -0
- package/package.json +1 -1
- package/src/benefitCenter/dtos/InputField.ts +2 -14
- package/src/benefitCenter/dtos/InputSchema.ts +2 -7
- package/src/benefitCenter/dtos/InputValidation.ts +2 -8
- package/src/benefitCenter/dtos/SelectOption.ts +2 -4
- package/src/benefitCenter/enums/InputFieldTypeEnum.ts +2 -10
- package/src/common/index.ts +4 -1
- package/src/common/types/JsonValue.ts +5 -0
- package/src/dynamicForm/dtos/InputField.ts +16 -0
- package/src/dynamicForm/dtos/InputSchema.ts +7 -0
- package/src/dynamicForm/dtos/InputValidation.ts +8 -0
- package/src/dynamicForm/dtos/SelectOption.ts +4 -0
- package/src/dynamicForm/enums/InputFieldTypeEnum.ts +18 -0
- package/src/dynamicForm/helpers/isDynamicFormValue.ts +16 -0
- package/src/dynamicForm/index.ts +17 -0
- package/src/dynamicForm/types/DynamicFormValue.ts +8 -0
- package/src/dynamicForm/validators/IsDynamicFormValues.ts +16 -0
- package/src/index.ts +14 -0
- package/src/platformRbac/dtos/RoleAssignmentsByScopeRefsRequest.ts +12 -0
- package/src/platformRbac/dtos/RoleAssignmentsByScopeRefsResponse.ts +22 -0
- package/src/platformRbac/enums/ScopeRefLookupStatusEnum.ts +5 -0
- package/src/platformRbac/index.ts +9 -0
- package/src/retailOrg/dtos/validation/PrivateSellerListResponse.ts +5 -1
- package/src/retailWizard/dtos/responses/BackofficeSellerTableResponse.ts +22 -2
- package/src/retailWizard/enums/SellerTableSourceStatusEnum.ts +2 -1
- package/src/rewards/constants/RewardsLimits.ts +2 -0
- package/src/rewards/dtos/GrantFailedMessage.ts +29 -0
- package/src/rewards/dtos/GrantRequestedMessage.ts +46 -0
- package/src/rewards/dtos/RewardChargeTo.ts +5 -0
- package/src/rewards/dtos/RewardCost.ts +7 -0
- package/src/rewards/dtos/RewardDependency.ts +18 -0
- package/src/rewards/dtos/RewardSource.ts +27 -0
- package/src/rewards/dtos/responses/GrantAttemptResponse.ts +16 -0
- package/src/rewards/dtos/responses/GrantItemResponse.ts +21 -0
- package/src/rewards/dtos/responses/GrantResponse.ts +24 -0
- package/src/rewards/dtos/responses/PackageContractItem.ts +13 -0
- package/src/rewards/dtos/responses/PackageContractResponse.ts +14 -0
- package/src/rewards/enums/DependencyIfMissingEnum.ts +5 -0
- package/src/rewards/enums/GrantFailedReasonEnum.ts +11 -0
- package/src/rewards/enums/GrantItemStatusEnum.ts +6 -0
- package/src/rewards/enums/GrantRejectReasonEnum.ts +6 -0
- package/src/rewards/enums/GrantStatusEnum.ts +8 -0
- package/src/rewards/enums/ItemErrorCategoryEnum.ts +7 -0
- package/src/rewards/enums/RewardStatusEnum.ts +4 -0
- package/src/rewards/enums/RewardsErrorCodeEnum.ts +5 -0
- package/src/rewards/enums/RewardsMessageTypeEnum.ts +4 -0
- package/src/rewards/index.ts +37 -0
- package/src/rewards/types/RewardInputs.ts +4 -0
- package/src/rewards/validators/IsRewardInputs.ts +18 -0
- package/src/rewards/validators/IsRewardTags.ts +18 -0
- package/src/rewardsEligibility/dtos/EventRunResult.ts +12 -0
- package/src/rewardsEligibility/dtos/EventSource.ts +15 -0
- package/src/rewardsEligibility/dtos/GetRunResponse.ts +23 -0
- package/src/rewardsEligibility/dtos/PostEventRequest.ts +32 -0
- package/src/rewardsEligibility/dtos/PostEventResponse.ts +6 -0
- package/src/rewardsEligibility/dtos/RunCounts.ts +12 -0
- package/src/rewardsEligibility/dtos/RunResultItem.ts +17 -0
- package/src/rewardsEligibility/enums/EvaluationOutcomeEnum.ts +11 -0
- package/src/rewardsEligibility/enums/GrantRequestStatusEnum.ts +11 -0
- package/src/rewardsEligibility/enums/RewardsEligibilityErrorCodeEnum.ts +8 -0
- package/src/rewardsEligibility/enums/RunModeEnum.ts +4 -0
- package/src/rewardsEligibility/enums/RunStatusEnum.ts +9 -0
- package/src/rewardsEligibility/enums/TriggerTypeEnum.ts +5 -0
- package/src/rewardsEligibility/index.ts +16 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { InputFieldTypeEnum } from "../enums/InputFieldTypeEnum";
|
|
2
|
+
import { SelectOption } from "./SelectOption";
|
|
3
|
+
|
|
4
|
+
export class InputField {
|
|
5
|
+
key: string;
|
|
6
|
+
type: InputFieldTypeEnum;
|
|
7
|
+
label: string;
|
|
8
|
+
required: boolean;
|
|
9
|
+
placeholder?: string;
|
|
10
|
+
helpImage?: string;
|
|
11
|
+
showHelp?: boolean;
|
|
12
|
+
options?: SelectOption[];
|
|
13
|
+
dependsOn?: string;
|
|
14
|
+
/** Endpoint del que salen las opciones (SELECT ampliado y ENTITY_REF). */
|
|
15
|
+
optionsSource?: string;
|
|
16
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export enum InputFieldTypeEnum {
|
|
2
|
+
PHONE = "PHONE",
|
|
3
|
+
BARCODE = "BARCODE",
|
|
4
|
+
ACCOUNT_NUMBER = "ACCOUNT_NUMBER",
|
|
5
|
+
TEXT = "TEXT",
|
|
6
|
+
NUMBER = "NUMBER",
|
|
7
|
+
MONEY = "MONEY",
|
|
8
|
+
SELECT = "SELECT",
|
|
9
|
+
DATE = "DATE",
|
|
10
|
+
/** Buscador de usuario (nombre, teléfono, correo). Valor: `directoryId`. */
|
|
11
|
+
DIRECTORY = "DIRECTORY",
|
|
12
|
+
/** Buscador contra `optionsSource` (ej. ventas). Valor: id de la entidad. */
|
|
13
|
+
ENTITY_REF = "ENTITY_REF",
|
|
14
|
+
/** Rango de fechas. Valor: `{from, to}`; cada extremo es fecha ISO o ventana relativa (`7d`, `1M`; spec B §9). */
|
|
15
|
+
DATE_RANGE = "DATE_RANGE",
|
|
16
|
+
/** Interruptor. Valor: `true`/`false`. */
|
|
17
|
+
BOOLEAN = "BOOLEAN",
|
|
18
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { JsonValue } from '../../common/types/JsonValue';
|
|
2
|
+
import { DateRangeValue, DynamicFormValue } from '../types/DynamicFormValue';
|
|
3
|
+
|
|
4
|
+
export const isPlainObject = (value: JsonValue): value is { [key: string]: JsonValue } =>
|
|
5
|
+
typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
6
|
+
|
|
7
|
+
export const isDateRangeValue = (value: JsonValue): value is DateRangeValue => {
|
|
8
|
+
if (!isPlainObject(value)) return false;
|
|
9
|
+
return Object.keys(value).length === 2 && typeof value.from === 'string' && typeof value.to === 'string';
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const isDynamicFormValue = (value: JsonValue): value is DynamicFormValue => {
|
|
13
|
+
if (typeof value === 'string' || typeof value === 'boolean') return true;
|
|
14
|
+
if (typeof value === 'number') return Number.isFinite(value);
|
|
15
|
+
return isDateRangeValue(value);
|
|
16
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//Enums
|
|
2
|
+
export * from './enums/InputFieldTypeEnum';
|
|
3
|
+
|
|
4
|
+
//DTOs
|
|
5
|
+
export * from './dtos/SelectOption';
|
|
6
|
+
export * from './dtos/InputValidation';
|
|
7
|
+
export * from './dtos/InputField';
|
|
8
|
+
export * from './dtos/InputSchema';
|
|
9
|
+
|
|
10
|
+
//Types
|
|
11
|
+
export * from './types/DynamicFormValue';
|
|
12
|
+
|
|
13
|
+
//Helpers
|
|
14
|
+
export * from './helpers/isDynamicFormValue';
|
|
15
|
+
|
|
16
|
+
//Validators
|
|
17
|
+
export * from './validators/IsDynamicFormValues';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Valor de un campo `DATE_RANGE`: `{from, to}`. `from`/`to` son fechas ISO o una ventana relativa
|
|
3
|
+
* (`7d`, `1M`; spec B §9) que el consumidor resuelve contra «ahora».
|
|
4
|
+
*/
|
|
5
|
+
export type DateRangeValue = { from: string; to: string };
|
|
6
|
+
|
|
7
|
+
/** Lo que puede valer una entrada de un formulario dinámico. */
|
|
8
|
+
export type DynamicFormValue = string | number | boolean | DateRangeValue;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ValidationArguments, ValidatorConstraint, ValidatorConstraintInterface } from 'class-validator';
|
|
2
|
+
import { JsonValue } from '../../common/types/JsonValue';
|
|
3
|
+
import { isDynamicFormValue, isPlainObject } from '../helpers/isDynamicFormValue';
|
|
4
|
+
|
|
5
|
+
/** Valida un mapa `clave → DynamicFormValue` (string | number | boolean | {from, to}). */
|
|
6
|
+
@ValidatorConstraint({ name: 'IsDynamicFormValues', async: false })
|
|
7
|
+
export class IsDynamicFormValues implements ValidatorConstraintInterface {
|
|
8
|
+
validate(value: JsonValue, _args: ValidationArguments): boolean {
|
|
9
|
+
if (!isPlainObject(value)) return false;
|
|
10
|
+
return Object.values(value).every(isDynamicFormValue);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
defaultMessage(_args: ValidationArguments): string {
|
|
14
|
+
return 'inputs debe ser un mapa clave → string | number | boolean | {from, to}';
|
|
15
|
+
}
|
|
16
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -193,3 +193,17 @@ export * as RetailLoan from './retailLoan';
|
|
|
193
193
|
export * as MoneyTransfer from './moneyTransfer';
|
|
194
194
|
// FileStorage: contrato de fiado-s3-lambda (documentos de usuario en S3). Consumido por api-invoker (IFileStorageApi).
|
|
195
195
|
export * as FileStorage from './fileStorage';
|
|
196
|
+
|
|
197
|
+
// DynamicForm: formulario dinámico compartido (InputField, InputFieldTypeEnum, SelectOption,
|
|
198
|
+
// InputValidation, InputSchema). Antes vivía en `benefitCenter`, que lo reexporta como alias.
|
|
199
|
+
// Lo usan rewards (dependencies de las recompensas) y rewardsEligibility (inputs, fields, params).
|
|
200
|
+
export * as DynamicForm from './dynamicForm';
|
|
201
|
+
|
|
202
|
+
// Rewards: contrato entre rewards-business (entrega paquetes de recompensas) y sus llamadores
|
|
203
|
+
// (rewards-eligibility-business): mensajes GRANT_REQUESTED / GRANT_FAILED de las colas compartidas
|
|
204
|
+
// y respuestas de las lecturas privadas GET /packages/{id} y GET /grants/{id}.
|
|
205
|
+
export * as Rewards from './rewards';
|
|
206
|
+
|
|
207
|
+
// RewardsEligibility: contrato del validador de elegibilidad (rewards-eligibility-business) hacia los
|
|
208
|
+
// servicios emisores: POST /events (request/response) y GET /runs/{id}.
|
|
209
|
+
export * as RewardsEligibility from './rewardsEligibility';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ArrayMaxSize, IsArray, IsString } from "class-validator";
|
|
2
|
+
|
|
3
|
+
// Tope de scopeRefs por request del endpoint batch de asignaciones por destino.
|
|
4
|
+
export const ROLE_ASSIGNMENTS_BY_SCOPE_REFS_MAX_BATCH = 100;
|
|
5
|
+
|
|
6
|
+
// Body de POST /internal/tenants/{tenantId}/role-assignments/by-scope-refs; la lista vacía responde sin items.
|
|
7
|
+
export class RoleAssignmentsByScopeRefsRequest {
|
|
8
|
+
@IsArray()
|
|
9
|
+
@ArrayMaxSize(ROLE_ASSIGNMENTS_BY_SCOPE_REFS_MAX_BATCH)
|
|
10
|
+
@IsString({ each: true })
|
|
11
|
+
scopeRefs!: string[];
|
|
12
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { PermissionScope } from '../enums/PermissionScope';
|
|
2
|
+
import type { ScopeRefLookupStatusEnum } from '../enums/ScopeRefLookupStatusEnum';
|
|
3
|
+
|
|
4
|
+
// Asignación vigente de un usuario en el destino; `roleId` es la clave del rol y `roleName` su displayName.
|
|
5
|
+
export interface ScopeRefRoleAssignment {
|
|
6
|
+
cognitoSub: string;
|
|
7
|
+
roleId: string;
|
|
8
|
+
roleName: string | null;
|
|
9
|
+
scope: PermissionScope;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// Asignaciones de un destino; con `UNAVAILABLE` la lista viene vacía y no significa «sin roles».
|
|
13
|
+
export interface ScopeRefRoleAssignments {
|
|
14
|
+
scopeRef: string;
|
|
15
|
+
status: ScopeRefLookupStatusEnum;
|
|
16
|
+
assignments: ScopeRefRoleAssignment[];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Respuesta de POST /internal/tenants/{tenantId}/role-assignments/by-scope-refs; un item por scopeRef pedido.
|
|
20
|
+
export interface RoleAssignmentsByScopeRefsResponse {
|
|
21
|
+
items: ScopeRefRoleAssignments[];
|
|
22
|
+
}
|
|
@@ -184,6 +184,15 @@ export type { RevokeTenantRoleResponse } from './dtos/RevokeTenantRoleResponse';
|
|
|
184
184
|
export * from './dtos/TenantUsersBySubsRequest';
|
|
185
185
|
export type { TenantUserBySubItem, TenantUsersBySubsResponse } from './dtos/TenantUsersBySubsResponse';
|
|
186
186
|
|
|
187
|
+
// Batch privado de asignaciones de rol por destino (scopeRef), para la tabla de Vendedores.
|
|
188
|
+
export * from './dtos/RoleAssignmentsByScopeRefsRequest';
|
|
189
|
+
export * from './enums/ScopeRefLookupStatusEnum';
|
|
190
|
+
export type {
|
|
191
|
+
ScopeRefRoleAssignment,
|
|
192
|
+
ScopeRefRoleAssignments,
|
|
193
|
+
RoleAssignmentsByScopeRefsResponse,
|
|
194
|
+
} from './dtos/RoleAssignmentsByScopeRefsResponse';
|
|
195
|
+
|
|
187
196
|
// Usuarios de API: login por Bearer, alta, rotación de secreto y diagnóstico del W5.
|
|
188
197
|
export * from './apiUser/ApiLoginRequest';
|
|
189
198
|
export * from './apiUser/ApiLoginResponse';
|
|
@@ -4,7 +4,7 @@ import type { RetailUserStatusEnum } from '../../enums/RetailUserStatusEnum';
|
|
|
4
4
|
* Shape mínimo de un vendedor para el motor de comisiones (F3b): a quién pagarle, de qué tienda es y
|
|
5
5
|
* en qué tier va.
|
|
6
6
|
*
|
|
7
|
-
* **Sin PII** —
|
|
7
|
+
* **Sin PII** — el teléfono solo viaja a pedido. `displayName` es el rótulo de conveniencia con el
|
|
8
8
|
* que el motor arma su reporte de devengo; no es identidad (la identidad vive en RBAC).
|
|
9
9
|
*
|
|
10
10
|
* `commissionTier` no es adorno: es lo que el motor usa para resolver CUÁNTO le toca a cada vendedor
|
|
@@ -18,6 +18,10 @@ export interface PrivateSellerDto {
|
|
|
18
18
|
status: RetailUserStatusEnum;
|
|
19
19
|
/** Teléfono del vendedor. Solo viaja si se pidió `includePhone=true`; `null` si no lo tiene. */
|
|
20
20
|
phone?: string | null;
|
|
21
|
+
/** Cuenta del vendedor en RBAC; `null` si todavía no tiene usuario. */
|
|
22
|
+
cognitoSub?: string | null;
|
|
23
|
+
/** Alta del vendedor en el padrón (ISO); `null` si la fila no la trae. */
|
|
24
|
+
createdAt?: string | null;
|
|
21
25
|
}
|
|
22
26
|
|
|
23
27
|
/**
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import type { RetailUserStatusEnum } from '../../../retailOrg/enums/RetailUserStatusEnum';
|
|
2
2
|
import type { SellerTableSourceStatusEnum } from '../../enums/SellerTableSourceStatusEnum';
|
|
3
3
|
|
|
4
|
+
/** Rol del vendedor en RBAC: `key` es el `roleId` y `name` su nombre legible. */
|
|
5
|
+
export interface SellerTableRole {
|
|
6
|
+
key: string;
|
|
7
|
+
name: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
4
10
|
/** Una fila de la tabla de Vendedores: padrón + ventas de la ventana + meta + comisión. */
|
|
5
11
|
export interface SellerTableRow {
|
|
6
12
|
retailUserId: string;
|
|
@@ -12,15 +18,25 @@ export interface SellerTableRow {
|
|
|
12
18
|
storeId: string | null;
|
|
13
19
|
storeName: string | null;
|
|
14
20
|
zoneName: string | null;
|
|
15
|
-
/**
|
|
21
|
+
/** Tiene el rol `store_manager`; si RBAC cae, es el encargado (`managerRetailUserId`) de su tienda. */
|
|
16
22
|
isStoreAdmin: boolean;
|
|
23
|
+
/** Roles de RBAC en la cadena, sus zonas y tiendas; `null` si RBAC no contestó, `[]` sin cuenta o sin roles. */
|
|
24
|
+
roles: SellerTableRole[] | null;
|
|
25
|
+
/** Correo de su cuenta de RBAC; `null` sin cuenta, sin correo o con RBAC caído. */
|
|
26
|
+
email: string | null;
|
|
17
27
|
/** Sin ventas en la ventana viaja `0`: el barrido es exhaustivo. */
|
|
18
28
|
salesCount: number;
|
|
19
29
|
placedCents: number;
|
|
20
30
|
averageTicketCents: number | null;
|
|
21
31
|
lastSaleAt: string | null;
|
|
22
|
-
/**
|
|
32
|
+
/** Clientes distintos de la ventana, sin canceladas; `null` si los totales vinieron del lake. */
|
|
33
|
+
customersServed: number | null;
|
|
34
|
+
/** Alta del vendedor en el padrón (ISO); `null` si no está en el padrón. */
|
|
35
|
+
memberSince: string | null;
|
|
36
|
+
/** Δ % de los últimos 7 días (al cierre de la ventana) contra los 7 anteriores; `null` si la semana base vendió 0. */
|
|
23
37
|
weekOverWeekChangePct: number | null;
|
|
38
|
+
/** Colocación de las últimas 8 semanas, de la más vieja a la actual; `null` sin lake. */
|
|
39
|
+
weeklyPlacedCents: number[] | null;
|
|
24
40
|
/**
|
|
25
41
|
* Meta mensual (`monthCents` del mes de `to`, hora de CDMX) escalada a los días de la ventana:
|
|
26
42
|
* `round(monthCents * días / 30)`. `null` sin meta, con metas caídas o con ventana > 90 días.
|
|
@@ -37,6 +53,10 @@ export interface SellerTableSources {
|
|
|
37
53
|
roster: SellerTableSourceStatusEnum;
|
|
38
54
|
goals: SellerTableSourceStatusEnum;
|
|
39
55
|
commission: SellerTableSourceStatusEnum;
|
|
56
|
+
/** Roles y correo. */
|
|
57
|
+
rbac: SellerTableSourceStatusEnum;
|
|
58
|
+
/** «Todo» y la tendencia de 8 semanas; `DISABLED` con el flag del lake apagado. */
|
|
59
|
+
lake: SellerTableSourceStatusEnum;
|
|
40
60
|
}
|
|
41
61
|
|
|
42
62
|
/** Corte semanal del que sale `commissionCents`; días locales `YYYY-MM-DD`, ambos incluidos. */
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
/** Si una fuente de la tabla
|
|
1
|
+
/** Si una fuente de la tabla contestó (`OK`), falló (`UNAVAILABLE`) o está apagada por flag (`DISABLED`). */
|
|
2
2
|
export enum SellerTableSourceStatusEnum {
|
|
3
3
|
OK = 'OK',
|
|
4
4
|
UNAVAILABLE = 'UNAVAILABLE',
|
|
5
|
+
DISABLED = 'DISABLED',
|
|
5
6
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Expose } from 'class-transformer';
|
|
2
|
+
import { Equals, IsEnum, IsNotEmpty, IsString } from 'class-validator';
|
|
3
|
+
import { GrantFailedReasonEnum } from '../enums/GrantFailedReasonEnum';
|
|
4
|
+
import { RewardsMessageTypeEnum } from '../enums/RewardsMessageTypeEnum';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Aviso de que una entrega terminó SIN ningún ítem entregado (`FAILED` o `REJECTED`). Lo publica
|
|
8
|
+
* rewards-business en la cola registrada para `source.service` (spec A 6.5) para que el llamador
|
|
9
|
+
* libere lo que reservó. Una entrega `PARTIAL` no avisa. Es idempotente en el destino.
|
|
10
|
+
*/
|
|
11
|
+
export class GrantFailedMessage {
|
|
12
|
+
@Expose()
|
|
13
|
+
@Equals(RewardsMessageTypeEnum.GRANT_FAILED)
|
|
14
|
+
messageType!: RewardsMessageTypeEnum.GRANT_FAILED;
|
|
15
|
+
|
|
16
|
+
@Expose()
|
|
17
|
+
@IsString()
|
|
18
|
+
@IsNotEmpty()
|
|
19
|
+
idempotencyKey!: string;
|
|
20
|
+
|
|
21
|
+
@Expose()
|
|
22
|
+
@IsString()
|
|
23
|
+
@IsNotEmpty()
|
|
24
|
+
grantId!: string;
|
|
25
|
+
|
|
26
|
+
@Expose()
|
|
27
|
+
@IsEnum(GrantFailedReasonEnum)
|
|
28
|
+
reason!: GrantFailedReasonEnum;
|
|
29
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Expose, Type } from 'class-transformer';
|
|
2
|
+
import { Equals, IsNotEmpty, IsString, Validate, ValidateNested } from 'class-validator';
|
|
3
|
+
import { RewardsMessageTypeEnum } from '../enums/RewardsMessageTypeEnum';
|
|
4
|
+
import { RewardInputs } from '../types/RewardInputs';
|
|
5
|
+
import { IsRewardInputs } from '../validators/IsRewardInputs';
|
|
6
|
+
import { RewardSource } from './RewardSource';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Pedido de entrega de un paquete, publicado en `RewardsGrantQueue` (spec A 6.1). Que la
|
|
10
|
+
* publicación funcione es la aceptación del pedido. El `grantId` NO viaja: el llamador lo calcula
|
|
11
|
+
* con `grantIdFor(source.service, idempotencyKey)` de `@fiado/api-invoker`.
|
|
12
|
+
*
|
|
13
|
+
* Parseo en el consumidor: `plainToInstance(GrantRequestedMessage, raw, { excludeExtraneousValues: true })`.
|
|
14
|
+
*/
|
|
15
|
+
export class GrantRequestedMessage {
|
|
16
|
+
@Expose()
|
|
17
|
+
@Equals(RewardsMessageTypeEnum.GRANT_REQUESTED)
|
|
18
|
+
messageType!: RewardsMessageTypeEnum.GRANT_REQUESTED;
|
|
19
|
+
|
|
20
|
+
/** Beneficiario de la recompensa. */
|
|
21
|
+
@Expose()
|
|
22
|
+
@IsString()
|
|
23
|
+
@IsNotEmpty()
|
|
24
|
+
directoryId!: string;
|
|
25
|
+
|
|
26
|
+
@Expose()
|
|
27
|
+
@IsString()
|
|
28
|
+
@IsNotEmpty()
|
|
29
|
+
packageId!: string;
|
|
30
|
+
|
|
31
|
+
@Expose()
|
|
32
|
+
@ValidateNested()
|
|
33
|
+
@Type(() => RewardSource)
|
|
34
|
+
source!: RewardSource;
|
|
35
|
+
|
|
36
|
+
/** Ej. `elig:{evaluationId}:{beneficiaryDirectoryId}:{grantKey}:r{n}`. Con `source.service` da el `grantId`. */
|
|
37
|
+
@Expose()
|
|
38
|
+
@IsString()
|
|
39
|
+
@IsNotEmpty()
|
|
40
|
+
idempotencyKey!: string;
|
|
41
|
+
|
|
42
|
+
/** `itemKey → inputKey → valor`. */
|
|
43
|
+
@Expose()
|
|
44
|
+
@Validate(IsRewardInputs)
|
|
45
|
+
inputs!: RewardInputs;
|
|
46
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { InputField } from '../../dynamicForm/dtos/InputField';
|
|
2
|
+
import { DependencyIfMissingEnum } from '../enums/DependencyIfMissingEnum';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Una dependencia de una recompensa: lo que quien consume debe enviar para poder entregarla.
|
|
6
|
+
* Adopta la forma de `InputField` (formulario dinámico compartido) y suma los campos propios
|
|
7
|
+
* de rewards (spec A 5.1).
|
|
8
|
+
*/
|
|
9
|
+
export class RewardDependency extends InputField {
|
|
10
|
+
/** Condición que la vuelve necesaria (sobre otras dependencias), si aplica. */
|
|
11
|
+
requiredWhen?: string;
|
|
12
|
+
/** Qué pasa si falta cuando se necesitaba. Por defecto, REJECT. */
|
|
13
|
+
ifMissing?: DependencyIfMissingEnum;
|
|
14
|
+
/** De dónde la saca el lambda solo cuando no se envía. */
|
|
15
|
+
resolvedFrom?: string;
|
|
16
|
+
/** Texto corto para quien consume. */
|
|
17
|
+
description?: string;
|
|
18
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Expose } from 'class-transformer';
|
|
2
|
+
import { IsNotEmpty, IsOptional, IsString, Validate } from 'class-validator';
|
|
3
|
+
import { IsRewardTags } from '../validators/IsRewardTags';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Quién pide la entrega. El lambda no interpreta `reference` ni `tags`: los guarda y los usa como
|
|
7
|
+
* filtro/auditoría (spec A D1, D10).
|
|
8
|
+
*/
|
|
9
|
+
export class RewardSource {
|
|
10
|
+
/** Servicio llamador (ej. `rewards-eligibility`). Entra en el `grantId`. */
|
|
11
|
+
@Expose()
|
|
12
|
+
@IsString()
|
|
13
|
+
@IsNotEmpty()
|
|
14
|
+
service!: string;
|
|
15
|
+
|
|
16
|
+
/** Referencia opaca del llamador (ej. `runId`). */
|
|
17
|
+
@Expose()
|
|
18
|
+
@IsString()
|
|
19
|
+
@IsNotEmpty()
|
|
20
|
+
reference!: string;
|
|
21
|
+
|
|
22
|
+
/** Etiquetas opacas (ej. `campaignId`, `evaluationId`). Máx. 10 llaves. */
|
|
23
|
+
@Expose()
|
|
24
|
+
@IsOptional()
|
|
25
|
+
@Validate(IsRewardTags)
|
|
26
|
+
tags?: Record<string, string>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ItemErrorCategoryEnum } from '../../enums/ItemErrorCategoryEnum';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Un intento de ejecutar un ítem. Sin `providerResponse`, `requestSnapshot` ni `correlationIds`:
|
|
5
|
+
* contienen PII y solo se leen en el backoffice (spec A R2).
|
|
6
|
+
*/
|
|
7
|
+
export class GrantAttemptResponse {
|
|
8
|
+
attempt: number;
|
|
9
|
+
/** Epoch en milisegundos. */
|
|
10
|
+
startedAt: number;
|
|
11
|
+
/** Epoch en milisegundos. */
|
|
12
|
+
finishedAt: number;
|
|
13
|
+
errorCategory?: ItemErrorCategoryEnum;
|
|
14
|
+
errorCode?: string;
|
|
15
|
+
httpStatus?: number;
|
|
16
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { GrantItemStatusEnum } from '../../enums/GrantItemStatusEnum';
|
|
2
|
+
import { RewardChargeTo } from '../RewardChargeTo';
|
|
3
|
+
import { RewardCost } from '../RewardCost';
|
|
4
|
+
import { GrantAttemptResponse } from './GrantAttemptResponse';
|
|
5
|
+
|
|
6
|
+
export class GrantItemResponse {
|
|
7
|
+
itemKey: string;
|
|
8
|
+
catalogItemId: string;
|
|
9
|
+
status: GrantItemStatusEnum;
|
|
10
|
+
/** Solo si `status` es SKIPPED (ej. `DEPENDENCY_MISSING`, `ITEM_NOT_APPLICABLE`). */
|
|
11
|
+
skipReason?: string;
|
|
12
|
+
chargeTo: RewardChargeTo;
|
|
13
|
+
cost: RewardCost;
|
|
14
|
+
attemptCount: number;
|
|
15
|
+
/** Epoch en milisegundos; solo si `status` es GRANTED. */
|
|
16
|
+
grantedAt?: number;
|
|
17
|
+
/** Referencias del proveedor (ej. `{ transactionNumber }`). */
|
|
18
|
+
externalRef?: Record<string, string>;
|
|
19
|
+
/** Últimos intentos (máx. 5). */
|
|
20
|
+
attempts: GrantAttemptResponse[];
|
|
21
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { GrantRejectReasonEnum } from '../../enums/GrantRejectReasonEnum';
|
|
2
|
+
import { GrantStatusEnum } from '../../enums/GrantStatusEnum';
|
|
3
|
+
import { RewardSource } from '../RewardSource';
|
|
4
|
+
import { GrantItemResponse } from './GrantItemResponse';
|
|
5
|
+
|
|
6
|
+
/** Respuesta de `GET /grants/{id}`: estado de la entrega y de cada ítem (spec A 6.4). */
|
|
7
|
+
export class GrantResponse {
|
|
8
|
+
id: string;
|
|
9
|
+
directoryId: string;
|
|
10
|
+
packageId: string;
|
|
11
|
+
/** Versión del paquete congelada al crear la entrega. */
|
|
12
|
+
packageVersion: number;
|
|
13
|
+
source: RewardSource;
|
|
14
|
+
status: GrantStatusEnum;
|
|
15
|
+
/** Solo si `status` es REJECTED. */
|
|
16
|
+
rejectReason?: GrantRejectReasonEnum;
|
|
17
|
+
/** Solo si `rejectReason` es `INPUT_INVALID`: claves de los campos inválidos, `itemKey.inputKey` (spec A §6.2). */
|
|
18
|
+
invalidFields?: string[];
|
|
19
|
+
items: GrantItemResponse[];
|
|
20
|
+
/** Epoch en milisegundos. */
|
|
21
|
+
createdAt: number;
|
|
22
|
+
/** Epoch en milisegundos. */
|
|
23
|
+
updatedAt: number;
|
|
24
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { RewardCost } from '../RewardCost';
|
|
2
|
+
import { RewardDependency } from '../RewardDependency';
|
|
3
|
+
|
|
4
|
+
/** Una recompensa dentro del contrato de un paquete (spec A 6.3). */
|
|
5
|
+
export class PackageContractItem {
|
|
6
|
+
itemKey: string;
|
|
7
|
+
catalogItemId: string;
|
|
8
|
+
name: string;
|
|
9
|
+
description: string;
|
|
10
|
+
cost: RewardCost;
|
|
11
|
+
/** Lo que el llamador debe enviar en `inputs[itemKey]`. */
|
|
12
|
+
dependencies: RewardDependency[];
|
|
13
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { RewardStatusEnum } from '../../enums/RewardStatusEnum';
|
|
2
|
+
import { RewardCost } from '../RewardCost';
|
|
3
|
+
import { PackageContractItem } from './PackageContractItem';
|
|
4
|
+
|
|
5
|
+
/** Respuesta de `GET /packages/{id}`: el contrato de entrada del paquete (spec A 6.3). */
|
|
6
|
+
export class PackageContractResponse {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
status: RewardStatusEnum;
|
|
10
|
+
version: number;
|
|
11
|
+
items: PackageContractItem[];
|
|
12
|
+
/** Costo total declarado del paquete, por moneda (sin conversión). */
|
|
13
|
+
totalCost: RewardCost[];
|
|
14
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `reason` de `GRANT_FAILED` (spec A 6.5). Las tres primeras son las de `GrantRejectReasonEnum`
|
|
3
|
+
* (entrega REJECTED); `ITEMS_FAILED` es una entrega FAILED: ningún ítem se entregó.
|
|
4
|
+
* Decisión P-2 aprobada.
|
|
5
|
+
*/
|
|
6
|
+
export enum GrantFailedReasonEnum {
|
|
7
|
+
INPUT_INVALID = 'INPUT_INVALID',
|
|
8
|
+
PACKAGE_NOT_FOUND = 'PACKAGE_NOT_FOUND',
|
|
9
|
+
PACKAGE_INACTIVE = 'PACKAGE_INACTIVE',
|
|
10
|
+
ITEMS_FAILED = 'ITEMS_FAILED',
|
|
11
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
//Enums
|
|
2
|
+
export * from './enums/RewardsMessageTypeEnum';
|
|
3
|
+
export * from './enums/GrantStatusEnum';
|
|
4
|
+
export * from './enums/GrantItemStatusEnum';
|
|
5
|
+
export * from './enums/GrantRejectReasonEnum';
|
|
6
|
+
export * from './enums/GrantFailedReasonEnum';
|
|
7
|
+
export * from './enums/ItemErrorCategoryEnum';
|
|
8
|
+
export * from './enums/RewardStatusEnum';
|
|
9
|
+
export * from './enums/DependencyIfMissingEnum';
|
|
10
|
+
export * from './enums/RewardsErrorCodeEnum';
|
|
11
|
+
|
|
12
|
+
//Types
|
|
13
|
+
export * from './types/RewardInputs';
|
|
14
|
+
|
|
15
|
+
//DTOs
|
|
16
|
+
export * from './dtos/RewardCost';
|
|
17
|
+
export * from './dtos/RewardChargeTo';
|
|
18
|
+
export * from './dtos/RewardDependency';
|
|
19
|
+
|
|
20
|
+
//Constants
|
|
21
|
+
export * from './constants/RewardsLimits';
|
|
22
|
+
|
|
23
|
+
//Validators
|
|
24
|
+
export * from './validators/IsRewardTags';
|
|
25
|
+
export * from './validators/IsRewardInputs';
|
|
26
|
+
|
|
27
|
+
//Messages (colas compartidas)
|
|
28
|
+
export * from './dtos/RewardSource';
|
|
29
|
+
export * from './dtos/GrantRequestedMessage';
|
|
30
|
+
export * from './dtos/GrantFailedMessage';
|
|
31
|
+
|
|
32
|
+
//Responses (lecturas privadas)
|
|
33
|
+
export * from './dtos/responses/PackageContractItem';
|
|
34
|
+
export * from './dtos/responses/PackageContractResponse';
|
|
35
|
+
export * from './dtos/responses/GrantAttemptResponse';
|
|
36
|
+
export * from './dtos/responses/GrantItemResponse';
|
|
37
|
+
export * from './dtos/responses/GrantResponse';
|