import { mergeDeep, someNumber, someString, someAny, someDate, } from '@wix/metro-common-builders';
import { CauseOfFailure, CollectionsFound, ConnectionType, FieldType, ProtocolVersion, WebhookIdentityType, } from './types.impl.js';
// @ts-ignore
import stack from 'callsite';
export function aConnectionType(enumFirstItem) {
    if (enumFirstItem === void 0) { enumFirstItem = ConnectionType.UNKNOWN_CONNECTION_TYPE; }
    return enumFirstItem;
}
export function aCreateExternalDatabaseConnectionRequest(overrideObject) {
    if (overrideObject === void 0) { overrideObject = {}; }
    if (isCurrentBuilderWasPreviouslyCalled()) {
        return {};
    }
    return mergeDeep({
        externalDatabaseConnection: aExternalDatabaseConnection(),
        connectionType: aConnectionType(),
        databaseManagedByWix: true,
    }, overrideObject);
}
export function aCreateExternalDatabaseConnectionResponse(overrideObject) {
    if (overrideObject === void 0) { overrideObject = {}; }
    if (isCurrentBuilderWasPreviouslyCalled()) {
        return {};
    }
    return mergeDeep({
        externalDatabaseConnection: aExternalDatabaseConnection(),
    }, overrideObject);
}
export function aDeleteExternalDatabaseConnectionRequest(overrideObject) {
    if (overrideObject === void 0) { overrideObject = {}; }
    return mergeDeep({
        name: someString({
            validations: [{ type: 'MAX_LENGTH', value: '255' }],
        }),
    }, overrideObject);
}
export function aDeleteExternalDatabaseConnectionResponse(overrideObject) {
    if (overrideObject === void 0) { overrideObject = {}; }
    return mergeDeep({}, overrideObject);
}
export function aExternalDatabaseConnection(overrideObject) {
    if (overrideObject === void 0) { overrideObject = {}; }
    if (isCurrentBuilderWasPreviouslyCalled()) {
        return {};
    }
    return mergeDeep({
        name: someString({
            validations: [
                { type: 'IMMUTABLE', value: 'true' },
                { type: 'MIN_LENGTH', value: '1' },
                { type: 'MAX_LENGTH', value: '255' },
            ],
        }),
        endpoint: someString({
            validations: [{ type: 'FORMAT', value: 'WEB_URL' }],
        }),
        configuration: {},
        connectionStatus: aConnectionStatus(),
        protocolVersion: aProtocolVersion(),
        publicKey: someString({
            validations: [
                { type: 'READ_ONLY', value: 'true' },
                { type: 'MAX_LENGTH', value: '128' },
            ],
        }),
        capabilities: aCapabilities(),
        applicationId: someString({
            validations: [
                { type: 'READ_ONLY', value: 'true' },
                { type: 'MAX_LENGTH', value: '128' },
            ],
        }),
    }, overrideObject);
}
export function aCapabilities(overrideObject) {
    if (overrideObject === void 0) { overrideObject = {}; }
    if (isCurrentBuilderWasPreviouslyCalled()) {
        return {};
    }
    return mergeDeep({
        collectionModificationsSupported: true,
        fieldTypes: [
            aFieldType(),
            aFieldType(),
            aFieldType(),
            aFieldType(),
            aFieldType(),
            aFieldType(),
            aFieldType(),
            aFieldType(),
            aFieldType(),
            aFieldType(),
        ],
    }, overrideObject);
}
export function aConnectionStatus(overrideObject) {
    if (overrideObject === void 0) { overrideObject = {}; }
    if (isCurrentBuilderWasPreviouslyCalled()) {
        return {};
    }
    return mergeDeep({
        successful: true,
        causeOfFailure: aCauseOfFailure(),
        hasCollections: aCollectionsFound(),
    }, overrideObject);
}
export function aCauseOfFailure(enumFirstItem) {
    if (enumFirstItem === void 0) { enumFirstItem = CauseOfFailure.NONE; }
    return enumFirstItem;
}
export function aCollectionsFound(enumFirstItem) {
    if (enumFirstItem === void 0) { enumFirstItem = CollectionsFound.UNKNOWN; }
    return enumFirstItem;
}
export function aProtocolVersion(enumFirstItem) {
    if (enumFirstItem === void 0) { enumFirstItem = ProtocolVersion.UNKNOWN_PROTOCOL_VERSION; }
    return enumFirstItem;
}
export function aGetExternalDatabaseConnectionRequest(overrideObject) {
    if (overrideObject === void 0) { overrideObject = {}; }
    return mergeDeep({
        name: someString({
            validations: [{ type: 'MAX_LENGTH', value: '255' }],
        }),
    }, overrideObject);
}
export function aGetExternalDatabaseConnectionResponse(overrideObject) {
    if (overrideObject === void 0) { overrideObject = {}; }
    if (isCurrentBuilderWasPreviouslyCalled()) {
        return {};
    }
    return mergeDeep({
        externalDatabaseConnection: aExternalDatabaseConnection(),
    }, overrideObject);
}
export function aListExternalDatabaseConnectionsRequest(overrideObject) {
    if (overrideObject === void 0) { overrideObject = {}; }
    if (isCurrentBuilderWasPreviouslyCalled()) {
        return {};
    }
    return mergeDeep({
        paging: aPaging(),
    }, overrideObject);
}
export function aListExternalDatabaseConnectionsResponse(overrideObject) {
    if (overrideObject === void 0) { overrideObject = {}; }
    if (isCurrentBuilderWasPreviouslyCalled()) {
        return {};
    }
    return mergeDeep({
        externalDatabaseConnections: [aExternalDatabaseConnection()],
        pagingMetadata: aPagingMetadata(),
    }, overrideObject);
}
export function aUpdateExternalDatabaseConnectionRequest(overrideObject) {
    if (overrideObject === void 0) { overrideObject = {}; }
    if (isCurrentBuilderWasPreviouslyCalled()) {
        return {};
    }
    return mergeDeep({
        externalDatabaseConnection: aExternalDatabaseConnection(),
    }, overrideObject);
}
export function aUpdateExternalDatabaseConnectionResponse(overrideObject) {
    if (overrideObject === void 0) { overrideObject = {}; }
    if (isCurrentBuilderWasPreviouslyCalled()) {
        return {};
    }
    return mergeDeep({
        externalDatabaseConnection: aExternalDatabaseConnection(),
    }, overrideObject);
}
export function aFieldType(enumFirstItem) {
    if (enumFirstItem === void 0) { enumFirstItem = FieldType.UNKNOWN_FIELD_TYPE; }
    return enumFirstItem;
}
export function aAccountInfo(overrideObject) {
    if (overrideObject === void 0) { overrideObject = {}; }
    return mergeDeep({
        accountId: someString({
            validations: [{ type: 'FORMAT', value: 'GUID' }],
        }),
        parentAccountId: someString({
            validations: [{ type: 'FORMAT', value: 'GUID' }],
        }),
        siteId: someString({
            validations: [{ type: 'FORMAT', value: 'GUID' }],
        }),
    }, overrideObject);
}
export function aIdentificationData(overrideObject) {
    if (overrideObject === void 0) { overrideObject = {}; }
    if (isCurrentBuilderWasPreviouslyCalled()) {
        return {};
    }
    return mergeDeep({
        anonymousVisitorId: someString({
            validations: [{ type: 'FORMAT', value: 'GUID' }],
        }),
        identityType: aWebhookIdentityType(),
    }, overrideObject);
}
export function aWebhookIdentityType(enumFirstItem) {
    if (enumFirstItem === void 0) { enumFirstItem = WebhookIdentityType.UNKNOWN; }
    return enumFirstItem;
}
export function aMessageEnvelope(overrideObject) {
    if (overrideObject === void 0) { overrideObject = {}; }
    if (isCurrentBuilderWasPreviouslyCalled()) {
        return {};
    }
    return mergeDeep({
        instanceId: someString({
            validations: [{ type: 'FORMAT', value: 'GUID' }],
        }),
        eventType: someString({
            validations: [{ type: 'MAX_LENGTH', value: '150' }],
        }),
        identity: aIdentificationData(),
        data: someString(),
        accountInfo: aAccountInfo(),
    }, overrideObject);
}
export function aPaging(overrideObject) {
    if (overrideObject === void 0) { overrideObject = {}; }
    return mergeDeep({
        limit: someNumber({
            validations: [{ type: 'MIN' }],
        }),
        offset: someNumber({
            validations: [{ type: 'MIN' }],
        }),
    }, overrideObject);
}
export function aPagingMetadata(overrideObject) {
    if (overrideObject === void 0) { overrideObject = {}; }
    return mergeDeep({
        count: someNumber(),
        offset: someNumber(),
        total: someNumber(),
        tooManyToCount: true,
        hasNext: true,
    }, overrideObject);
}
export function aActionEvent(overrideObject) {
    if (overrideObject === void 0) { overrideObject = {}; }
    return mergeDeep({
        bodyAsJson: someString(),
    }, overrideObject);
}
export function aDomainEvent(overrideObject) {
    if (overrideObject === void 0) { overrideObject = {}; }
    if (isCurrentBuilderWasPreviouslyCalled()) {
        return {};
    }
    return mergeDeep({
        createdEvent: aEntityCreatedEvent(),
        id: someString(),
        entityFqdn: someString(),
        slug: someString(),
        entityId: someString(),
        eventTime: someDate(),
        triggeredByAnonymizeRequest: true,
        originatedFrom: someString(),
        entityEventSequence: someString({
            validations: [{ type: 'DECIMAL_VALUE' }],
        }),
    }, overrideObject);
}
export function aEntityCreatedEvent(overrideObject) {
    if (overrideObject === void 0) { overrideObject = {}; }
    if (isCurrentBuilderWasPreviouslyCalled()) {
        return {};
    }
    return mergeDeep({
        entityAsJson: someString(),
        triggeredByUndelete: true,
        restoreInfo: aRestoreInfo(),
        additionalMetadataAsJson: someString(),
    }, overrideObject);
}
export function aEntityDeletedEvent(overrideObject) {
    if (overrideObject === void 0) { overrideObject = {}; }
    return mergeDeep({
        movedToTrash: true,
        deletedEntityAsJson: someString(),
        additionalMetadataAsJson: someString(),
    }, overrideObject);
}
export function aEntityUpdatedEvent(overrideObject) {
    if (overrideObject === void 0) { overrideObject = {}; }
    return mergeDeep({
        currentEntityAsJson: someString(),
        previousEntityAsJson: someString(),
        modifiedFields: { modifiedFields: someAny() },
        additionalMetadataAsJson: someString(),
    }, overrideObject);
}
export function aRestoreInfo(overrideObject) {
    if (overrideObject === void 0) { overrideObject = {}; }
    return mergeDeep({
        deletedDate: someDate(),
    }, overrideObject);
}
function isCurrentBuilderWasPreviouslyCalled() {
    var callChainFunctionNames = stack().map(function (item) {
        return item.getFunctionName();
    });
    var callChainWithoutCurrentBuilder = callChainFunctionNames.splice(2);
    var currentBuilderName = callChainFunctionNames[1];
    return callChainWithoutCurrentBuilder.some(function (functionName) { return functionName === currentBuilderName; });
}
export * from '@wix/metro-common-builders';
//# sourceMappingURL=builders.impl.js.map