From 9a648945c7e058a80424d4c02e8d88bc0ca77fe9 Mon Sep 17 00:00:00 2001 From: Michael Wittwer Date: Tue, 16 Apr 2024 22:04:58 +0200 Subject: [PATCH] refactor(make-request): remove non-existent method This method now executes PartiQL requests. No Replacement available. BREAKING CHANGE: Methods DynamoStore.makeRequest and DynamoDBWrapper.makeRequest are no longer available. --- src/dynamo/dynamo-db-wrapper.spec.ts | 36 ---------------------------- src/dynamo/dynamo-db-wrapper.ts | 7 ------ src/dynamo/dynamo-store.spec.ts | 9 ------- src/dynamo/dynamo-store.ts | 10 -------- 4 files changed, 62 deletions(-) diff --git a/src/dynamo/dynamo-db-wrapper.spec.ts b/src/dynamo/dynamo-db-wrapper.spec.ts index 4112d2f22..08a86c802 100644 --- a/src/dynamo/dynamo-db-wrapper.spec.ts +++ b/src/dynamo/dynamo-db-wrapper.spec.ts @@ -98,31 +98,6 @@ describe('dynamo rx', () => { }) }) - // TODO v3: remove when decision is made if DynamoDbWrapper.makeRequest comes back or not - // describe('makeRequest', () => { - // let dynamoDBWrapper: DynamoDbWrapper - // let sessionValidityEnsurerMock: jest.Mock - // let dynamoDBMock: jest.SpyInstance - // let pseudoParams: any - // - // beforeEach(() => { - // pseudoParams = { TableName: 'tableName', KeyConditionExpression: 'blub' } - // sessionValidityEnsurerMock = jest.fn().mockReturnValueOnce(Promise.resolve(true)) - // updateDynamoEasyConfig({ sessionValidityEnsurer: sessionValidityEnsurerMock }) - // dynamoDBWrapper = new DynamoDbWrapper(new DynamoDB.DynamoDB({})) - // }) - // - // it('should call the validity ensurer before each call and call the correct dynamoDB method', async () => { - // dynamoDBMock = jest - // .spyOn(dynamoDBWrapper.dynamoDB, 'makeRequest') - // .mockReturnValueOnce({ promise: () => Promise.resolve() }) - // await dynamoDBWrapper.makeRequest('pseudoOperation', pseudoParams) - // expect(sessionValidityEnsurerMock).toHaveBeenCalled() - // expect(dynamoDBMock).toHaveBeenCalledTimes(1) - // expect(dynamoDBMock).toHaveBeenCalledWith('pseudoOperation', pseudoParams) - // }) - // }) - describe('query', () => { beforeEach(() => {}) it('should throw when no KeyConditionExpression was given', () => { @@ -131,15 +106,4 @@ describe('dynamo rx', () => { expect(() => dynamoDBWrapper.query({ TableName: 'tableName' })).toThrow() }) }) - - // TODO v3: remove when decision is made if DynamoDbWrapper.makeRequest comes back or not - // it('should call makeRequest with the given params', async () => { - // const dynamoDBWrapper = new DynamoDbWrapper(new DynamoDB.DynamoDB({})) - // const makeRequestMock = jest.fn().mockReturnValue({ promise: (args: any) => Promise.resolve(args) }) - // Object.assign(dynamoDBWrapper, { dynamoDB: { makeRequest: makeRequestMock } }) - // - // await dynamoDBWrapper.makeRequest({ ok: true }) - // expect(makeRequestMock).toHaveBeenCalled() - // expect(makeRequestMock.mock.calls.slice(-1)[0][0]).toEqual({ ok: true }) - // }) }) diff --git a/src/dynamo/dynamo-db-wrapper.ts b/src/dynamo/dynamo-db-wrapper.ts index a92e64802..2bc892719 100644 --- a/src/dynamo/dynamo-db-wrapper.ts +++ b/src/dynamo/dynamo-db-wrapper.ts @@ -58,11 +58,4 @@ export class DynamoDbWrapper { return dynamoEasyConfig.sessionValidityEnsurer().then(() => this.dynamoDB.query(params)) } - - /* - * TODO v3: check for replacement. DynamoDB.executeStatement is now used to execute statements using PartiQL - */ - // makeRequest(operation: string, params?: Record): Promise { - // return dynamoEasyConfig.sessionValidityEnsurer().then(() => this.dynamoDB.executeStatement(operation as any, params)) - // } } diff --git a/src/dynamo/dynamo-store.spec.ts b/src/dynamo/dynamo-store.spec.ts index 7d04a1023..6cc9ec737 100644 --- a/src/dynamo/dynamo-store.spec.ts +++ b/src/dynamo/dynamo-store.spec.ts @@ -90,15 +90,6 @@ describe('dynamo store', () => { expect(store.transactGet([{ id: 'myId' }]) instanceof TransactGetSingleTableRequest).toBeTruthy()) }) - // TODO v3: possibly remove when we decided on how to proceed with DynamoDbWrapper.makeRequest - // xdescribe('should enable custom requests', () => { - // const makeRequestSpy = jest.fn().mockReturnValue(Promise.resolve()) - // const store = new DynamoStore(SimpleWithPartitionKeyModel, dynamoDB) - // Object.assign(store, { dynamoDBWrapper: { makeRequest: makeRequestSpy } }) - // store.makeRequest('updateTimeToLive', {}) - // expect(makeRequestSpy).toBeCalled() - // }) - describe('allow to get dynamoDB instance', () => { const store = new DynamoStore(SimpleWithPartitionKeyModel, new DynamoDB.DynamoDB({})) expect(store.dynamoDB).toBeDefined() diff --git a/src/dynamo/dynamo-store.ts b/src/dynamo/dynamo-store.ts index 898a51143..e0c3d4867 100644 --- a/src/dynamo/dynamo-store.ts +++ b/src/dynamo/dynamo-store.ts @@ -80,14 +80,4 @@ export class DynamoStore { transactGet(keys: Array>): TransactGetSingleTableRequest { return new TransactGetSingleTableRequest(this.dynamoDBWrapper, this.modelClazz, keys) } - - /** - * TODO v3: check for potential replacement - */ - // makeRequest(operation: DynamoApiOperations, params?: Record): Promise { - // this.logger.debug('request', params) - // return this.dynamoDBWrapper - // .makeRequest(operation, params) - // .then(promiseTap((r: Z) => this.logger.debug('response', r))) - // } }