@villedemontreal/workit-bpm-client
Version:
Camunda BPM client for WorkIt that works with Camunda platform powered by TypeScript
38 lines • 1.59 kB
JavaScript
/*
* Copyright (c) 2025 Ville de Montreal. All rights reserved.
* Licensed under the MIT license.
* See LICENSE file in the project root for full license information.
*/
/* eslint @typescript-eslint/no-redundant-type-constituents: 0 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.PaginationUtils = void 0;
class PaginationUtils {
static setCamundaBpmPaginationParams(params, options) {
if (!options) {
return params;
}
// make no sens to set size to 0
return { ...params, firstResult: options.from, maxResults: options.size || PaginationUtils._DEFAULT_SIZE_ITEMS };
}
static getPagingFromOptions(totalCount, options) {
// https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-from-size.html
if (!options) {
return {
from: 0,
size: PaginationUtils._DEFAULT_SIZE_ITEMS,
totalCount,
};
}
return {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment
from: typeof options.from === 'number' ? options.from : 0,
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment
size: options.size || PaginationUtils._DEFAULT_SIZE_ITEMS,
totalCount,
};
}
}
exports.PaginationUtils = PaginationUtils;
PaginationUtils._DEFAULT_SIZE_ITEMS = 500;
//# sourceMappingURL=paginationUtils.js.map
;