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 { Field, ObjectType, Resolver, Root, Subscription } from 'type-graphql';
export const CACHE_INVALIDATION_TOPIC = 'CACHE_INVALIDATION';
let CacheInvalidationNotification = class CacheInvalidationNotification {
};
__decorate([
    Field(() => String),
    __metadata("design:type", String)
], CacheInvalidationNotification.prototype, "EntityName", void 0);
__decorate([
    Field(() => String, { nullable: true }),
    __metadata("design:type", String)
], CacheInvalidationNotification.prototype, "PrimaryKeyValues", void 0);
__decorate([
    Field(() => String),
    __metadata("design:type", String)
], CacheInvalidationNotification.prototype, "Action", void 0);
__decorate([
    Field(() => String),
    __metadata("design:type", String)
], CacheInvalidationNotification.prototype, "SourceServerID", void 0);
__decorate([
    Field(() => Date),
    __metadata("design:type", Date)
], CacheInvalidationNotification.prototype, "Timestamp", void 0);
__decorate([
    Field(() => String, { nullable: true }),
    __metadata("design:type", String)
], CacheInvalidationNotification.prototype, "OriginSessionID", void 0);
__decorate([
    Field(() => String, { nullable: true }),
    __metadata("design:type", String)
], CacheInvalidationNotification.prototype, "RecordData", void 0);
CacheInvalidationNotification = __decorate([
    ObjectType()
], CacheInvalidationNotification);
export { CacheInvalidationNotification };
let CacheInvalidationResolver = class CacheInvalidationResolver {
    /**
     * Subscription that broadcasts cache invalidation events to ALL connected clients.
     * No session filter — every browser connected via WebSocket receives every event.
     * This enables cross-server cache invalidation to propagate to browser clients.
     */
    cacheInvalidation(payload) {
        return {
            EntityName: payload.entityName,
            PrimaryKeyValues: payload.primaryKeyValues ?? undefined,
            Action: payload.action,
            SourceServerID: payload.sourceServerId,
            Timestamp: payload.timestamp,
            OriginSessionID: payload.originSessionId ?? undefined,
            RecordData: payload.recordData ?? undefined,
        };
    }
};
__decorate([
    Subscription(() => CacheInvalidationNotification, {
        topics: CACHE_INVALIDATION_TOPIC,
    }),
    __param(0, Root()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object]),
    __metadata("design:returntype", CacheInvalidationNotification)
], CacheInvalidationResolver.prototype, "cacheInvalidation", null);
CacheInvalidationResolver = __decorate([
    Resolver()
], CacheInvalidationResolver);
export { CacheInvalidationResolver };
//# sourceMappingURL=CacheInvalidationResolver.js.map