Skip to content

Commit

Permalink
chore(DTFS2-6889): update durable functions package to v3 (#2887)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarRobSoftwire authored Mar 28, 2024
1 parent ef51d86 commit 2f749a9
Show file tree
Hide file tree
Showing 58 changed files with 732 additions and 449 deletions.
3 changes: 3 additions & 0 deletions azure-functions/acbs-function/__mocks__/durable-functions.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
const actualDurableFunctions = jest.requireActual('durable-functions');

const mockClient = {
startNew: jest.fn(() => 'mockInstanceId'),
createCheckStatusResponse: jest.fn(),
};

module.exports = {
...actualDurableFunctions,
getClient: jest.fn(() => mockClient),
};

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const df = require('durable-functions');
const retryOptions = require('../helpers/retryOptions');
const mappings = require('../mappings');

module.exports = df.orchestrator(function* Facility(context) {
df.app.orchestration('acbs-amend-facility-loan-record', function* Facility(context) {
try {
if (context.df.getInput()) {
const { facilityId, facility, amendments, fmr } = context.df.getInput();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const df = require('durable-functions');
const retryOptions = require('../helpers/retryOptions');
const mappings = require('../mappings');

module.exports = df.orchestrator(function* Facility(context) {
df.app.orchestration('acbs-amend-facility-master-record', function* Facility(context) {
try {
if (context.df.getInput()) {
const { deal, facilityId, fmr, etag, amendments } = context.df.getInput();
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion azure-functions/acbs-function/acbs-amend-facility/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const { DEAL, FACILITY } = require('../constants');

const acceptableFacilityStage = ['07'];

module.exports = df.orchestrator(function* amendACBSFacility(context) {
df.app.orchestration('acbs-amend-facility', function* amendACBSFacility(context) {
try {
const { amendment } = context.df.getInput();
if (amendment) {
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion azure-functions/acbs-function/acbs-facility-bond/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const mappings = require('../mappings');
const CONSTANTS = require('../constants');
const retryOptions = require('../helpers/retryOptions');

module.exports = df.orchestrator(function* createACBSfacilityBond(context) {
df.app.orchestration('acbs-facility-bond', function* createACBSfacilityBond(context) {
try {
const { deal, facility, dealAcbsData } = context.df.getInput();

Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion azure-functions/acbs-function/acbs-facility-loan/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const mappings = require('../mappings');
const CONSTANTS = require('../constants');
const retryOptions = require('../helpers/retryOptions');

module.exports = df.orchestrator(function* createACBSfacilityBond(context) {
df.app.orchestration('acbs-facility-loan', function* createACBSfacilityBond(context) {
try {
const { deal, facility, dealAcbsData } = context.df.getInput();

Expand Down
9 changes: 0 additions & 9 deletions azure-functions/acbs-function/acbs-facility/function.json

This file was deleted.

2 changes: 1 addition & 1 deletion azure-functions/acbs-function/acbs-facility/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const mappings = require('../mappings');
const CONSTANTS = require('../constants');
const helpers = require('../mappings/facility/helpers');

module.exports = df.orchestrator(function* createACBSfacility(context) {
df.app.orchestration('acbs-facility', function* createACBSfacility(context) {
const { deal, facility, dealAcbsData, acbsReference } = context.df.getInput();
let facilityLoan;
let facilityFee;
Expand Down
24 changes: 0 additions & 24 deletions azure-functions/acbs-function/acbs-http/function.json

This file was deleted.

2 changes: 1 addition & 1 deletion azure-functions/acbs-function/acbs-http/index.api-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ test('Http trigger should return known text', async () => {

await httpFunction(context, request);

expect(df.mockClient.startNew).toHaveBeenCalledWith(request.params.functionName, undefined, request.body);
expect(df.mockClient.startNew).toHaveBeenCalledWith(request.params.functionName, { input: request.body });
expect(df.mockClient.createCheckStatusResponse).toHaveBeenCalledWith(context.bindingData.req, 'mockInstanceId');
});
9 changes: 8 additions & 1 deletion azure-functions/acbs-function/acbs-http/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
const df = require('durable-functions');
const { app } = require('@azure/functions');

const acbsHttp = async (context, req) => {
console.info('⚡️ Invoking ACBS DOF via Azure HTTP trigger');

const client = df.getClient(context);
const instanceId = await client.startNew(req.params.functionName, undefined, req.body);
const instanceId = await client.startNew(req.params.functionName, { input: req.body });

return client.createCheckStatusResponse(context.bindingData.req, instanceId);
};

module.exports = acbsHttp;

app.http('acbs-http', {
route: 'orchestrators/{orchestratorName}',
extraInputs: [df.input.durableClient()],
handler: acbsHttp,
});

This file was deleted.

2 changes: 1 addition & 1 deletion azure-functions/acbs-function/acbs-issue-facility/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const retryOptions = require('../helpers/retryOptions');
const mappings = require('../mappings');
const CONSTANTS = require('../constants');

module.exports = df.orchestrator(function* updateACBSfacility(context) {
df.app.orchestration('acbs-issue-facility', function* updateACBSfacility(context) {
try {
const { facilityId, facility, deal } = context.df.getInput();

Expand Down
9 changes: 0 additions & 9 deletions azure-functions/acbs-function/acbs/function.json

This file was deleted.

2 changes: 1 addition & 1 deletion azure-functions/acbs-function/acbs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const mappings = require('../mappings');
const retryOptions = require('../helpers/retryOptions');
const CONSTANTS = require('../constants');

module.exports = df.orchestrator(function* HDeal(context) {
df.app.orchestration('acbs', function* HDeal(context) {
try {
if (context.df.getInput()) {
const { deal, bank } = context.df.getInput();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* * - run 'npm install durable-functions' from the wwwroot folder of your
* function app in Kudu
*/

const df = require('durable-functions');
const { getNowAsIsoString } = require('../helpers/date');
const api = require('../api');
const { isHttpErrorStatus } = require('../helpers/http');
Expand All @@ -23,7 +23,7 @@ const createCodeValueTransaction = async (context) => {
const missingMandatory = findMissingMandatory(acbsCodeValueTransactionInput, mandatoryFields);

if (missingMandatory.length) {
return Promise.resolve({ missingMandatory });
return { missingMandatory };
}

const submittedToACBS = getNowAsIsoString();
Expand Down Expand Up @@ -60,4 +60,6 @@ const createCodeValueTransaction = async (context) => {
}
};

module.exports = createCodeValueTransaction;
df.app.activity('create-code-value-transation', {
handler: createCodeValueTransaction,
});

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* * - run 'npm install durable-functions' from the wwwroot folder of your
* function app in Kudu
*/
const df = require('durable-functions');
const { getNowAsIsoString } = require('../helpers/date');
const api = require('../api');
const { isHttpErrorStatus } = require('../helpers/http');
Expand All @@ -22,7 +23,7 @@ const createDealGuarantee = async (context) => {
const missingMandatory = findMissingMandatory(guarantee, mandatoryFields);

if (missingMandatory.length) {
return Promise.resolve({ missingMandatory });
return { missingMandatory };
}

const submittedToACBS = getNowAsIsoString();
Expand Down Expand Up @@ -60,4 +61,6 @@ const createDealGuarantee = async (context) => {
}
};

module.exports = createDealGuarantee;
df.app.activity('create-deal-guarantee', {
handler: createDealGuarantee,
});

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* * - run 'npm install durable-functions' from the wwwroot folder of your
* function app in Kudu
*/
const df = require('durable-functions');
const { getNowAsIsoString } = require('../helpers/date');
const api = require('../api');
const { isHttpErrorStatus } = require('../helpers/http');
Expand All @@ -22,7 +23,7 @@ const createDealInvestor = async (context) => {
const missingMandatory = findMissingMandatory(investor, mandatoryFields);

if (missingMandatory.length) {
return Promise.resolve({ missingMandatory });
return { missingMandatory };
}

const submittedToACBS = getNowAsIsoString();
Expand Down Expand Up @@ -60,4 +61,6 @@ const createDealInvestor = async (context) => {
}
};

module.exports = createDealInvestor;
df.app.activity('create-deal-investor', {
handler: createDealInvestor,
});

This file was deleted.

7 changes: 5 additions & 2 deletions azure-functions/acbs-function/activity-create-deal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* * - run 'npm install durable-functions' from the wwwroot folder of your
* function app in Kudu
*/
const df = require('durable-functions');
const { getNowAsIsoString } = require('../helpers/date');
const api = require('../api');
const { isHttpErrorStatus } = require('../helpers/http');
Expand All @@ -30,7 +31,7 @@ const createDeal = async (context) => {
const missingMandatory = findMissingMandatory(deal, mandatoryFields);

if (missingMandatory.length) {
return Promise.resolve({ missingMandatory });
return { missingMandatory };
}

const submittedToACBS = getNowAsIsoString();
Expand Down Expand Up @@ -68,4 +69,6 @@ const createDeal = async (context) => {
}
};

module.exports = createDeal;
df.app.activity('create-deal', {
handler: createDeal,
});

This file was deleted.

Loading

0 comments on commit 2f749a9

Please sign in to comment.