"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.mapMemory = exports.MemoryResponseDto = exports.MemoryStatisticsResponseDto = exports.MemoryCreateDto = exports.MemoryUpdateDto = exports.MemorySearchDto = void 0;
const openapi = require("@nestjs/swagger");
const nestjs_zod_1 = require("nestjs-zod");
const decorators_1 = require("../decorators");
const asset_response_dto_1 = require("./asset-response.dto");
const enum_1 = require("../enum");
const validation_1 = require("../validation");
const zod_1 = __importDefault(require("zod"));
const MemorySearchSchema = zod_1.default
    .object({
    type: enum_1.MemoryTypeSchema.optional(),
    for: validation_1.isoDateToDate.optional().describe('Filter by date'),
    isTrashed: validation_1.stringToBool.optional().describe('Include trashed memories'),
    isSaved: validation_1.stringToBool.optional().describe('Filter by saved status'),
    size: zod_1.default.coerce.number().int().min(1).optional().describe('Number of memories to return'),
    order: enum_1.AssetOrderWithRandomSchema.optional(),
})
    .meta({ id: 'MemorySearchDto' });
const OnThisDaySchema = zod_1.default
    .object({
    year: zod_1.default.int().min(1000).max(9999).describe('Year for on this day memory'),
})
    .meta({ id: 'OnThisDayDto' });
const MemoryUpdateSchema = (0, validation_1.nonEmptyPartial)({
    isSaved: zod_1.default.boolean().describe('Is memory saved'),
    seenAt: validation_1.isoDatetimeToDate.describe('Date when memory was seen'),
    memoryAt: validation_1.isoDatetimeToDate.describe('Memory date'),
}).meta({ id: 'MemoryUpdateDto' });
const MemoryCreateSchema = zod_1.default
    .object({
    type: enum_1.MemoryTypeSchema,
    data: OnThisDaySchema,
    memoryAt: validation_1.isoDatetimeToDate.describe('Memory date'),
    assetIds: zod_1.default.array(zod_1.default.uuidv4()).optional().describe('Asset IDs to associate with memory'),
    isSaved: zod_1.default.boolean().optional().describe('Is memory saved'),
    seenAt: validation_1.isoDatetimeToDate.optional().describe('Date when memory was seen'),
    showAt: validation_1.isoDatetimeToDate
        .optional()
        .describe('Date when memory should be shown')
        .meta(new decorators_1.HistoryBuilder().added('v2.6.0').stable('v2.6.0').getExtensions()),
    hideAt: validation_1.isoDatetimeToDate
        .optional()
        .describe('Date when memory should be hidden')
        .meta(new decorators_1.HistoryBuilder().added('v2.6.0').stable('v2.6.0').getExtensions()),
})
    .meta({ id: 'MemoryCreateDto' });
const MemoryStatisticsResponseSchema = zod_1.default
    .object({
    total: zod_1.default.int().describe('Total number of memories'),
})
    .meta({ id: 'MemoryStatisticsResponseDto' });
const MemoryResponseSchema = zod_1.default
    .object({
    id: zod_1.default.uuidv4().describe('Memory ID'),
    createdAt: validation_1.isoDatetimeToDate.describe('Creation date'),
    updatedAt: validation_1.isoDatetimeToDate.describe('Last update date'),
    deletedAt: validation_1.isoDatetimeToDate.optional().describe('Deletion date'),
    memoryAt: validation_1.isoDatetimeToDate.describe('Memory date'),
    seenAt: validation_1.isoDatetimeToDate.optional().describe('Date when memory was seen'),
    showAt: validation_1.isoDatetimeToDate.optional().describe('Date when memory should be shown'),
    hideAt: validation_1.isoDatetimeToDate.optional().describe('Date when memory should be hidden'),
    ownerId: zod_1.default.uuidv4().describe('Owner user ID'),
    type: enum_1.MemoryTypeSchema,
    data: OnThisDaySchema,
    isSaved: zod_1.default.boolean().describe('Is memory saved'),
    assets: zod_1.default.array(asset_response_dto_1.AssetResponseSchema),
})
    .meta({ id: 'MemoryResponseDto' });
class MemorySearchDto extends (0, nestjs_zod_1.createZodDto)(MemorySearchSchema) {
    static _OPENAPI_METADATA_FACTORY() {
        return {};
    }
}
exports.MemorySearchDto = MemorySearchDto;
class MemoryUpdateDto extends (0, nestjs_zod_1.createZodDto)(MemoryUpdateSchema) {
    static _OPENAPI_METADATA_FACTORY() {
        return {};
    }
}
exports.MemoryUpdateDto = MemoryUpdateDto;
class MemoryCreateDto extends (0, nestjs_zod_1.createZodDto)(MemoryCreateSchema) {
    static _OPENAPI_METADATA_FACTORY() {
        return {};
    }
}
exports.MemoryCreateDto = MemoryCreateDto;
class MemoryStatisticsResponseDto extends (0, nestjs_zod_1.createZodDto)(MemoryStatisticsResponseSchema) {
    static _OPENAPI_METADATA_FACTORY() {
        return {};
    }
}
exports.MemoryStatisticsResponseDto = MemoryStatisticsResponseDto;
class MemoryResponseDto extends (0, nestjs_zod_1.createZodDto)(MemoryResponseSchema) {
    static _OPENAPI_METADATA_FACTORY() {
        return {};
    }
}
exports.MemoryResponseDto = MemoryResponseDto;
const mapMemory = (entity, auth) => {
    return {
        id: entity.id,
        createdAt: entity.createdAt,
        updatedAt: entity.updatedAt,
        deletedAt: entity.deletedAt ?? undefined,
        memoryAt: entity.memoryAt,
        seenAt: entity.seenAt ?? undefined,
        showAt: entity.showAt ?? undefined,
        hideAt: entity.hideAt ?? undefined,
        ownerId: entity.ownerId,
        type: entity.type,
        data: entity.data,
        isSaved: entity.isSaved,
        assets: ('assets' in entity ? entity.assets : []).map((asset) => (0, asset_response_dto_1.mapAsset)(asset, { auth })),
    };
};
exports.mapMemory = mapMemory;
//# sourceMappingURL=memory.dto.js.map