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);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
import { Arg, Ctx, Field, Float, InputType, Int, ObjectType, Query, Resolver } from 'type-graphql';
import { PotentialDuplicateRequest, PotentialDuplicateResponse, PotentialDuplicate, CompositeKey, PotentialDuplicateResult, } from '@memberjunction/core';
import { UserCache } from '@memberjunction/sqlserver-dataprovider';
import { LoadPineconeVectorDB } from '@memberjunction/ai-vectors-pinecone';
import { CompositeKeyInputType, CompositeKeyOutputType, KeyValuePairOutputType } from '../generic/KeyInputOutputTypes.js';
import { GetReadOnlyProvider } from '../util.js';
LoadPineconeVectorDB();
let PotentialDuplicateRequestType = class PotentialDuplicateRequestType extends PotentialDuplicateRequest {
};
__decorate([
    Field(() => String),
    __metadata("design:type", String)
], PotentialDuplicateRequestType.prototype, "EntityID", void 0);
__decorate([
    Field(() => [CompositeKeyInputType]),
    __metadata("design:type", Array)
], PotentialDuplicateRequestType.prototype, "RecordIDs", void 0);
__decorate([
    Field(() => String, { nullable: true }),
    __metadata("design:type", String)
], PotentialDuplicateRequestType.prototype, "EntityDocumentID", void 0);
__decorate([
    Field(() => Int, { nullable: true }),
    __metadata("design:type", Number)
], PotentialDuplicateRequestType.prototype, "ProbabilityScore", void 0);
__decorate([
    Field(() => String),
    __metadata("design:type", String)
], PotentialDuplicateRequestType.prototype, "ListID", void 0);
PotentialDuplicateRequestType = __decorate([
    InputType()
], PotentialDuplicateRequestType);
export { PotentialDuplicateRequestType };
let PotentialDuplicateType = class PotentialDuplicateType extends PotentialDuplicate {
};
__decorate([
    Field(() => Float),
    __metadata("design:type", Number)
], PotentialDuplicateType.prototype, "ProbabilityScore", void 0);
__decorate([
    Field(() => [KeyValuePairOutputType]),
    __metadata("design:type", Array)
], PotentialDuplicateType.prototype, "KeyValuePairs", void 0);
PotentialDuplicateType = __decorate([
    ObjectType()
], PotentialDuplicateType);
export { PotentialDuplicateType };
let PotentialDuplicateResultType = class PotentialDuplicateResultType extends PotentialDuplicateResult {
    RecordPrimaryKeys;
};
__decorate([
    Field(() => String, { nullable: true }),
    __metadata("design:type", String)
], PotentialDuplicateResultType.prototype, "EntityID", void 0);
__decorate([
    Field(() => [PotentialDuplicateType]),
    __metadata("design:type", Array)
], PotentialDuplicateResultType.prototype, "Duplicates", void 0);
__decorate([
    Field(() => CompositeKeyOutputType),
    __metadata("design:type", CompositeKey)
], PotentialDuplicateResultType.prototype, "RecordPrimaryKeys", void 0);
__decorate([
    Field(() => [String]),
    __metadata("design:type", Array)
], PotentialDuplicateResultType.prototype, "DuplicateRunDetailMatchRecordIDs", void 0);
PotentialDuplicateResultType = __decorate([
    ObjectType()
], PotentialDuplicateResultType);
export { PotentialDuplicateResultType };
let PotentialDuplicateResponseType = class PotentialDuplicateResponseType extends PotentialDuplicateResponse {
};
__decorate([
    Field(() => String),
    __metadata("design:type", String)
], PotentialDuplicateResponseType.prototype, "Status", void 0);
__decorate([
    Field(() => String, { nullable: true }),
    __metadata("design:type", String)
], PotentialDuplicateResponseType.prototype, "ErrorMessage", void 0);
__decorate([
    Field(() => [PotentialDuplicateResultType]),
    __metadata("design:type", Array)
], PotentialDuplicateResponseType.prototype, "PotentialDuplicateResult", void 0);
PotentialDuplicateResponseType = __decorate([
    ObjectType()
], PotentialDuplicateResponseType);
export { PotentialDuplicateResponseType };
let DuplicateRecordResolver = class DuplicateRecordResolver {
    async GetRecordDuplicates({ dataSource, userPayload, providers }, params) {
        const md = GetReadOnlyProvider(providers);
        const user = UserCache.Instance.Users.find((u) => u.Email.trim().toLowerCase() === userPayload.email.trim().toLowerCase());
        if (!user) {
            throw new Error(`User ${userPayload.email} not found in UserCache`);
        }
        const result = await md.GetRecordDuplicates(params, user);
        return result;
    }
};
__decorate([
    Query(() => PotentialDuplicateResponseType),
    __param(0, Ctx()),
    __param(1, Arg('params')),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, PotentialDuplicateRequestType]),
    __metadata("design:returntype", Promise)
], DuplicateRecordResolver.prototype, "GetRecordDuplicates", null);
DuplicateRecordResolver = __decorate([
    Resolver(PotentialDuplicateResponseType)
], DuplicateRecordResolver);
export { DuplicateRecordResolver };
//# sourceMappingURL=PotentialDuplicateRecordResolver.js.map