@comasoft/nestjs 0.1.60 → 0.1.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/database/entities/notification.entity.d.ts +3 -0
- package/dist/database/entities/notification.entity.js +1 -1
- package/dist/events/services/event-storage.service.js +1 -1
- package/dist/events/types/audit-events.type.d.ts +1 -0
- package/dist/interceptors/success.interceptor.js +1 -1
- package/package.json +1 -1
|
@@ -6,11 +6,14 @@ declare class Relations {
|
|
|
6
6
|
export declare class Notification extends Relations {
|
|
7
7
|
id: number;
|
|
8
8
|
type: string;
|
|
9
|
+
batch_id: string;
|
|
9
10
|
template_key: string;
|
|
10
11
|
status: NOTIFICATION_STATUS;
|
|
11
12
|
sender: string;
|
|
12
13
|
title: string;
|
|
13
14
|
content: string;
|
|
15
|
+
scheduled_at: Date;
|
|
16
|
+
sent_at: Date;
|
|
14
17
|
created_at: Date;
|
|
15
18
|
updated_at: Date;
|
|
16
19
|
deleted_at: Date;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var t=this&&this.__decorate||function(t,e,o,i){var n,
|
|
1
|
+
var t=this&&this.__decorate||function(t,e,o,i){var n,a=arguments.length,r=a<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,o,i);else for(var p=t.length-1;p>=0;p--)(n=t[p])&&(r=(a<3?n(r):a>3?n(e,o,r):n(e,o))||r);return a>3&&r&&Object.defineProperty(e,o,r),r},e=this&&this.__metadata||function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)};Object.defineProperty(exports,"__esModule",{value:!0}),exports.Notification=void 0;const o=require("typeorm"),i=require("../../enums.common"),n=require("./notification-recipient.entity");class Relations{}t([(0,o.OneToMany)(()=>n.NotificationRecipient,t=>t.notification),e("design:type",Array)],Relations.prototype,"recipients",void 0);let a=class Notification extends Relations{};exports.Notification=a,t([(0,o.PrimaryGeneratedColumn)(),e("design:type",Number)],a.prototype,"id",void 0),t([(0,o.Column)("varchar",{length:25}),e("design:type",String)],a.prototype,"type",void 0),t([(0,o.Column)("varchar",{length:50,nullable:!0}),e("design:type",String)],a.prototype,"batch_id",void 0),t([(0,o.Column)("varchar",{length:50}),e("design:type",String)],a.prototype,"template_key",void 0),t([(0,o.Column)("enum",{enum:i.NOTIFICATION_STATUS}),e("design:type",String)],a.prototype,"status",void 0),t([(0,o.Column)("varchar",{length:50,nullable:!0}),e("design:type",String)],a.prototype,"sender",void 0),t([(0,o.Column)("varchar",{length:100,nullable:!0}),e("design:type",String)],a.prototype,"title",void 0),t([(0,o.Column)("text",{nullable:!0}),e("design:type",String)],a.prototype,"content",void 0),t([(0,o.Column)("timestamptz",{nullable:!0}),e("design:type",Date)],a.prototype,"scheduled_at",void 0),t([(0,o.Column)("timestamptz",{nullable:!0}),e("design:type",Date)],a.prototype,"sent_at",void 0),t([(0,o.CreateDateColumn)({type:"timestamptz"}),e("design:type",Date)],a.prototype,"created_at",void 0),t([(0,o.UpdateDateColumn)({type:"timestamptz"}),e("design:type",Date)],a.prototype,"updated_at",void 0),t([(0,o.DeleteDateColumn)({type:"timestamptz"}),e("design:type",Date)],a.prototype,"deleted_at",void 0),exports.Notification=a=t([(0,o.Entity)("notifications"),(0,o.Index)(["id"],{where:"deleted_at IS NULL"}),(0,o.Index)(["status"])],a);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=this&&this.__decorate||function(e,t,i,n){var o,r=arguments.length,s=r<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,i,n);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(r<3?o(s):r>3?o(t,i,s):o(t,i))||s);return r>3&&s&&Object.defineProperty(t,i,s),s},t=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},i=this&&this.__param||function(e,t){return function(i,n){t(i,n,e)}},n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))(function(o,r){function fulfilled(e){try{step(n.next(e))}catch(e){r(e)}}function rejected(e){try{step(n.throw(e))}catch(e){r(e)}}function step(e){e.done?o(e.value):function adopt(e){return e instanceof i?e:new i(function(t){t(e)})}(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0}),exports.EventStorageService=void 0;const o=require("@nestjs/common"),r=require("@nestjs/typeorm"),s=require("nanoid"),a=require("typeorm"),d=require("../../database/entities");let u=class EventStorageService{constructor(e,t,i){this.eventLogRepository=e,this.auditLogRepository=t,this.dataSource=i}store(e){return n(this,void 0,void 0,function*(){var t,i,n;const o=this.eventLogRepository.create({uid:e.uid||(0,s.nanoid)(),name:e.name,user_id:(null===(t=e.user)||void 0===t?void 0:t.user_id)||0,ip_address:null===(i=e.user)||void 0===i?void 0:i.ip_address,user_agent:null===(n=e.user)||void 0===n?void 0:n.user_agent,occurred_at:e.timestamp||new Date});yield this.eventLogRepository.save(o)})}storeAuditEvent(e){return n(this,void 0,void 0,function*(){yield this.dataSource.transaction(t=>n(this,void 0,void 0,function*(){var i,n,o;const r=t.create(d.LogsAudit,{uid:e.uid||(0,s.nanoid)(),name:e.name,user_id:(null===(i=e.user)||void 0===i?void 0:i.user_id)||0,entity:e.entity,entity_id:e.entity_id,entity_ids:e.entity_ids,action:e.action,changes:e.changes,ip_address:null===(n=e.user)||void 0===n?void 0:n.ip_address,user_agent:null===(o=e.user)||void 0===o?void 0:o.user_agent,occurred_at:e.timestamp||new Date,meta:e.meta});yield t.save(r)}))})}};exports.EventStorageService=u,exports.EventStorageService=u=e([(0,o.Injectable)(),i(0,(0,r.InjectRepository)(d.LogsEvent)),i(1,(0,r.InjectRepository)(d.LogsAudit)),t("design:paramtypes",[a.Repository,a.Repository,a.DataSource])],u);
|
|
1
|
+
var e=this&&this.__decorate||function(e,t,i,n){var o,r=arguments.length,s=r<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,i,n);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(r<3?o(s):r>3?o(t,i,s):o(t,i))||s);return r>3&&s&&Object.defineProperty(t,i,s),s},t=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},i=this&&this.__param||function(e,t){return function(i,n){t(i,n,e)}},n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))(function(o,r){function fulfilled(e){try{step(n.next(e))}catch(e){r(e)}}function rejected(e){try{step(n.throw(e))}catch(e){r(e)}}function step(e){e.done?o(e.value):function adopt(e){return e instanceof i?e:new i(function(t){t(e)})}(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0}),exports.EventStorageService=void 0;const o=require("@nestjs/common"),r=require("@nestjs/typeorm"),s=require("nanoid"),a=require("typeorm"),d=require("../../database/entities");let u=class EventStorageService{constructor(e,t,i){this.eventLogRepository=e,this.auditLogRepository=t,this.dataSource=i}store(e){return n(this,void 0,void 0,function*(){var t,i,n;const o=this.eventLogRepository.create({uid:e.uid||(0,s.nanoid)(),name:e.name,user_id:(null===(t=e.user)||void 0===t?void 0:t.user_id)||0,ip_address:null===(i=e.user)||void 0===i?void 0:i.ip_address,user_agent:null===(n=e.user)||void 0===n?void 0:n.user_agent,occurred_at:e.timestamp||new Date});yield this.eventLogRepository.save(o)})}storeAuditEvent(e){return n(this,void 0,void 0,function*(){yield this.dataSource.transaction(t=>n(this,void 0,void 0,function*(){var i,n,o;const r=t.create(d.LogsAudit,{uid:e.uid||(0,s.nanoid)(),name:e.name,user_id:(null===(i=e.user)||void 0===i?void 0:i.user_id)||0,target_user_id:e.target_user_id,entity:e.entity,entity_id:e.entity_id,entity_ids:e.entity_ids,action:e.action,changes:e.changes,ip_address:null===(n=e.user)||void 0===n?void 0:n.ip_address,user_agent:null===(o=e.user)||void 0===o?void 0:o.user_agent,occurred_at:e.timestamp||new Date,meta:e.meta});yield t.save(r)}))})}};exports.EventStorageService=u,exports.EventStorageService=u=e([(0,o.Injectable)(),i(0,(0,r.InjectRepository)(d.LogsEvent)),i(1,(0,r.InjectRepository)(d.LogsAudit)),t("design:paramtypes",[a.Repository,a.Repository,a.DataSource])],u);
|
|
@@ -5,6 +5,7 @@ export interface AuditEventBase<TName extends string = string> extends BaseEvent
|
|
|
5
5
|
readonly entity: string;
|
|
6
6
|
readonly entity_id: number;
|
|
7
7
|
readonly entity_ids?: string[];
|
|
8
|
+
readonly target_user_id?: number;
|
|
8
9
|
readonly action: AUDIT_ACTION;
|
|
9
10
|
readonly changes?: Record<string, {
|
|
10
11
|
before: any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=this&&this.__decorate||function(e,t,r,s){var c
|
|
1
|
+
var e=this&&this.__decorate||function(e,t,r,s){var o,c=arguments.length,n=c<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,s);else for(var p=e.length-1;p>=0;p--)(o=e[p])&&(n=(c<3?o(n):c>3?o(t,r,n):o(t,r))||n);return c>3&&n&&Object.defineProperty(t,r,n),n},t=this&&this.__rest||function(e,t){var r={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(r[s]=e[s]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(s=Object.getOwnPropertySymbols(e);o<s.length;o++)t.indexOf(s[o])<0&&Object.prototype.propertyIsEnumerable.call(e,s[o])&&(r[s[o]]=e[s[o]])}return r};Object.defineProperty(exports,"__esModule",{value:!0}),exports.SuccessInterceptor=void 0;const r=require("@nestjs/common"),s=require("rxjs/operators");let o=class SuccessInterceptor{intercept(e,r){return r.handle().pipe((0,s.map)(e=>{const{audit:r}=e,s=t(e,["audit"]);return e&&(e.access_token||e.refresh_token)?Object.assign({success:!0},s):e&&void 0!==e.response?{success:!0,data:s.response}:void 0===e.response?{success:!0,data:s}:{success:!0}}))}};exports.SuccessInterceptor=o,exports.SuccessInterceptor=o=e([(0,r.Injectable)()],o);
|