Initial commit - Event Planner application
This commit is contained in:
9
dist/gift/api/dto/create-contribution.dto.d.ts
vendored
Normal file
9
dist/gift/api/dto/create-contribution.dto.d.ts
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
export declare class CreateContributionDto {
|
||||
giftId: string;
|
||||
contributorName: string;
|
||||
contributorEmail?: string;
|
||||
amount: number;
|
||||
type?: 'individual' | 'group';
|
||||
metadata?: Record<string, any>;
|
||||
}
|
||||
//# sourceMappingURL=create-contribution.dto.d.ts.map
|
||||
1
dist/gift/api/dto/create-contribution.dto.d.ts.map
vendored
Normal file
1
dist/gift/api/dto/create-contribution.dto.d.ts.map
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"create-contribution.dto.d.ts","sourceRoot":"","sources":["../../../../src/gift/api/dto/create-contribution.dto.ts"],"names":[],"mappings":"AAAA,qBAAa,qBAAqB;IAChC,MAAM,EAAG,MAAM,CAAC;IAChB,eAAe,EAAG,MAAM,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,MAAM,EAAG,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAChC"}
|
||||
6
dist/gift/api/dto/create-contribution.dto.js
vendored
Normal file
6
dist/gift/api/dto/create-contribution.dto.js
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CreateContributionDto = void 0;
|
||||
class CreateContributionDto {
|
||||
}
|
||||
exports.CreateContributionDto = CreateContributionDto;
|
||||
10
dist/gift/api/dto/create-gift.dto.d.ts
vendored
Normal file
10
dist/gift/api/dto/create-gift.dto.d.ts
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
export declare class CreateGiftDto {
|
||||
name: string;
|
||||
description?: string;
|
||||
imageUrl?: string;
|
||||
price?: number;
|
||||
experience?: boolean;
|
||||
ownerId?: string;
|
||||
metadata?: Record<string, any>;
|
||||
}
|
||||
//# sourceMappingURL=create-gift.dto.d.ts.map
|
||||
1
dist/gift/api/dto/create-gift.dto.d.ts.map
vendored
Normal file
1
dist/gift/api/dto/create-gift.dto.d.ts.map
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"create-gift.dto.d.ts","sourceRoot":"","sources":["../../../../src/gift/api/dto/create-gift.dto.ts"],"names":[],"mappings":"AAAA,qBAAa,aAAa;IACxB,IAAI,EAAG,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAChC"}
|
||||
6
dist/gift/api/dto/create-gift.dto.js
vendored
Normal file
6
dist/gift/api/dto/create-gift.dto.js
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CreateGiftDto = void 0;
|
||||
class CreateGiftDto {
|
||||
}
|
||||
exports.CreateGiftDto = CreateGiftDto;
|
||||
14
dist/gift/api/gift.controller.d.ts
vendored
Normal file
14
dist/gift/api/gift.controller.d.ts
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
import { Request } from 'express';
|
||||
import { GiftService } from '../services/gift.service';
|
||||
import { CreateGiftDto } from './dto/create-gift.dto';
|
||||
import { CreateContributionDto } from './dto/create-contribution.dto';
|
||||
export declare class GiftController {
|
||||
private readonly giftService;
|
||||
constructor(giftService: GiftService);
|
||||
createGift(req: Request, tenantId: string, dto: CreateGiftDto): Promise<import("../entities/gift.entity").Gift>;
|
||||
listGifts(tenantId: string): Promise<import("../entities/gift.entity").Gift[]>;
|
||||
contribute(tenantId: string, dto: CreateContributionDto): Promise<import("../entities/gift.entity").GiftContribution>;
|
||||
getGift(req: Request, tenantId: string, id: string): Promise<import("../entities/gift.entity").Gift | null>;
|
||||
listContributions(req: Request, tenantId: string, id: string): Promise<import("../entities/gift.entity").GiftContribution[]>;
|
||||
}
|
||||
//# sourceMappingURL=gift.controller.d.ts.map
|
||||
1
dist/gift/api/gift.controller.d.ts.map
vendored
Normal file
1
dist/gift/api/gift.controller.d.ts.map
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"gift.controller.d.ts","sourceRoot":"","sources":["../../../src/gift/api/gift.controller.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAEtE,qBACa,cAAc;IACb,OAAO,CAAC,QAAQ,CAAC,WAAW;gBAAX,WAAW,EAAE,WAAW;IAG/C,UAAU,CACP,GAAG,EAAE,OAAO,EACK,QAAQ,EAAE,MAAM,EAChC,GAAG,EAAE,aAAa;IAOtB,SAAS,CAAyB,QAAQ,EAAE,MAAM;IAKlD,UAAU,CACU,QAAQ,EAAE,MAAM,EAChC,GAAG,EAAE,qBAAqB;IAM9B,OAAO,CACJ,GAAG,EAAE,OAAO,EACK,QAAQ,EAAE,MAAM,EAC3B,EAAE,EAAE,MAAM;IAOnB,iBAAiB,CACd,GAAG,EAAE,OAAO,EACK,QAAQ,EAAE,MAAM,EAC3B,EAAE,EAAE,MAAM;CAK1B"}
|
||||
89
dist/gift/api/gift.controller.js
vendored
Normal file
89
dist/gift/api/gift.controller.js
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
"use strict";
|
||||
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); }
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.GiftController = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const gift_service_1 = require("../services/gift.service");
|
||||
const create_gift_dto_1 = require("./dto/create-gift.dto");
|
||||
const create_contribution_dto_1 = require("./dto/create-contribution.dto");
|
||||
let GiftController = class GiftController {
|
||||
constructor(giftService) {
|
||||
this.giftService = giftService;
|
||||
}
|
||||
async createGift(req, tenantId, dto) {
|
||||
const ownerId = req.user?.id;
|
||||
return this.giftService.createGift(tenantId, { ...dto, ownerId });
|
||||
}
|
||||
async listGifts(tenantId) {
|
||||
return this.giftService.listGifts(tenantId);
|
||||
}
|
||||
async contribute(tenantId, dto) {
|
||||
return this.giftService.createContribution(tenantId, dto);
|
||||
}
|
||||
async getGift(req, tenantId, id) {
|
||||
const requesterId = req.user?.id;
|
||||
return this.giftService.getGiftById(tenantId, id, requesterId);
|
||||
}
|
||||
async listContributions(req, tenantId, id) {
|
||||
const requesterId = req.user?.id;
|
||||
return this.giftService.listContributions(tenantId, id, requesterId);
|
||||
}
|
||||
};
|
||||
exports.GiftController = GiftController;
|
||||
__decorate([
|
||||
(0, common_1.Post)(),
|
||||
__param(0, (0, common_1.Req)()),
|
||||
__param(1, (0, common_1.Headers)('x-tenant-id')),
|
||||
__param(2, (0, common_1.Body)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object, String, create_gift_dto_1.CreateGiftDto]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], GiftController.prototype, "createGift", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)(),
|
||||
__param(0, (0, common_1.Headers)('x-tenant-id')),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], GiftController.prototype, "listGifts", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)('contribution'),
|
||||
__param(0, (0, common_1.Headers)('x-tenant-id')),
|
||||
__param(1, (0, common_1.Body)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String, create_contribution_dto_1.CreateContributionDto]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], GiftController.prototype, "contribute", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)(':id'),
|
||||
__param(0, (0, common_1.Req)()),
|
||||
__param(1, (0, common_1.Headers)('x-tenant-id')),
|
||||
__param(2, (0, common_1.Param)('id')),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object, String, String]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], GiftController.prototype, "getGift", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)(':id/contributions'),
|
||||
__param(0, (0, common_1.Req)()),
|
||||
__param(1, (0, common_1.Headers)('x-tenant-id')),
|
||||
__param(2, (0, common_1.Param)('id')),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object, String, String]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], GiftController.prototype, "listContributions", null);
|
||||
exports.GiftController = GiftController = __decorate([
|
||||
(0, common_1.Controller)('gift'),
|
||||
__metadata("design:paramtypes", [gift_service_1.GiftService])
|
||||
], GiftController);
|
||||
22
dist/gift/entities/gift.entity.d.ts
vendored
Normal file
22
dist/gift/entities/gift.entity.d.ts
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
import { EntitySchema } from '@mikro-orm/core';
|
||||
import { BaseEntity } from '../../core/entities/base.entity';
|
||||
export declare class Gift extends BaseEntity {
|
||||
name: string;
|
||||
description?: string;
|
||||
imageUrl?: string;
|
||||
price?: number;
|
||||
experience?: boolean;
|
||||
status: string;
|
||||
ownerId?: string;
|
||||
}
|
||||
export declare const GiftSchema: EntitySchema<Gift, never, import("@mikro-orm/core").EntityCtor<Gift>>;
|
||||
export declare class GiftContribution extends BaseEntity {
|
||||
giftId: string;
|
||||
contributorName: string;
|
||||
contributorEmail?: string;
|
||||
amount: number;
|
||||
type: string;
|
||||
status: string;
|
||||
}
|
||||
export declare const GiftContributionSchema: EntitySchema<GiftContribution, never, import("@mikro-orm/core").EntityCtor<GiftContribution>>;
|
||||
//# sourceMappingURL=gift.entity.d.ts.map
|
||||
1
dist/gift/entities/gift.entity.d.ts.map
vendored
Normal file
1
dist/gift/entities/gift.entity.d.ts.map
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"gift.entity.d.ts","sourceRoot":"","sources":["../../../src/gift/entities/gift.entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAE7D,qBAAa,IAAK,SAAQ,UAAU;IAClC,IAAI,EAAG,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,MAAM,EAAE,MAAM,CAAa;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,UAAU,uEAoDrB,CAAC;AAEH,qBAAa,gBAAiB,SAAQ,UAAU;IAC9C,MAAM,EAAG,MAAM,CAAC;IAChB,eAAe,EAAG,MAAM,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,MAAM,EAAG,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAgB;IAC5B,MAAM,EAAE,MAAM,CAAa;CAC5B;AAED,eAAO,MAAM,sBAAsB,+FA8CjC,CAAC"}
|
||||
121
dist/gift/entities/gift.entity.js
vendored
Normal file
121
dist/gift/entities/gift.entity.js
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.GiftContributionSchema = exports.GiftContribution = exports.GiftSchema = exports.Gift = void 0;
|
||||
const core_1 = require("@mikro-orm/core");
|
||||
const uuid_1 = require("uuid");
|
||||
const base_entity_1 = require("../../core/entities/base.entity");
|
||||
class Gift extends base_entity_1.BaseEntity {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.status = 'pending';
|
||||
}
|
||||
}
|
||||
exports.Gift = Gift;
|
||||
exports.GiftSchema = new core_1.EntitySchema({
|
||||
class: Gift,
|
||||
tableName: 'gifts',
|
||||
properties: {
|
||||
id: {
|
||||
type: 'uuid',
|
||||
primary: true,
|
||||
default: (0, uuid_1.v4)(),
|
||||
},
|
||||
tenantId: {
|
||||
type: 'string',
|
||||
},
|
||||
metadata: {
|
||||
type: 'json',
|
||||
nullable: true,
|
||||
},
|
||||
createdAt: {
|
||||
type: 'date',
|
||||
default: new Date(),
|
||||
},
|
||||
updatedAt: {
|
||||
type: 'date',
|
||||
default: new Date(),
|
||||
},
|
||||
name: {
|
||||
type: 'string',
|
||||
},
|
||||
description: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
imageUrl: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
price: {
|
||||
type: 'float',
|
||||
nullable: true,
|
||||
},
|
||||
experience: {
|
||||
type: 'boolean',
|
||||
nullable: true,
|
||||
},
|
||||
status: {
|
||||
type: 'string',
|
||||
default: 'pending',
|
||||
},
|
||||
ownerId: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
class GiftContribution extends base_entity_1.BaseEntity {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.type = 'individual';
|
||||
this.status = 'pending';
|
||||
}
|
||||
}
|
||||
exports.GiftContribution = GiftContribution;
|
||||
exports.GiftContributionSchema = new core_1.EntitySchema({
|
||||
class: GiftContribution,
|
||||
tableName: 'gift_contributions',
|
||||
properties: {
|
||||
id: {
|
||||
type: 'uuid',
|
||||
primary: true,
|
||||
default: (0, uuid_1.v4)(),
|
||||
},
|
||||
tenantId: {
|
||||
type: 'string',
|
||||
},
|
||||
metadata: {
|
||||
type: 'json',
|
||||
nullable: true,
|
||||
},
|
||||
createdAt: {
|
||||
type: 'date',
|
||||
default: new Date(),
|
||||
},
|
||||
updatedAt: {
|
||||
type: 'date',
|
||||
default: new Date(),
|
||||
},
|
||||
giftId: {
|
||||
type: 'uuid',
|
||||
},
|
||||
contributorName: {
|
||||
type: 'string',
|
||||
},
|
||||
contributorEmail: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
},
|
||||
amount: {
|
||||
type: 'float',
|
||||
},
|
||||
type: {
|
||||
type: 'string',
|
||||
default: 'individual',
|
||||
},
|
||||
status: {
|
||||
type: 'string',
|
||||
default: 'pending',
|
||||
},
|
||||
},
|
||||
});
|
||||
3
dist/gift/gift.module.d.ts
vendored
Normal file
3
dist/gift/gift.module.d.ts
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export declare class GiftModule {
|
||||
}
|
||||
//# sourceMappingURL=gift.module.d.ts.map
|
||||
1
dist/gift/gift.module.d.ts.map
vendored
Normal file
1
dist/gift/gift.module.d.ts.map
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"gift.module.d.ts","sourceRoot":"","sources":["../../src/gift/gift.module.ts"],"names":[],"mappings":"AASA,qBASa,UAAU;CAAG"}
|
||||
31
dist/gift/gift.module.js
vendored
Normal file
31
dist/gift/gift.module.js
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
"use strict";
|
||||
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;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.GiftModule = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const nestjs_1 = require("@mikro-orm/nestjs");
|
||||
const core_module_1 = require("../core/core.module");
|
||||
const gift_service_1 = require("./services/gift.service");
|
||||
const gift_controller_1 = require("./api/gift.controller");
|
||||
const gift_subscriber_1 = require("./subscribers/gift.subscriber");
|
||||
const gift_entity_1 = require("./entities/gift.entity");
|
||||
const gift_registration_1 = require("./gift.registration");
|
||||
let GiftModule = class GiftModule {
|
||||
};
|
||||
exports.GiftModule = GiftModule;
|
||||
exports.GiftModule = GiftModule = __decorate([
|
||||
(0, common_1.Module)({
|
||||
imports: [
|
||||
core_module_1.CoreModule,
|
||||
nestjs_1.MikroOrmModule.forFeature({ entities: [gift_entity_1.GiftSchema, gift_entity_1.GiftContributionSchema] }),
|
||||
],
|
||||
providers: [gift_service_1.GiftService, gift_subscriber_1.GiftSubscriber, gift_registration_1.GiftModuleRegistration],
|
||||
controllers: [gift_controller_1.GiftController],
|
||||
exports: [gift_service_1.GiftService],
|
||||
})
|
||||
], GiftModule);
|
||||
8
dist/gift/gift.registration.d.ts
vendored
Normal file
8
dist/gift/gift.registration.d.ts
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import { OnModuleInit } from '@nestjs/common';
|
||||
import { ModuleRegistryService } from '../core/services/module-registry.service';
|
||||
export declare class GiftModuleRegistration implements OnModuleInit {
|
||||
private readonly moduleRegistry;
|
||||
constructor(moduleRegistry: ModuleRegistryService);
|
||||
onModuleInit(): void;
|
||||
}
|
||||
//# sourceMappingURL=gift.registration.d.ts.map
|
||||
1
dist/gift/gift.registration.d.ts.map
vendored
Normal file
1
dist/gift/gift.registration.d.ts.map
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"gift.registration.d.ts","sourceRoot":"","sources":["../../src/gift/gift.registration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AAEjF,qBACa,sBAAuB,YAAW,YAAY;IAC7C,OAAO,CAAC,QAAQ,CAAC,cAAc;gBAAd,cAAc,EAAE,qBAAqB;IAElE,YAAY;CAQb"}
|
||||
32
dist/gift/gift.registration.js
vendored
Normal file
32
dist/gift/gift.registration.js
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
"use strict";
|
||||
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);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.GiftModuleRegistration = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const module_registry_service_1 = require("../core/services/module-registry.service");
|
||||
let GiftModuleRegistration = class GiftModuleRegistration {
|
||||
constructor(moduleRegistry) {
|
||||
this.moduleRegistry = moduleRegistry;
|
||||
}
|
||||
onModuleInit() {
|
||||
this.moduleRegistry.registerModule({
|
||||
key: 'gift',
|
||||
name: 'Regalos',
|
||||
description: 'Gestión de lista de regalos, aportes individuales y grupales.',
|
||||
routePrefix: '/gift',
|
||||
});
|
||||
}
|
||||
};
|
||||
exports.GiftModuleRegistration = GiftModuleRegistration;
|
||||
exports.GiftModuleRegistration = GiftModuleRegistration = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__metadata("design:paramtypes", [module_registry_service_1.ModuleRegistryService])
|
||||
], GiftModuleRegistration);
|
||||
17
dist/gift/services/gift.service.d.ts
vendored
Normal file
17
dist/gift/services/gift.service.d.ts
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
import { MikroORM } from '@mikro-orm/core';
|
||||
import { EventEmitter2 } from '@nestjs/event-emitter';
|
||||
import { Gift, GiftContribution } from '../entities/gift.entity';
|
||||
import { CreateGiftDto } from '../api/dto/create-gift.dto';
|
||||
import { CreateContributionDto } from '../api/dto/create-contribution.dto';
|
||||
export declare class GiftService {
|
||||
private readonly orm;
|
||||
private readonly eventEmitter;
|
||||
constructor(orm: MikroORM, eventEmitter: EventEmitter2);
|
||||
private get em();
|
||||
createGift(tenantId: string, dto: CreateGiftDto): Promise<Gift>;
|
||||
createContribution(tenantId: string, dto: CreateContributionDto): Promise<GiftContribution>;
|
||||
listGifts(tenantId: string): Promise<Gift[]>;
|
||||
getGiftById(tenantId: string, id: string, requesterId?: string): Promise<Gift | null>;
|
||||
listContributions(tenantId: string, giftId: string, requesterId?: string): Promise<GiftContribution[]>;
|
||||
}
|
||||
//# sourceMappingURL=gift.service.d.ts.map
|
||||
1
dist/gift/services/gift.service.d.ts.map
vendored
Normal file
1
dist/gift/services/gift.service.d.ts.map
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"gift.service.d.ts","sourceRoot":"","sources":["../../../src/gift/services/gift.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAE3E,qBACa,WAAW;IAEpB,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,YAAY;gBADZ,GAAG,EAAE,QAAQ,EACb,YAAY,EAAE,aAAa;IAG9C,OAAO,KAAK,EAAE,GAEb;IAEK,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAW/D,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,qBAAqB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAW3F,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAI5C,WAAW,CACf,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,MAAM,EACV,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;IASjB,iBAAiB,CACrB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,gBAAgB,EAAE,CAAC;CAK/B"}
|
||||
69
dist/gift/services/gift.service.js
vendored
Normal file
69
dist/gift/services/gift.service.js
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
"use strict";
|
||||
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);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.GiftService = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const core_1 = require("@mikro-orm/core");
|
||||
const event_emitter_1 = require("@nestjs/event-emitter");
|
||||
const gift_entity_1 = require("../entities/gift.entity");
|
||||
let GiftService = class GiftService {
|
||||
constructor(orm, eventEmitter) {
|
||||
this.orm = orm;
|
||||
this.eventEmitter = eventEmitter;
|
||||
}
|
||||
get em() {
|
||||
return this.orm.em.fork();
|
||||
}
|
||||
async createGift(tenantId, dto) {
|
||||
const gift = this.em.create(gift_entity_1.Gift, {
|
||||
tenantId,
|
||||
...dto,
|
||||
});
|
||||
this.em.persist(gift);
|
||||
await this.em.flush();
|
||||
this.eventEmitter.emit('gift.created', { gift });
|
||||
return gift;
|
||||
}
|
||||
async createContribution(tenantId, dto) {
|
||||
const contribution = this.em.create(gift_entity_1.GiftContribution, {
|
||||
tenantId,
|
||||
...dto,
|
||||
});
|
||||
this.em.persist(contribution);
|
||||
await this.em.flush();
|
||||
this.eventEmitter.emit('gift.contribution', { contribution });
|
||||
return contribution;
|
||||
}
|
||||
async listGifts(tenantId) {
|
||||
return this.em.find(gift_entity_1.Gift, { tenantId });
|
||||
}
|
||||
async getGiftById(tenantId, id, requesterId) {
|
||||
const gift = await this.em.findOne(gift_entity_1.Gift, { tenantId, id });
|
||||
if (!gift)
|
||||
return null;
|
||||
if (requesterId && gift.ownerId && gift.ownerId !== requesterId) {
|
||||
return null;
|
||||
}
|
||||
return gift;
|
||||
}
|
||||
async listContributions(tenantId, giftId, requesterId) {
|
||||
const gift = await this.getGiftById(tenantId, giftId, requesterId);
|
||||
if (!gift)
|
||||
return [];
|
||||
return this.em.find(gift_entity_1.GiftContribution, { tenantId, giftId });
|
||||
}
|
||||
};
|
||||
exports.GiftService = GiftService;
|
||||
exports.GiftService = GiftService = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__metadata("design:paramtypes", [core_1.MikroORM,
|
||||
event_emitter_1.EventEmitter2])
|
||||
], GiftService);
|
||||
10
dist/gift/subscribers/gift.subscriber.d.ts
vendored
Normal file
10
dist/gift/subscribers/gift.subscriber.d.ts
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import { NotificationService } from '../../core/services/notification.service';
|
||||
import { NotificationRuleService } from '../../core/services/notification-rule.service';
|
||||
export declare class GiftSubscriber {
|
||||
private readonly notificationService;
|
||||
private readonly notificationRuleService;
|
||||
constructor(notificationService: NotificationService, notificationRuleService: NotificationRuleService);
|
||||
handleGiftCreated(payload: any): Promise<void>;
|
||||
handleGiftContribution(payload: any): Promise<void>;
|
||||
}
|
||||
//# sourceMappingURL=gift.subscriber.d.ts.map
|
||||
1
dist/gift/subscribers/gift.subscriber.d.ts.map
vendored
Normal file
1
dist/gift/subscribers/gift.subscriber.d.ts.map
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"gift.subscriber.d.ts","sourceRoot":"","sources":["../../../src/gift/subscribers/gift.subscriber.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAC/E,OAAO,EAAE,uBAAuB,EAAE,MAAM,+CAA+C,CAAC;AAExF,qBACa,cAAc;IAEvB,OAAO,CAAC,QAAQ,CAAC,mBAAmB;IACpC,OAAO,CAAC,QAAQ,CAAC,uBAAuB;gBADvB,mBAAmB,EAAE,mBAAmB,EACxC,uBAAuB,EAAE,uBAAuB;IAI7D,iBAAiB,CAAC,OAAO,EAAE,GAAG;IAgB9B,sBAAsB,CAAC,OAAO,EAAE,GAAG;CAc1C"}
|
||||
58
dist/gift/subscribers/gift.subscriber.js
vendored
Normal file
58
dist/gift/subscribers/gift.subscriber.js
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
"use strict";
|
||||
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);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.GiftSubscriber = void 0;
|
||||
const event_emitter_1 = require("@nestjs/event-emitter");
|
||||
const common_1 = require("@nestjs/common");
|
||||
const notification_service_1 = require("../../core/services/notification.service");
|
||||
const notification_rule_service_1 = require("../../core/services/notification-rule.service");
|
||||
let GiftSubscriber = class GiftSubscriber {
|
||||
constructor(notificationService, notificationRuleService) {
|
||||
this.notificationService = notificationService;
|
||||
this.notificationRuleService = notificationRuleService;
|
||||
}
|
||||
async handleGiftCreated(payload) {
|
||||
const { gift } = payload;
|
||||
const rules = await this.notificationRuleService.getRulesForEvent(gift.tenantId, 'gift', 'gift.created');
|
||||
for (const rule of rules) {
|
||||
for (const channel of rule.channels) {
|
||||
await this.notificationService.send(channel, gift.metadata?.notifyTo || '', 'Nuevo regalo creado', `Se ha creado el regalo: ${gift.name}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
async handleGiftContribution(payload) {
|
||||
const { contribution } = payload;
|
||||
const rules = await this.notificationRuleService.getRulesForEvent(contribution.tenantId, 'gift', 'gift.contribution');
|
||||
for (const rule of rules) {
|
||||
for (const channel of rule.channels) {
|
||||
await this.notificationService.send(channel, contribution.metadata?.notifyTo || '', 'Nuevo aporte a regalo', `Se ha registrado un aporte de ${contribution.amount} al regalo (${contribution.giftId}).`);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
exports.GiftSubscriber = GiftSubscriber;
|
||||
__decorate([
|
||||
(0, event_emitter_1.OnEvent)('gift.created'),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], GiftSubscriber.prototype, "handleGiftCreated", null);
|
||||
__decorate([
|
||||
(0, event_emitter_1.OnEvent)('gift.contribution'),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], GiftSubscriber.prototype, "handleGiftContribution", null);
|
||||
exports.GiftSubscriber = GiftSubscriber = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__metadata("design:paramtypes", [notification_service_1.NotificationService,
|
||||
notification_rule_service_1.NotificationRuleService])
|
||||
], GiftSubscriber);
|
||||
5
dist/gift/workflows/gift.workflow.d.ts
vendored
Normal file
5
dist/gift/workflows/gift.workflow.d.ts
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import { BaseWorkflow } from '../../core/workflows/base-workflow';
|
||||
export declare class GiftWorkflow extends BaseWorkflow {
|
||||
execute(...args: any[]): Promise<any>;
|
||||
}
|
||||
//# sourceMappingURL=gift.workflow.d.ts.map
|
||||
1
dist/gift/workflows/gift.workflow.d.ts.map
vendored
Normal file
1
dist/gift/workflows/gift.workflow.d.ts.map
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"gift.workflow.d.ts","sourceRoot":"","sources":["../../../src/gift/workflows/gift.workflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAElE,qBAAa,YAAa,SAAQ,YAAY;IACtC,OAAO,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;CAM5C"}
|
||||
13
dist/gift/workflows/gift.workflow.js
vendored
Normal file
13
dist/gift/workflows/gift.workflow.js
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.GiftWorkflow = void 0;
|
||||
const base_workflow_1 = require("../../core/workflows/base-workflow");
|
||||
class GiftWorkflow extends base_workflow_1.BaseWorkflow {
|
||||
async execute(...args) {
|
||||
this.logExecution('Ejecutando workflow de regalo', args);
|
||||
// Lógica de workflow para regalos
|
||||
// ...existing code...
|
||||
return {};
|
||||
}
|
||||
}
|
||||
exports.GiftWorkflow = GiftWorkflow;
|
||||
Reference in New Issue
Block a user