"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
    for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.aConnectionType = aConnectionType;
exports.aCreateExternalDatabaseConnectionRequest = aCreateExternalDatabaseConnectionRequest;
exports.aCreateExternalDatabaseConnectionResponse = aCreateExternalDatabaseConnectionResponse;
exports.aDeleteExternalDatabaseConnectionRequest = aDeleteExternalDatabaseConnectionRequest;
exports.aDeleteExternalDatabaseConnectionResponse = aDeleteExternalDatabaseConnectionResponse;
exports.aExternalDatabaseConnection = aExternalDatabaseConnection;
exports.aCapabilities = aCapabilities;
exports.aConnectionStatus = aConnectionStatus;
exports.aCauseOfFailure = aCauseOfFailure;
exports.aCollectionsFound = aCollectionsFound;
exports.aProtocolVersion = aProtocolVersion;
exports.aGetExternalDatabaseConnectionRequest = aGetExternalDatabaseConnectionRequest;
exports.aGetExternalDatabaseConnectionResponse = aGetExternalDatabaseConnectionResponse;
exports.aListExternalDatabaseConnectionsRequest = aListExternalDatabaseConnectionsRequest;
exports.aListExternalDatabaseConnectionsResponse = aListExternalDatabaseConnectionsResponse;
exports.aUpdateExternalDatabaseConnectionRequest = aUpdateExternalDatabaseConnectionRequest;
exports.aUpdateExternalDatabaseConnectionResponse = aUpdateExternalDatabaseConnectionResponse;
exports.aFieldType = aFieldType;
exports.aAccountInfo = aAccountInfo;
exports.aIdentificationData = aIdentificationData;
exports.aWebhookIdentityType = aWebhookIdentityType;
exports.aMessageEnvelope = aMessageEnvelope;
exports.aPaging = aPaging;
exports.aPagingMetadata = aPagingMetadata;
exports.aActionEvent = aActionEvent;
exports.aDomainEvent = aDomainEvent;
exports.aEntityCreatedEvent = aEntityCreatedEvent;
exports.aEntityDeletedEvent = aEntityDeletedEvent;
exports.aEntityUpdatedEvent = aEntityUpdatedEvent;
exports.aRestoreInfo = aRestoreInfo;
var metro_common_builders_1 = require("@wix/metro-common-builders");
var types_impl_js_1 = require("./types.impl.js");
// @ts-ignore
var callsite_1 = __importDefault(require("callsite"));
function aConnectionType(enumFirstItem) {
    if (enumFirstItem === void 0) { enumFirstItem = types_impl_js_1.ConnectionType.UNKNOWN_CONNECTION_TYPE; }
    return enumFirstItem;
}
function aCreateExternalDatabaseConnectionRequest(overrideObject) {
    if (overrideObject === void 0) { overrideObject = {}; }
    if (isCurrentBuilderWasPreviouslyCalled()) {
        return {};
    }
    return (0, metro_common_builders_1.mergeDeep)({
        externalDatabaseConnection: aExternalDatabaseConnection(),
        connectionType: aConnectionType(),
        databaseManagedByWix: true,
    }, overrideObject);
}
function aCreateExternalDatabaseConnectionResponse(overrideObject) {
    if (overrideObject === void 0) { overrideObject = {}; }
    if (isCurrentBuilderWasPreviouslyCalled()) {
        return {};
    }
    return (0, metro_common_builders_1.mergeDeep)({
        externalDatabaseConnection: aExternalDatabaseConnection(),
    }, overrideObject);
}
function aDeleteExternalDatabaseConnectionRequest(overrideObject) {
    if (overrideObject === void 0) { overrideObject = {}; }
    return (0, metro_common_builders_1.mergeDeep)({
        name: (0, metro_common_builders_1.someString)({
            validations: [{ type: 'MAX_LENGTH', value: '255' }],
        }),
    }, overrideObject);
}
function aDeleteExternalDatabaseConnectionResponse(overrideObject) {
    if (overrideObject === void 0) { overrideObject = {}; }
    return (0, metro_common_builders_1.mergeDeep)({}, overrideObject);
}
function aExternalDatabaseConnection(overrideObject) {
    if (overrideObject === void 0) { overrideObject = {}; }
    if (isCurrentBuilderWasPreviouslyCalled()) {
        return {};
    }
    return (0, metro_common_builders_1.mergeDeep)({
        name: (0, metro_common_builders_1.someString)({
            validations: [
                { type: 'IMMUTABLE', value: 'true' },
                { type: 'MIN_LENGTH', value: '1' },
                { type: 'MAX_LENGTH', value: '255' },
            ],
        }),
        endpoint: (0, metro_common_builders_1.someString)({
            validations: [{ type: 'FORMAT', value: 'WEB_URL' }],
        }),
        configuration: {},
        connectionStatus: aConnectionStatus(),
        protocolVersion: aProtocolVersion(),
        publicKey: (0, metro_common_builders_1.someString)({
            validations: [
                { type: 'READ_ONLY', value: 'true' },
                { type: 'MAX_LENGTH', value: '128' },
            ],
        }),
        capabilities: aCapabilities(),
        applicationId: (0, metro_common_builders_1.someString)({
            validations: [
                { type: 'READ_ONLY', value: 'true' },
                { type: 'MAX_LENGTH', value: '128' },
            ],
        }),
    }, overrideObject);
}
function aCapabilities(overrideObject) {
    if (overrideObject === void 0) { overrideObject = {}; }
    if (isCurrentBuilderWasPreviouslyCalled()) {
        return {};
    }
    return (0, metro_common_builders_1.mergeDeep)({
        collectionModificationsSupported: true,
        fieldTypes: [
            aFieldType(),
            aFieldType(),
            aFieldType(),
            aFieldType(),
            aFieldType(),
            aFieldType(),
            aFieldType(),
            aFieldType(),
            aFieldType(),
            aFieldType(),
        ],
    }, overrideObject);
}
function aConnectionStatus(overrideObject) {
    if (overrideObject === void 0) { overrideObject = {}; }
    if (isCurrentBuilderWasPreviouslyCalled()) {
        return {};
    }
    return (0, metro_common_builders_1.mergeDeep)({
        successful: true,
        causeOfFailure: aCauseOfFailure(),
        hasCollections: aCollectionsFound(),
    }, overrideObject);
}
function aCauseOfFailure(enumFirstItem) {
    if (enumFirstItem === void 0) { enumFirstItem = types_impl_js_1.CauseOfFailure.NONE; }
    return enumFirstItem;
}
function aCollectionsFound(enumFirstItem) {
    if (enumFirstItem === void 0) { enumFirstItem = types_impl_js_1.CollectionsFound.UNKNOWN; }
    return enumFirstItem;
}
function aProtocolVersion(enumFirstItem) {
    if (enumFirstItem === void 0) { enumFirstItem = types_impl_js_1.ProtocolVersion.UNKNOWN_PROTOCOL_VERSION; }
    return enumFirstItem;
}
function aGetExternalDatabaseConnectionRequest(overrideObject) {
    if (overrideObject === void 0) { overrideObject = {}; }
    return (0, metro_common_builders_1.mergeDeep)({
        name: (0, metro_common_builders_1.someString)({
            validations: [{ type: 'MAX_LENGTH', value: '255' }],
        }),
    }, overrideObject);
}
function aGetExternalDatabaseConnectionResponse(overrideObject) {
    if (overrideObject === void 0) { overrideObject = {}; }
    if (isCurrentBuilderWasPreviouslyCalled()) {
        return {};
    }
    return (0, metro_common_builders_1.mergeDeep)({
        externalDatabaseConnection: aExternalDatabaseConnection(),
    }, overrideObject);
}
function aListExternalDatabaseConnectionsRequest(overrideObject) {
    if (overrideObject === void 0) { overrideObject = {}; }
    if (isCurrentBuilderWasPreviouslyCalled()) {
        return {};
    }
    return (0, metro_common_builders_1.mergeDeep)({
        paging: aPaging(),
    }, overrideObject);
}
function aListExternalDatabaseConnectionsResponse(overrideObject) {
    if (overrideObject === void 0) { overrideObject = {}; }
    if (isCurrentBuilderWasPreviouslyCalled()) {
        return {};
    }
    return (0, metro_common_builders_1.mergeDeep)({
        externalDatabaseConnections: [aExternalDatabaseConnection()],
        pagingMetadata: aPagingMetadata(),
    }, overrideObject);
}
function aUpdateExternalDatabaseConnectionRequest(overrideObject) {
    if (overrideObject === void 0) { overrideObject = {}; }
    if (isCurrentBuilderWasPreviouslyCalled()) {
        return {};
    }
    return (0, metro_common_builders_1.mergeDeep)({
        externalDatabaseConnection: aExternalDatabaseConnection(),
    }, overrideObject);
}
function aUpdateExternalDatabaseConnectionResponse(overrideObject) {
    if (overrideObject === void 0) { overrideObject = {}; }
    if (isCurrentBuilderWasPreviouslyCalled()) {
        return {};
    }
    return (0, metro_common_builders_1.mergeDeep)({
        externalDatabaseConnection: aExternalDatabaseConnection(),
    }, overrideObject);
}
function aFieldType(enumFirstItem) {
    if (enumFirstItem === void 0) { enumFirstItem = types_impl_js_1.FieldType.UNKNOWN_FIELD_TYPE; }
    return enumFirstItem;
}
function aAccountInfo(overrideObject) {
    if (overrideObject === void 0) { overrideObject = {}; }
    return (0, metro_common_builders_1.mergeDeep)({
        accountId: (0, metro_common_builders_1.someString)({
            validations: [{ type: 'FORMAT', value: 'GUID' }],
        }),
        parentAccountId: (0, metro_common_builders_1.someString)({
            validations: [{ type: 'FORMAT', value: 'GUID' }],
        }),
        siteId: (0, metro_common_builders_1.someString)({
            validations: [{ type: 'FORMAT', value: 'GUID' }],
        }),
    }, overrideObject);
}
function aIdentificationData(overrideObject) {
    if (overrideObject === void 0) { overrideObject = {}; }
    if (isCurrentBuilderWasPreviouslyCalled()) {
        return {};
    }
    return (0, metro_common_builders_1.mergeDeep)({
        anonymousVisitorId: (0, metro_common_builders_1.someString)({
            validations: [{ type: 'FORMAT', value: 'GUID' }],
        }),
        identityType: aWebhookIdentityType(),
    }, overrideObject);
}
function aWebhookIdentityType(enumFirstItem) {
    if (enumFirstItem === void 0) { enumFirstItem = types_impl_js_1.WebhookIdentityType.UNKNOWN; }
    return enumFirstItem;
}
function aMessageEnvelope(overrideObject) {
    if (overrideObject === void 0) { overrideObject = {}; }
    if (isCurrentBuilderWasPreviouslyCalled()) {
        return {};
    }
    return (0, metro_common_builders_1.mergeDeep)({
        instanceId: (0, metro_common_builders_1.someString)({
            validations: [{ type: 'FORMAT', value: 'GUID' }],
        }),
        eventType: (0, metro_common_builders_1.someString)({
            validations: [{ type: 'MAX_LENGTH', value: '150' }],
        }),
        identity: aIdentificationData(),
        data: (0, metro_common_builders_1.someString)(),
        accountInfo: aAccountInfo(),
    }, overrideObject);
}
function aPaging(overrideObject) {
    if (overrideObject === void 0) { overrideObject = {}; }
    return (0, metro_common_builders_1.mergeDeep)({
        limit: (0, metro_common_builders_1.someNumber)({
            validations: [{ type: 'MIN' }],
        }),
        offset: (0, metro_common_builders_1.someNumber)({
            validations: [{ type: 'MIN' }],
        }),
    }, overrideObject);
}
function aPagingMetadata(overrideObject) {
    if (overrideObject === void 0) { overrideObject = {}; }
    return (0, metro_common_builders_1.mergeDeep)({
        count: (0, metro_common_builders_1.someNumber)(),
        offset: (0, metro_common_builders_1.someNumber)(),
        total: (0, metro_common_builders_1.someNumber)(),
        tooManyToCount: true,
        hasNext: true,
    }, overrideObject);
}
function aActionEvent(overrideObject) {
    if (overrideObject === void 0) { overrideObject = {}; }
    return (0, metro_common_builders_1.mergeDeep)({
        bodyAsJson: (0, metro_common_builders_1.someString)(),
    }, overrideObject);
}
function aDomainEvent(overrideObject) {
    if (overrideObject === void 0) { overrideObject = {}; }
    if (isCurrentBuilderWasPreviouslyCalled()) {
        return {};
    }
    return (0, metro_common_builders_1.mergeDeep)({
        createdEvent: aEntityCreatedEvent(),
        id: (0, metro_common_builders_1.someString)(),
        entityFqdn: (0, metro_common_builders_1.someString)(),
        slug: (0, metro_common_builders_1.someString)(),
        entityId: (0, metro_common_builders_1.someString)(),
        eventTime: (0, metro_common_builders_1.someDate)(),
        triggeredByAnonymizeRequest: true,
        originatedFrom: (0, metro_common_builders_1.someString)(),
        entityEventSequence: (0, metro_common_builders_1.someString)({
            validations: [{ type: 'DECIMAL_VALUE' }],
        }),
    }, overrideObject);
}
function aEntityCreatedEvent(overrideObject) {
    if (overrideObject === void 0) { overrideObject = {}; }
    if (isCurrentBuilderWasPreviouslyCalled()) {
        return {};
    }
    return (0, metro_common_builders_1.mergeDeep)({
        entityAsJson: (0, metro_common_builders_1.someString)(),
        triggeredByUndelete: true,
        restoreInfo: aRestoreInfo(),
        additionalMetadataAsJson: (0, metro_common_builders_1.someString)(),
    }, overrideObject);
}
function aEntityDeletedEvent(overrideObject) {
    if (overrideObject === void 0) { overrideObject = {}; }
    return (0, metro_common_builders_1.mergeDeep)({
        movedToTrash: true,
        deletedEntityAsJson: (0, metro_common_builders_1.someString)(),
        additionalMetadataAsJson: (0, metro_common_builders_1.someString)(),
    }, overrideObject);
}
function aEntityUpdatedEvent(overrideObject) {
    if (overrideObject === void 0) { overrideObject = {}; }
    return (0, metro_common_builders_1.mergeDeep)({
        currentEntityAsJson: (0, metro_common_builders_1.someString)(),
        previousEntityAsJson: (0, metro_common_builders_1.someString)(),
        modifiedFields: { modifiedFields: (0, metro_common_builders_1.someAny)() },
        additionalMetadataAsJson: (0, metro_common_builders_1.someString)(),
    }, overrideObject);
}
function aRestoreInfo(overrideObject) {
    if (overrideObject === void 0) { overrideObject = {}; }
    return (0, metro_common_builders_1.mergeDeep)({
        deletedDate: (0, metro_common_builders_1.someDate)(),
    }, overrideObject);
}
function isCurrentBuilderWasPreviouslyCalled() {
    var callChainFunctionNames = (0, callsite_1.default)().map(function (item) {
        return item.getFunctionName();
    });
    var callChainWithoutCurrentBuilder = callChainFunctionNames.splice(2);
    var currentBuilderName = callChainFunctionNames[1];
    return callChainWithoutCurrentBuilder.some(function (functionName) { return functionName === currentBuilderName; });
}
__exportStar(require("@wix/metro-common-builders"), exports);
//# sourceMappingURL=builders.impl.js.map