Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: drop using internal modules #258

Merged
merged 14 commits into from
Feb 24, 2021
Merged
11 changes: 0 additions & 11 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,6 @@ jobs:
- checkout
- restore_cache:
key: dependency-cache-v3-{{ checksum "src/package-lock.json" }}
paths:
- src/node_modules
- run:
name: Create dir for lint results
command: cd src && mkdir -p /lintresults
Expand All @@ -207,8 +205,6 @@ jobs:
- checkout
- restore_cache:
key: dependency-cache-v3-{{ checksum "src/package-lock.json" }}
paths:
- src/node_modules
- run:
name: Create dir for test results
command: mkdir -p ./audit/results
Expand All @@ -217,7 +213,6 @@ jobs:
command: cd src && npm run audit:check --silent -- --json > ../audit/results/auditResults.json
- store_artifacts:
path: ./audit/results
prefix: audit

audit-licenses:
executor: default-docker
Expand All @@ -230,14 +225,11 @@ jobs:
<<: *defaults_license_scanner
- restore_cache:
key: dependency-cache-v3-{{ checksum "src/package-lock.json" }}
paths:
- src/node_modules
- run:
name: Run the license-scanner
command: cd /tmp/license-scanner && pathToRepo=$CIRCLE_WORKING_DIRECTORY make run
- store_artifacts:
path: /tmp/license-scanner/results
prefix: licenses

build-local:
executor: default-machine
Expand Down Expand Up @@ -272,7 +264,6 @@ jobs:
command: cd /tmp/license-scanner && mode=docker dockerImages=mojaloop/$CIRCLE_PROJECT_REPONAME:local make run
- store_artifacts:
path: /tmp/license-scanner/results
prefix: licenses

image-scan:
executor: anchore/anchore_engine
Expand Down Expand Up @@ -333,8 +324,6 @@ jobs:
- checkout
- restore_cache:
key: dependency-cache-v3-{{ checksum "src/package-lock.json" }}
paths:
- src/node_modules
- run:
name: Configure git
command: |
Expand Down
8 changes: 0 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@ WORKDIR /src/
# relying on docker-compose.
COPY ./src/package.json ./package.json
COPY ./src/package-lock.json ./package-lock.json
COPY ./src/lib/cache/package.json ./lib/cache/package.json
COPY ./src/lib/check/package.json ./lib/check/package.json
COPY ./src/lib/model/lib/requests/package.json ./lib/model/lib/requests/package.json
COPY ./src/lib/model/lib/shared/package.json ./lib/model/lib/shared/package.json
COPY ./src/lib/model/package.json ./lib/model/package.json
COPY ./src/lib/randomphrase/package.json ./lib/randomphrase/package.json
COPY ./src/lib/router/package.json ./lib/router/package.json
COPY ./src/lib/validate/package.json ./lib/validate/package.json
RUN npm ci --only=production

FROM node:14.15-alpine
Expand Down
10 changes: 5 additions & 5 deletions src/InboundServer/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@

'use strict';

const Model = require('@internal/model').InboundTransfersModel;
const PartiesModel = require('@internal/model').PartiesModel;
const QuotesModel = require('@internal/model').QuotesModel;
const TransfersModel = require('@internal/model').TransfersModel;
const AuthorizationsModel = require('@internal/model').AuthorizationsModel;
const Model = require('../lib/model').InboundTransfersModel;
const PartiesModel = require('../lib/model').PartiesModel;
const QuotesModel = require('../lib/model').QuotesModel;
const TransfersModel = require('../lib/model').TransfersModel;
const AuthorizationsModel = require('../lib/model').AuthorizationsModel;

/**
* Handles a GET /authorizations/{id} request
Expand Down
4 changes: 2 additions & 2 deletions src/InboundServer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ const EventEmitter = require('events');

const { WSO2Auth } = require('@mojaloop/sdk-standard-components');

const Validate = require('@internal/validate');
const router = require('@internal/router');
const Validate = require('../lib/validate');
const router = require('../lib/router');
const handlers = require('./handlers');
const middlewares = require('./middlewares');

Expand Down
2 changes: 1 addition & 1 deletion src/InboundServer/middlewares.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

const coBody = require('co-body');

const randomPhrase = require('@internal/randomphrase');
const randomPhrase = require('../lib/randomphrase');
const { Jws, Errors } = require('@mojaloop/sdk-standard-components');

/**
Expand Down
33 changes: 18 additions & 15 deletions src/OutboundServer/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ paths:
operationId: PartiesByTypeAndID
responses:
'200':
$ref: '#/components/responses/partiesByIdResponse'
$ref: '#/components/responses/partiesByIdSuccess'
'404':
$ref: '#/components/responses/partiesByIdError404'
'/parties/{Type}/{ID}/{SubId}':
Expand All @@ -427,7 +427,7 @@ paths:
operationId: PartiesSubIdByTypeAndID
responses:
'200':
$ref: '#/components/responses/partiesByIdResponse'
$ref: '#/components/responses/partiesByIdSuccess'
'404':
$ref: '#/components/responses/partiesByIdError404'
/quotes:
Expand Down Expand Up @@ -2115,6 +2115,19 @@ components:
- WAITING_FOR_ACTION
- COMPLETED
- ERROR_OCCURRED
partiesByIdResponse:
title: partiesByIdResponse
type: object
description: 'GET /parties/{Type}/{ID} response object'
properties:
party:
$ref: '#/components/schemas/Party'
description: Information regarding the requested Party.
currentState:
$ref: '#/components/schemas/async2SyncCurrentState'
required:
- party
- currentState
QuotesPostRequest:
title: QuotesPostRequest
type: object
Expand Down Expand Up @@ -2607,22 +2620,12 @@ components:
application/json:
schema:
$ref: '#/components/schemas/errorAccountsResponse'
partiesByIdResponse:
description: PartiesByIdResponse
partiesByIdSuccess:
description: PartiesByIdSuccess
content:
application/json:
schema:
type: object
description: 'GET /parties/{Type}/{ID} response object'
properties:
party:
$ref: '#/components/schemas/Party'
description: Information regarding the requested Party.
currentState:
$ref: '#/components/schemas/async2SyncCurrentState'
required:
- party
- currentState
$ref: '#/components/schemas/partiesByIdResponse'
partiesByIdError404:
description: PartiesByIdError404
content:
Expand Down
1 change: 1 addition & 0 deletions src/OutboundServer/api_interfaces/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export declare namespace Schemas {
type PartyPersonalInfo = components["schemas"]["PartyPersonalInfo"];
type Party = components["schemas"]["Party"];
type async2SyncCurrentState = components["schemas"]["async2SyncCurrentState"];
type partiesByIdResponse = components["schemas"]["partiesByIdResponse"];
type QuotesPostRequest = components["schemas"]["QuotesPostRequest"];
type quotesPostRequest = components["schemas"]["quotesPostRequest"];
type quotesPostResponse = components["schemas"]["quotesPostResponse"];
Expand Down
20 changes: 11 additions & 9 deletions src/OutboundServer/api_interfaces/openapi.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,14 +288,14 @@ export interface operations {
/** The HTTP request GET /parties// (or GET /parties///) is used to lookup information regarding the requested Party, defined by , and optionally (for example, GET /parties/MSISDN/123456789, or GET /parties/BUSINESS/shoecompany/employee1). */
PartiesByTypeAndID: {
responses: {
200: components["responses"]["partiesByIdResponse"];
200: components["responses"]["partiesByIdSuccess"];
404: components["responses"]["partiesByIdError404"];
};
};
/** The HTTP request GET /parties// (or GET /parties///) is used to lookup information regarding the requested Party, defined by , and optionally (for example, GET /parties/MSISDN/123456789, or GET /parties/BUSINESS/shoecompany/employee1). */
PartiesSubIdByTypeAndID: {
responses: {
200: components["responses"]["partiesByIdResponse"];
200: components["responses"]["partiesByIdSuccess"];
404: components["responses"]["partiesByIdError404"];
};
};
Expand Down Expand Up @@ -1085,6 +1085,12 @@ export interface components {
| "WAITING_FOR_ACTION"
| "COMPLETED"
| "ERROR_OCCURRED";
/** GET /parties/{Type}/{ID} response object */
partiesByIdResponse: {
/** Information regarding the requested Party. */
party: components["schemas"]["Party"];
currentState: components["schemas"]["async2SyncCurrentState"];
};
/** The object sent in the POST /quotes request. */
QuotesPostRequest: {
/** Common ID between the FSPs for the quote object, decided by the Payer FSP. The ID should be reused for resends of the same quote for a transaction. A new ID should be generated for each new quote for a transaction. */
Expand Down Expand Up @@ -1341,14 +1347,10 @@ export interface components {
"application/json": components["schemas"]["errorAccountsResponse"];
};
};
/** PartiesByIdResponse */
partiesByIdResponse: {
/** PartiesByIdSuccess */
partiesByIdSuccess: {
content: {
"application/json": {
/** Information regarding the requested Party. */
party: components["schemas"]["Party"];
currentState: components["schemas"]["async2SyncCurrentState"];
};
"application/json": components["schemas"]["partiesByIdResponse"];
};
};
/** PartiesByIdError404 */
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
description: PartiesByIdSuccess
content:
application/json:
schema:
$ref: ../schemas/partiesByIdResponse.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
title: partiesByIdResponse
type: object
description: 'GET /parties/{Type}/{ID} response object'
properties:
party:
$ref: >-
../../../../node_modules/@mojaloop/api-snippets/thirdparty/openapi3/components/schemas/Party.yaml
description: Information regarding the requested Party.
currentState:
$ref: ../schemas/async2SyncCurrentState.yaml
required:
- party
- currentState
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ get:
operationId: PartiesByTypeAndID
responses:
'200':
$ref: ../components/responses/partiesByIdResponse.yaml
$ref: ../components/responses/partiesByIdSuccess.yaml
'404':
$ref: ../components/responses/partiesByIdError404.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ get:
operationId: PartiesSubIdByTypeAndID
responses:
'200':
$ref: ../components/responses/partiesByIdResponse.yaml
$ref: ../components/responses/partiesByIdSuccess.yaml
'404':
$ref: ../components/responses/partiesByIdError404.yaml
2 changes: 1 addition & 1 deletion src/OutboundServer/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const {
QuotesModel,
TransfersModel,
AuthorizationsModel
} = require('@internal/model');
} = require('../lib/model');


/**
Expand Down
4 changes: 2 additions & 2 deletions src/OutboundServer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ const cors = require('@koa/cors');

const { WSO2Auth } = require('@mojaloop/sdk-standard-components');

const Validate = require('@internal/validate');
const router = require('@internal/router');
const Validate = require('../lib/validate');
const router = require('../lib/router');
const handlers = require('./handlers');
const middlewares = require('./middlewares');

Expand Down
2 changes: 1 addition & 1 deletion src/OutboundServer/middlewares.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
**************************************************************************/


const { ProxyModel } = require('@internal/model');
const { ProxyModel } = require('../lib/model');
const { applyState, createErrorHandler, createLogger, createRequestIdGenerator } =
require('../InboundServer/middlewares');

Expand Down
4 changes: 2 additions & 2 deletions src/TestServer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ const yaml = require('js-yaml');
const fs = require('fs').promises;
const path = require('path');

const Validate = require('@internal/validate');
const router = require('@internal/router');
const Validate = require('../lib/validate');
const router = require('../lib/router');
const handlers = require('./handlers');
const middlewares = require('../InboundServer/middlewares');

Expand Down
6 changes: 1 addition & 5 deletions src/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
import * as OutboundAPI from './OutboundServer/api_interfaces';
declare const _default: {
OutboundAPI: typeof OutboundAPI;
};
export default _default;
export * as OutboundAPI from './OutboundServer/api_interfaces';
8 changes: 4 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ const TestServer = require('./TestServer');
// scheme adapter as a service
const InboundServerMiddleware = require('./InboundServer/middlewares.js');
const OutboundServerMiddleware = require('./OutboundServer/middlewares.js');
const Router = require('@internal/router');
const Validate = require('@internal/validate');
const RandomPhrase = require('@internal/randomphrase');
const Cache = require('@internal/cache');
const Router = require('./lib/router');
const Validate = require('./lib/validate');
const RandomPhrase = require('./lib/randomphrase');
const Cache = require('./lib/cache');
const { Logger } = require('@mojaloop/sdk-standard-components');

/**
Expand Down
File renamed without changes.
20 changes: 0 additions & 20 deletions src/lib/cache/package.json

This file was deleted.

File renamed without changes.
12 changes: 0 additions & 12 deletions src/lib/check/package.json

This file was deleted.

2 changes: 1 addition & 1 deletion src/lib/model/Async2SyncModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const util = require('util');

const PSM = require('./common').PersistentStateMachine;
const MojaloopRequests = require('@mojaloop/sdk-standard-components').MojaloopRequests;
const deferredJob = require('@internal/shared/deferredJob');
const deferredJob = require('./lib').deferredJob;

function generate({
/**
Expand Down
Loading