Skip to content

Commit 3cae869

Browse files
feat: change type of the response/result to a record
1 parent bb382bb commit 3cae869

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Diff for: packages/idempotency/src/persistence/PersistenceLayer.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,13 @@ abstract class PersistenceLayer implements PersistenceLayerInterface {
8282
* @param data - the data payload that will be hashed to create the hash portion of the idempotency key
8383
* @param result - the result of the successfully completed function
8484
*/
85-
public async saveSuccess(data: unknown, result: unknown): Promise<void> {
85+
public async saveSuccess(data: unknown, result: Record<string, unknown>): Promise<void> {
8686
const idempotencyRecord: IdempotencyRecord =
8787
new IdempotencyRecord(this.getHashedIdempotencyKey(data),
8888
IdempotencyRecordStatus.COMPLETED,
8989
this.getExpiryTimestamp(),
9090
undefined,
91-
JSON.stringify(result),
91+
result,
9292
undefined
9393
);
9494

Diff for: packages/idempotency/tests/unit/persistence/PersistenceLayer.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ describe('Class: Persistence Layer', ()=> {
141141

142142
test('When called it updates the idempotency record to COMPLETED', async () => {
143143
const data = 'someData';
144-
const result = 'result';
144+
const result = {};
145145
const persistenceLayer: PersistenceLayer = new PersistenceLayerTestClass();
146146

147147
await persistenceLayer.saveSuccess(data, result);
@@ -153,7 +153,7 @@ describe('Class: Persistence Layer', ()=> {
153153

154154
test('When called it generates the idempotency key from the function name and a digest of the md5 hash of the data', async ()=> {
155155
const data = 'someData';
156-
const result = 'result';
156+
const result = {};
157157
const lambdaFunctionName = 'LambdaName';
158158
jest.spyOn(EnvironmentVariablesService.prototype, 'getLambdaFunctionName').mockReturnValue(lambdaFunctionName);
159159

@@ -180,7 +180,7 @@ describe('Class: Persistence Layer', ()=> {
180180
test('When called it sets the expiry timestamp to one hour in the future', async ()=> {
181181
const persistenceLayer: PersistenceLayer = new PersistenceLayerTestClass();
182182
const data = 'someData';
183-
const result = 'result';
183+
const result = {};
184184
const currentMillisTime = 3000;
185185
const currentSeconds = currentMillisTime / 1000;
186186
const oneHourSeconds = 60 * 60;

0 commit comments

Comments
 (0)