@fiado/type-kit 3.510.0 → 3.511.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/rewards/enums.test.ts +20 -4
- package/_test_/unit/rewards/grantMessages.test.ts +6 -0
- package/_test_/unit/rewards/readResponses.test.ts +17 -0
- package/bin/rewards/enums/GrantFailedReasonEnum.d.ts +6 -2
- package/bin/rewards/enums/GrantFailedReasonEnum.js +6 -2
- package/bin/rewards/enums/GrantItemStatusEnum.d.ts +5 -0
- package/bin/rewards/enums/GrantItemStatusEnum.js +5 -0
- package/bin/rewards/enums/GrantRejectReasonEnum.d.ts +6 -1
- package/bin/rewards/enums/GrantRejectReasonEnum.js +5 -0
- package/package.json +1 -1
- package/src/rewards/enums/GrantFailedReasonEnum.ts +6 -2
- package/src/rewards/enums/GrantItemStatusEnum.ts +5 -0
- package/src/rewards/enums/GrantRejectReasonEnum.ts +5 -0
|
@@ -29,7 +29,7 @@ describe('rewards: enums (los valores viajan por cola y por HTTP: no se renombra
|
|
|
29
29
|
});
|
|
30
30
|
|
|
31
31
|
it('GrantItemStatusEnum coincide con spec A 7.1', () => {
|
|
32
|
-
expect(Object.values(GrantItemStatusEnum).sort()).toEqual(['FAILED', 'GRANTED', 'PENDING', 'SKIPPED']);
|
|
32
|
+
expect(Object.values(GrantItemStatusEnum).sort()).toEqual(['FAILED', 'GRANTED', 'PENDING', 'PROCESSING', 'SKIPPED']);
|
|
33
33
|
});
|
|
34
34
|
|
|
35
35
|
it('ItemErrorCategoryEnum coincide con spec A §8', () => {
|
|
@@ -38,10 +38,26 @@ describe('rewards: enums (los valores viajan por cola y por HTTP: no se renombra
|
|
|
38
38
|
]);
|
|
39
39
|
});
|
|
40
40
|
|
|
41
|
-
it('
|
|
42
|
-
|
|
43
|
-
expect(Object.values(
|
|
41
|
+
it('GrantItemStatusEnum conserva los valores previos y agrega PROCESSING', () => {
|
|
42
|
+
['PENDING', 'GRANTED', 'FAILED', 'SKIPPED'].forEach((v) => {
|
|
43
|
+
expect(Object.values(GrantItemStatusEnum)).toContain(v);
|
|
44
44
|
});
|
|
45
|
+
expect(GrantItemStatusEnum.PROCESSING).toBe('PROCESSING');
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('GrantRejectReasonEnum conserva los valores previos y agrega UNSUPPORTED_REWARD_TYPE', () => {
|
|
49
|
+
expect(Object.values(GrantRejectReasonEnum).sort()).toEqual([
|
|
50
|
+
'INPUT_INVALID', 'PACKAGE_INACTIVE', 'PACKAGE_NOT_FOUND', 'UNSUPPORTED_REWARD_TYPE',
|
|
51
|
+
]);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('GrantFailedReasonEnum incluye las razones de rechazo (salvo UNSUPPORTED_REWARD_TYPE, que se avisa como INPUT_INVALID) más ITEMS_FAILED', () => {
|
|
55
|
+
Object.values(GrantRejectReasonEnum)
|
|
56
|
+
.filter((razon) => razon !== GrantRejectReasonEnum.UNSUPPORTED_REWARD_TYPE)
|
|
57
|
+
.forEach((razon) => {
|
|
58
|
+
expect(Object.values(GrantFailedReasonEnum)).toContain(razon);
|
|
59
|
+
});
|
|
60
|
+
expect(Object.values(GrantFailedReasonEnum)).not.toContain('UNSUPPORTED_REWARD_TYPE');
|
|
45
61
|
expect(GrantFailedReasonEnum.ITEMS_FAILED).toBe('ITEMS_FAILED');
|
|
46
62
|
expect(Object.values(GrantFailedReasonEnum)).toHaveLength(4);
|
|
47
63
|
});
|
|
@@ -105,6 +105,12 @@ describe('GrantFailedMessage (spec A 6.5)', () => {
|
|
|
105
105
|
expect(dto.reason).toBe(GrantFailedReasonEnum.PACKAGE_INACTIVE);
|
|
106
106
|
});
|
|
107
107
|
|
|
108
|
+
it('un REJECTED por UNSUPPORTED_REWARD_TYPE se avisa como INPUT_INVALID (GrantFailedReasonEnum no suma valores)', async () => {
|
|
109
|
+
expect(Object.values(GrantFailedReasonEnum)).not.toContain('UNSUPPORTED_REWARD_TYPE');
|
|
110
|
+
expect(await errorProps(failed({ ...baseFailed, reason: 'UNSUPPORTED_REWARD_TYPE' }))).toContain('reason');
|
|
111
|
+
expect(await validate(failed({ ...baseFailed, reason: GrantFailedReasonEnum.INPUT_INVALID }))).toHaveLength(0);
|
|
112
|
+
});
|
|
113
|
+
|
|
108
114
|
it.each(Object.values(GrantFailedReasonEnum))('acepta la razón %s', async (reason) => {
|
|
109
115
|
expect(await validate(failed({ ...baseFailed, reason }))).toHaveLength(0);
|
|
110
116
|
});
|
|
@@ -112,6 +112,23 @@ describe('GrantResponse (GET /grants/{id}, spec A 6.4)', () => {
|
|
|
112
112
|
expect(rechazada.rejectReason).toBe('PACKAGE_INACTIVE');
|
|
113
113
|
});
|
|
114
114
|
|
|
115
|
+
it('una entrega REJECTED por UNSUPPORTED_REWARD_TYPE y un ítem PROCESSING viajan por JSON', () => {
|
|
116
|
+
const sinAdaptador: GrantResponse = {
|
|
117
|
+
...entrega,
|
|
118
|
+
status: GrantStatusEnum.REJECTED,
|
|
119
|
+
rejectReason: GrantRejectReasonEnum.UNSUPPORTED_REWARD_TYPE,
|
|
120
|
+
items: [],
|
|
121
|
+
};
|
|
122
|
+
expect(JSON.parse(JSON.stringify(sinAdaptador)).rejectReason).toBe('UNSUPPORTED_REWARD_TYPE');
|
|
123
|
+
|
|
124
|
+
const enProceso: GrantResponse = {
|
|
125
|
+
...entrega,
|
|
126
|
+
status: GrantStatusEnum.IN_PROGRESS,
|
|
127
|
+
items: [{ ...entrega.items[1], status: GrantItemStatusEnum.PROCESSING, grantedAt: undefined }],
|
|
128
|
+
};
|
|
129
|
+
expect(JSON.parse(JSON.stringify(enProceso)).items[0].status).toBe('PROCESSING');
|
|
130
|
+
});
|
|
131
|
+
|
|
115
132
|
it('un INPUT_INVALID expone la lista de campos inválidos (spec A 6.2)', () => {
|
|
116
133
|
const invalida: GrantResponse = {
|
|
117
134
|
...entrega,
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `reason` de `GRANT_FAILED` (spec A 6.5).
|
|
3
|
-
* (entrega REJECTED); `ITEMS_FAILED` es una entrega FAILED: ningún ítem se entregó.
|
|
2
|
+
* `reason` de `GRANT_FAILED` (spec A 6.5). `INPUT_INVALID`, `PACKAGE_NOT_FOUND` y `PACKAGE_INACTIVE` son las
|
|
3
|
+
* de `GrantRejectReasonEnum` (entrega REJECTED); `ITEMS_FAILED` es una entrega FAILED: ningún ítem se entregó.
|
|
4
4
|
* Decisión P-2 aprobada.
|
|
5
|
+
*
|
|
6
|
+
* Excepción: un REJECTED por `GrantRejectReasonEnum.UNSUPPORTED_REWARD_TYPE` se avisa como `INPUT_INVALID`
|
|
7
|
+
* (el paquete pide algo que el núcleo no puede ejecutar, o sea una solicitud inválida para este lambda).
|
|
8
|
+
* No se agregó un valor nuevo para no ampliar el contrato de la cola.
|
|
5
9
|
*/
|
|
6
10
|
export declare enum GrantFailedReasonEnum {
|
|
7
11
|
INPUT_INVALID = "INPUT_INVALID",
|
|
@@ -2,9 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.GrantFailedReasonEnum = void 0;
|
|
4
4
|
/**
|
|
5
|
-
* `reason` de `GRANT_FAILED` (spec A 6.5).
|
|
6
|
-
* (entrega REJECTED); `ITEMS_FAILED` es una entrega FAILED: ningún ítem se entregó.
|
|
5
|
+
* `reason` de `GRANT_FAILED` (spec A 6.5). `INPUT_INVALID`, `PACKAGE_NOT_FOUND` y `PACKAGE_INACTIVE` son las
|
|
6
|
+
* de `GrantRejectReasonEnum` (entrega REJECTED); `ITEMS_FAILED` es una entrega FAILED: ningún ítem se entregó.
|
|
7
7
|
* Decisión P-2 aprobada.
|
|
8
|
+
*
|
|
9
|
+
* Excepción: un REJECTED por `GrantRejectReasonEnum.UNSUPPORTED_REWARD_TYPE` se avisa como `INPUT_INVALID`
|
|
10
|
+
* (el paquete pide algo que el núcleo no puede ejecutar, o sea una solicitud inválida para este lambda).
|
|
11
|
+
* No se agregó un valor nuevo para no ampliar el contrato de la cola.
|
|
8
12
|
*/
|
|
9
13
|
var GrantFailedReasonEnum;
|
|
10
14
|
(function (GrantFailedReasonEnum) {
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
export declare enum GrantItemStatusEnum {
|
|
2
2
|
PENDING = "PENDING",
|
|
3
|
+
/**
|
|
4
|
+
* Reclamado por el worker antes de ejecutar; si un reintento lo encuentra así, el envío pudo haber
|
|
5
|
+
* ocurrido y el adaptador debe reconciliar antes de reintentar.
|
|
6
|
+
*/
|
|
7
|
+
PROCESSING = "PROCESSING",
|
|
3
8
|
GRANTED = "GRANTED",
|
|
4
9
|
FAILED = "FAILED",
|
|
5
10
|
SKIPPED = "SKIPPED"
|
|
@@ -4,6 +4,11 @@ exports.GrantItemStatusEnum = void 0;
|
|
|
4
4
|
var GrantItemStatusEnum;
|
|
5
5
|
(function (GrantItemStatusEnum) {
|
|
6
6
|
GrantItemStatusEnum["PENDING"] = "PENDING";
|
|
7
|
+
/**
|
|
8
|
+
* Reclamado por el worker antes de ejecutar; si un reintento lo encuentra así, el envío pudo haber
|
|
9
|
+
* ocurrido y el adaptador debe reconciliar antes de reintentar.
|
|
10
|
+
*/
|
|
11
|
+
GrantItemStatusEnum["PROCESSING"] = "PROCESSING";
|
|
7
12
|
GrantItemStatusEnum["GRANTED"] = "GRANTED";
|
|
8
13
|
GrantItemStatusEnum["FAILED"] = "FAILED";
|
|
9
14
|
GrantItemStatusEnum["SKIPPED"] = "SKIPPED";
|
|
@@ -2,5 +2,10 @@
|
|
|
2
2
|
export declare enum GrantRejectReasonEnum {
|
|
3
3
|
INPUT_INVALID = "INPUT_INVALID",
|
|
4
4
|
PACKAGE_NOT_FOUND = "PACKAGE_NOT_FOUND",
|
|
5
|
-
PACKAGE_INACTIVE = "PACKAGE_INACTIVE"
|
|
5
|
+
PACKAGE_INACTIVE = "PACKAGE_INACTIVE",
|
|
6
|
+
/**
|
|
7
|
+
* El paquete contiene un tipo de recompensa sin adaptador registrado; se rechaza antes de ejecutar
|
|
8
|
+
* cualquier ítem.
|
|
9
|
+
*/
|
|
10
|
+
UNSUPPORTED_REWARD_TYPE = "UNSUPPORTED_REWARD_TYPE"
|
|
6
11
|
}
|
|
@@ -7,4 +7,9 @@ var GrantRejectReasonEnum;
|
|
|
7
7
|
GrantRejectReasonEnum["INPUT_INVALID"] = "INPUT_INVALID";
|
|
8
8
|
GrantRejectReasonEnum["PACKAGE_NOT_FOUND"] = "PACKAGE_NOT_FOUND";
|
|
9
9
|
GrantRejectReasonEnum["PACKAGE_INACTIVE"] = "PACKAGE_INACTIVE";
|
|
10
|
+
/**
|
|
11
|
+
* El paquete contiene un tipo de recompensa sin adaptador registrado; se rechaza antes de ejecutar
|
|
12
|
+
* cualquier ítem.
|
|
13
|
+
*/
|
|
14
|
+
GrantRejectReasonEnum["UNSUPPORTED_REWARD_TYPE"] = "UNSUPPORTED_REWARD_TYPE";
|
|
10
15
|
})(GrantRejectReasonEnum || (exports.GrantRejectReasonEnum = GrantRejectReasonEnum = {}));
|
package/package.json
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `reason` de `GRANT_FAILED` (spec A 6.5).
|
|
3
|
-
* (entrega REJECTED); `ITEMS_FAILED` es una entrega FAILED: ningún ítem se entregó.
|
|
2
|
+
* `reason` de `GRANT_FAILED` (spec A 6.5). `INPUT_INVALID`, `PACKAGE_NOT_FOUND` y `PACKAGE_INACTIVE` son las
|
|
3
|
+
* de `GrantRejectReasonEnum` (entrega REJECTED); `ITEMS_FAILED` es una entrega FAILED: ningún ítem se entregó.
|
|
4
4
|
* Decisión P-2 aprobada.
|
|
5
|
+
*
|
|
6
|
+
* Excepción: un REJECTED por `GrantRejectReasonEnum.UNSUPPORTED_REWARD_TYPE` se avisa como `INPUT_INVALID`
|
|
7
|
+
* (el paquete pide algo que el núcleo no puede ejecutar, o sea una solicitud inválida para este lambda).
|
|
8
|
+
* No se agregó un valor nuevo para no ampliar el contrato de la cola.
|
|
5
9
|
*/
|
|
6
10
|
export enum GrantFailedReasonEnum {
|
|
7
11
|
INPUT_INVALID = 'INPUT_INVALID',
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
export enum GrantItemStatusEnum {
|
|
2
2
|
PENDING = 'PENDING',
|
|
3
|
+
/**
|
|
4
|
+
* Reclamado por el worker antes de ejecutar; si un reintento lo encuentra así, el envío pudo haber
|
|
5
|
+
* ocurrido y el adaptador debe reconciliar antes de reintentar.
|
|
6
|
+
*/
|
|
7
|
+
PROCESSING = 'PROCESSING',
|
|
3
8
|
GRANTED = 'GRANTED',
|
|
4
9
|
FAILED = 'FAILED',
|
|
5
10
|
SKIPPED = 'SKIPPED',
|
|
@@ -3,4 +3,9 @@ export enum GrantRejectReasonEnum {
|
|
|
3
3
|
INPUT_INVALID = 'INPUT_INVALID',
|
|
4
4
|
PACKAGE_NOT_FOUND = 'PACKAGE_NOT_FOUND',
|
|
5
5
|
PACKAGE_INACTIVE = 'PACKAGE_INACTIVE',
|
|
6
|
+
/**
|
|
7
|
+
* El paquete contiene un tipo de recompensa sin adaptador registrado; se rechaza antes de ejecutar
|
|
8
|
+
* cualquier ítem.
|
|
9
|
+
*/
|
|
10
|
+
UNSUPPORTED_REWARD_TYPE = 'UNSUPPORTED_REWARD_TYPE',
|
|
6
11
|
}
|