"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SearchOptions = void 0;
/*
 *
 * Copyright 2018-present NEM
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */
const clime_1 = require("clime");
const offset_resolver_1 = require("../resolvers/offset.resolver");
const order_resolver_1 = require("../resolvers/order.resolver");
const pageNumber_resolver_1 = require("../resolvers/pageNumber.resolver");
const pageSize_resolver_1 = require("../resolvers/pageSize.resolver");
const profile_options_1 = require("./profile.options");
/**
 * Search options
 */
class SearchOptions extends profile_options_1.ProfileOptions {
    async buildBaseSearchCriteria() {
        const criteria = {
            order: await new order_resolver_1.OrderResolver().resolve(this),
            pageSize: await new pageSize_resolver_1.PageSizeResolver().resolve(this),
            pageNumber: await new pageNumber_resolver_1.PageNumberResolver().resolve(this),
        };
        if (this.offset) {
            criteria.offset = await new offset_resolver_1.OffsetResolver().resolve(this);
        }
        return criteria;
    }
}
__decorate([
    (0, clime_1.option)({
        flag: 'o',
        description: '(Optional): Sort entries. (Desc: Newer to older, Asc: Older to newer)',
        default: 'Desc',
    }),
    __metadata("design:type", String)
], SearchOptions.prototype, "order", void 0);
__decorate([
    (0, clime_1.option)({
        flag: 'n',
        description: '(Optional) Number of entries per page.',
        default: 10,
    }),
    __metadata("design:type", Number)
], SearchOptions.prototype, "pageSize", void 0);
__decorate([
    (0, clime_1.option)({
        flag: 'n',
        description: '(Optional) Filter by page number.',
        default: 1,
    }),
    __metadata("design:type", Number)
], SearchOptions.prototype, "pageNumber", void 0);
__decorate([
    (0, clime_1.option)({
        flag: 'i',
        description: '(Optional) Database entry id at which to start pagination.',
    }),
    __metadata("design:type", String)
], SearchOptions.prototype, "offset", void 0);
exports.SearchOptions = SearchOptions;
