Skip to content

Commit

Permalink
take page size from user input, if exists
Browse files Browse the repository at this point in the history
  • Loading branch information
pnedelko committed Jun 6, 2023
1 parent e1738ee commit 6a69979
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
8 changes: 3 additions & 5 deletions templates/lib/actions/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ function processAction(msg, cfg, snapshot, incomingMessageHeaders, tokenData) {
const { pathName, method, requestContentType } = action.callParams;

const specPath = spec.paths[pathName];
const specPathParameters = specPath[method].parameters
? specPath[method].parameters.map(({ name }) => name)
: [];
const specPathParameters = specPath[method].parameters ? specPath[method].parameters.map(({ name }) => name) : [];

const body = msg.data;
mapFieldNames(body);
Expand Down Expand Up @@ -71,9 +69,9 @@ function processAction(msg, cfg, snapshot, incomingMessageHeaders, tokenData) {

// Call operation via Swagger client
return Swagger.execute(callParams).then((resp) => {
this.logger.info("Swagger response %j", resp);
const { body, headers } = resp;
this.logger.info("Swagger response %j", { body, headers });

delete resp.uid;
const newElement = {};
newElement.metadata = getMetadata(msg.metadata);
newElement.data = resp.data;
Expand Down
12 changes: 9 additions & 3 deletions templates/lib/triggers/trigger.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ async function processTrigger(msg, cfg, snapshot, incomingMessageHeaders, tokenD

const paginationConfig = $PAGINATION_CONFIG;

// if there is user provided pageSize
if (paginationConfig?.pageSizeOption?.fieldName && parameters[paginationConfig.pageSizeOption.fieldName]) {
paginationConfig.strategy.pageSize = parseInt(parameters[paginationConfig.pageSizeOption.fieldName]);
}

this.logger.info("Pagination config %j", paginationConfig);

const paginator = createPaginator(paginationConfig);

let hasMorePages = true;
Expand All @@ -72,12 +79,11 @@ async function processTrigger(msg, cfg, snapshot, incomingMessageHeaders, tokenD
this.logger.info("Call params %j", callParamsForLogging);

const resp = await Swagger.execute(callParams);
this.logger.info("Swagger response %j", resp);
const { body, headers } = resp;
this.logger.info("Swagger response %j", { body, headers });

const newElement = {};
newElement.metadata = getMetadata(msg.metadata);
const body = resp.body;
const headers = resp.headers;

newElement.data = getElementDataFromResponse(arraySplittingKey, body);
if (skipSnapshot) {
Expand Down

0 comments on commit 6a69979

Please sign in to comment.