@drax/audit-back 0.38.0

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.
Files changed (47) hide show
  1. package/dist/controllers/AuditController.js +54 -0
  2. package/dist/factory/services/AuditServiceFactory.js +15 -0
  3. package/dist/index.js +10 -0
  4. package/dist/interfaces/IAuditRepository.js +1 -0
  5. package/dist/models/AuditModel.js +38 -0
  6. package/dist/permissions/AuditPermissions.js +8 -0
  7. package/dist/repository/AuditRepository.js +12 -0
  8. package/dist/routes/AuditRoutes.js +15 -0
  9. package/dist/schemas/AuditSchema.js +31 -0
  10. package/dist/services/AuditService.js +8 -0
  11. package/dist/utils/RegisterCrudEvent.js +67 -0
  12. package/package.json +43 -0
  13. package/src/controllers/AuditController.ts +63 -0
  14. package/src/factory/services/AuditServiceFactory.ts +23 -0
  15. package/src/index.ts +26 -0
  16. package/src/interfaces/IAuditRepository.ts +11 -0
  17. package/src/models/AuditModel.ts +52 -0
  18. package/src/permissions/AuditPermissions.ts +12 -0
  19. package/src/repository/AuditRepository.ts +21 -0
  20. package/src/routes/AuditRoutes.ts +25 -0
  21. package/src/schemas/AuditSchema.ts +38 -0
  22. package/src/services/AuditService.ts +16 -0
  23. package/src/utils/RegisterCrudEvent.ts +88 -0
  24. package/tsconfig.json +16 -0
  25. package/tsconfig.tsbuildinfo +1 -0
  26. package/types/controllers/AuditController.d.ts +13 -0
  27. package/types/controllers/AuditController.d.ts.map +1 -0
  28. package/types/factory/services/AuditServiceFactory.d.ts +8 -0
  29. package/types/factory/services/AuditServiceFactory.d.ts.map +1 -0
  30. package/types/index.d.ts +13 -0
  31. package/types/index.d.ts.map +1 -0
  32. package/types/interfaces/IAuditRepository.d.ts +6 -0
  33. package/types/interfaces/IAuditRepository.d.ts.map +1 -0
  34. package/types/models/AuditModel.d.ts +15 -0
  35. package/types/models/AuditModel.d.ts.map +1 -0
  36. package/types/permissions/AuditPermissions.d.ts +8 -0
  37. package/types/permissions/AuditPermissions.d.ts.map +1 -0
  38. package/types/repository/AuditRepository.d.ts +9 -0
  39. package/types/repository/AuditRepository.d.ts.map +1 -0
  40. package/types/routes/AuditRoutes.d.ts +4 -0
  41. package/types/routes/AuditRoutes.d.ts.map +1 -0
  42. package/types/schemas/AuditSchema.d.ts +189 -0
  43. package/types/schemas/AuditSchema.d.ts.map +1 -0
  44. package/types/services/AuditService.d.ts +10 -0
  45. package/types/services/AuditService.d.ts.map +1 -0
  46. package/types/utils/RegisterCrudEvent.d.ts +5 -0
  47. package/types/utils/RegisterCrudEvent.d.ts.map +1 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuditServiceFactory.d.ts","sourceRoot":"","sources":["../../../src/factory/services/AuditServiceFactory.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,YAAY,EAAC,MAAM,gCAAgC,CAAA;AAG3D,cAAM,mBAAmB;IACrB,OAAO,CAAC,MAAM,CAAC,OAAO,CAAe;IAErC,WAAkB,QAAQ,IAAI,YAAY,CAOzC;CACJ;AAED,eAAe,mBAAmB,CAAA;AAClC,OAAO,EACH,mBAAmB,EACtB,CAAA"}
@@ -0,0 +1,13 @@
1
+ import AuditPermissions from './permissions/AuditPermissions.js';
2
+ import AuditSchema from './schemas/AuditSchema.js';
3
+ import AuditModel from './models/AuditModel.js';
4
+ import AuditRepository from './repository/AuditRepository.js';
5
+ import AuditService from './services/AuditService.js';
6
+ import AuditServiceFactory from './factory/services/AuditServiceFactory.js';
7
+ import AuditController from './controllers/AuditController.js';
8
+ import AuditRoutes from './routes/AuditRoutes.js';
9
+ import { RegisterCrudEvent } from './utils/RegisterCrudEvent.js';
10
+ import type { IAuditRepository } from './interfaces/IAuditRepository';
11
+ export type { IAuditRepository };
12
+ export { AuditPermissions, AuditSchema, AuditModel, AuditRepository, AuditService, AuditServiceFactory, AuditController, AuditRoutes, RegisterCrudEvent };
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,MAAM,mCAAmC,CAAA;AAChE,OAAO,WAAW,MAAM,0BAA0B,CAAA;AAClD,OAAO,UAAU,MAAM,wBAAwB,CAAA;AAC/C,OAAO,eAAe,MAAM,iCAAiC,CAAA;AAC7D,OAAO,YAAY,MAAM,4BAA4B,CAAA;AACrD,OAAO,mBAAmB,MAAM,2CAA2C,CAAA;AAC3E,OAAO,eAAe,MAAM,kCAAkC,CAAA;AAC9D,OAAO,WAAW,MAAM,yBAAyB,CAAA;AACjD,OAAO,EAAC,iBAAiB,EAAC,MAAM,8BAA8B,CAAA;AAC9D,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,+BAA+B,CAAA;AAEnE,YAAW,EACP,gBAAgB,EACnB,CAAA;AAED,OAAO,EACH,gBAAgB,EAChB,WAAW,EACX,UAAU,EACV,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,eAAe,EACf,WAAW,EACX,iBAAiB,EACpB,CAAA"}
@@ -0,0 +1,6 @@
1
+ import type { IAudit, IAuditBase } from '@drax/audit-share';
2
+ import { IDraxCrudRepository } from "@drax/crud-share";
3
+ interface IAuditRepository extends IDraxCrudRepository<IAudit, IAuditBase, IAuditBase> {
4
+ }
5
+ export { IAuditRepository };
6
+ //# sourceMappingURL=IAuditRepository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IAuditRepository.d.ts","sourceRoot":"","sources":["../../src/interfaces/IAuditRepository.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,MAAM,EAAE,UAAU,EAAC,MAAM,mBAAmB,CAAA;AACzD,OAAO,EAAC,mBAAmB,EAAC,MAAM,kBAAkB,CAAC;AAErD,UAAU,gBAAiB,SAAQ,mBAAmB,CAAC,MAAM,EAAE,UAAU,EAAE,UAAU,CAAC;CAErF;AAED,OAAO,EAAC,gBAAgB,EAAC,CAAA"}
@@ -0,0 +1,15 @@
1
+ import { mongoose } from '@drax/common-back';
2
+ import type { IAudit } from '@drax/audit-share';
3
+ declare const AuditSchema: mongoose.Schema<IAudit, mongoose.Model<IAudit, any, any, any, mongoose.Document<unknown, any, IAudit> & IAudit & Required<{
4
+ _id: string;
5
+ }> & {
6
+ __v: number;
7
+ }, any>, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, IAudit, mongoose.Document<unknown, {}, mongoose.FlatRecord<IAudit>> & mongoose.FlatRecord<IAudit> & Required<{
8
+ _id: string;
9
+ }> & {
10
+ __v: number;
11
+ }>;
12
+ declare const AuditModel: mongoose.PaginateModel<IAudit, {}, {}>;
13
+ export { AuditSchema, AuditModel };
14
+ export default AuditModel;
15
+ //# sourceMappingURL=AuditModel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuditModel.d.ts","sourceRoot":"","sources":["../../src/models/AuditModel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAI3C,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,mBAAmB,CAAA;AAE7C,QAAA,MAAM,WAAW;;;;;;;;EAsBK,CAAC;AAgBvB,QAAA,MAAM,UAAU,wCAA0F,CAAC;AAE3G,OAAO,EACH,WAAW,EACX,UAAU,EACb,CAAA;AAED,eAAe,UAAU,CAAA"}
@@ -0,0 +1,8 @@
1
+ declare enum AuditPermissions {
2
+ View = "audit:view",
3
+ ViewAll = "audit:viewAll",
4
+ Manage = "audit:manage"
5
+ }
6
+ export { AuditPermissions };
7
+ export default AuditPermissions;
8
+ //# sourceMappingURL=AuditPermissions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuditPermissions.d.ts","sourceRoot":"","sources":["../../src/permissions/AuditPermissions.ts"],"names":[],"mappings":"AACA,aAAK,gBAAgB;IAEjB,IAAI,eAAe;IACnB,OAAO,kBAAkB;IACzB,MAAM,iBAAiB;CAE1B;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAC5B,eAAe,gBAAgB,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { AbstractMongoRepository } from "@drax/crud-back";
2
+ import type { IAuditRepository } from '../interfaces/IAuditRepository';
3
+ import type { IAudit, IAuditBase } from "@drax/audit-share";
4
+ declare class AuditMongoRepository extends AbstractMongoRepository<IAudit, IAuditBase, IAuditBase> implements IAuditRepository {
5
+ constructor();
6
+ }
7
+ export default AuditMongoRepository;
8
+ export { AuditMongoRepository };
9
+ //# sourceMappingURL=AuditRepository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuditRepository.d.ts","sourceRoot":"","sources":["../../src/repository/AuditRepository.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,uBAAuB,EAAC,MAAM,iBAAiB,CAAC;AAExD,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,gCAAgC,CAAA;AACpE,OAAO,KAAK,EAAC,MAAM,EAAE,UAAU,EAAC,MAAM,mBAAmB,CAAC;AAG1D,cAAM,oBAAqB,SAAQ,uBAAuB,CAAC,MAAM,EAAE,UAAU,EAAE,UAAU,CAAE,YAAW,gBAAgB;;CASrH;AAED,eAAe,oBAAoB,CAAA;AACnC,OAAO,EAAC,oBAAoB,EAAC,CAAA"}
@@ -0,0 +1,4 @@
1
+ declare function AuditFastifyRoutes(fastify: any, options: any): Promise<void>;
2
+ export default AuditFastifyRoutes;
3
+ export { AuditFastifyRoutes };
4
+ //# sourceMappingURL=AuditRoutes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuditRoutes.d.ts","sourceRoot":"","sources":["../../src/routes/AuditRoutes.ts"],"names":[],"mappings":"AAKA,iBAAe,kBAAkB,CAAC,OAAO,KAAA,EAAE,OAAO,KAAA,iBAgBjD;AAED,eAAe,kBAAkB,CAAC;AAClC,OAAO,EAAC,kBAAkB,EAAC,CAAA"}
@@ -0,0 +1,189 @@
1
+ import { z } from 'zod';
2
+ declare const AuditBaseSchema: z.ZodObject<{
3
+ entity: z.ZodString;
4
+ user: z.ZodObject<{
5
+ id: z.ZodString;
6
+ username: z.ZodString;
7
+ rolName: z.ZodNullable<z.ZodOptional<z.ZodString>>;
8
+ }, "strip", z.ZodTypeAny, {
9
+ id?: string;
10
+ username?: string;
11
+ rolName?: string;
12
+ }, {
13
+ id?: string;
14
+ username?: string;
15
+ rolName?: string;
16
+ }>;
17
+ action: z.ZodString;
18
+ ip: z.ZodNullable<z.ZodOptional<z.ZodString>>;
19
+ userAgent: z.ZodNullable<z.ZodOptional<z.ZodString>>;
20
+ changes: z.ZodOptional<z.ZodArray<z.ZodObject<{
21
+ field: z.ZodString;
22
+ old: z.ZodNullable<z.ZodOptional<z.ZodString>>;
23
+ new: z.ZodNullable<z.ZodOptional<z.ZodString>>;
24
+ }, "strip", z.ZodTypeAny, {
25
+ field?: string;
26
+ old?: string;
27
+ new?: string;
28
+ }, {
29
+ field?: string;
30
+ old?: string;
31
+ new?: string;
32
+ }>, "many">>;
33
+ sessionId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
34
+ requestId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
35
+ detail: z.ZodNullable<z.ZodOptional<z.ZodString>>;
36
+ tenant: z.ZodNullable<z.ZodOptional<z.ZodObject<{
37
+ id: z.ZodNullable<z.ZodOptional<z.ZodString>>;
38
+ name: z.ZodNullable<z.ZodOptional<z.ZodString>>;
39
+ }, "strip", z.ZodTypeAny, {
40
+ id?: string;
41
+ name?: string;
42
+ }, {
43
+ id?: string;
44
+ name?: string;
45
+ }>>>;
46
+ }, "strip", z.ZodTypeAny, {
47
+ entity?: string;
48
+ user?: {
49
+ id?: string;
50
+ username?: string;
51
+ rolName?: string;
52
+ };
53
+ action?: string;
54
+ ip?: string;
55
+ userAgent?: string;
56
+ changes?: {
57
+ field?: string;
58
+ old?: string;
59
+ new?: string;
60
+ }[];
61
+ sessionId?: string;
62
+ requestId?: string;
63
+ detail?: string;
64
+ tenant?: {
65
+ id?: string;
66
+ name?: string;
67
+ };
68
+ }, {
69
+ entity?: string;
70
+ user?: {
71
+ id?: string;
72
+ username?: string;
73
+ rolName?: string;
74
+ };
75
+ action?: string;
76
+ ip?: string;
77
+ userAgent?: string;
78
+ changes?: {
79
+ field?: string;
80
+ old?: string;
81
+ new?: string;
82
+ }[];
83
+ sessionId?: string;
84
+ requestId?: string;
85
+ detail?: string;
86
+ tenant?: {
87
+ id?: string;
88
+ name?: string;
89
+ };
90
+ }>;
91
+ declare const AuditSchema: z.ZodObject<z.objectUtil.extendShape<{
92
+ entity: z.ZodString;
93
+ user: z.ZodObject<{
94
+ id: z.ZodString;
95
+ username: z.ZodString;
96
+ rolName: z.ZodNullable<z.ZodOptional<z.ZodString>>;
97
+ }, "strip", z.ZodTypeAny, {
98
+ id?: string;
99
+ username?: string;
100
+ rolName?: string;
101
+ }, {
102
+ id?: string;
103
+ username?: string;
104
+ rolName?: string;
105
+ }>;
106
+ action: z.ZodString;
107
+ ip: z.ZodNullable<z.ZodOptional<z.ZodString>>;
108
+ userAgent: z.ZodNullable<z.ZodOptional<z.ZodString>>;
109
+ changes: z.ZodOptional<z.ZodArray<z.ZodObject<{
110
+ field: z.ZodString;
111
+ old: z.ZodNullable<z.ZodOptional<z.ZodString>>;
112
+ new: z.ZodNullable<z.ZodOptional<z.ZodString>>;
113
+ }, "strip", z.ZodTypeAny, {
114
+ field?: string;
115
+ old?: string;
116
+ new?: string;
117
+ }, {
118
+ field?: string;
119
+ old?: string;
120
+ new?: string;
121
+ }>, "many">>;
122
+ sessionId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
123
+ requestId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
124
+ detail: z.ZodNullable<z.ZodOptional<z.ZodString>>;
125
+ tenant: z.ZodNullable<z.ZodOptional<z.ZodObject<{
126
+ id: z.ZodNullable<z.ZodOptional<z.ZodString>>;
127
+ name: z.ZodNullable<z.ZodOptional<z.ZodString>>;
128
+ }, "strip", z.ZodTypeAny, {
129
+ id?: string;
130
+ name?: string;
131
+ }, {
132
+ id?: string;
133
+ name?: string;
134
+ }>>>;
135
+ }, {
136
+ _id: z.ZodString;
137
+ createdAt: z.ZodDate;
138
+ }>, "strip", z.ZodTypeAny, {
139
+ entity?: string;
140
+ user?: {
141
+ id?: string;
142
+ username?: string;
143
+ rolName?: string;
144
+ };
145
+ action?: string;
146
+ ip?: string;
147
+ userAgent?: string;
148
+ changes?: {
149
+ field?: string;
150
+ old?: string;
151
+ new?: string;
152
+ }[];
153
+ sessionId?: string;
154
+ requestId?: string;
155
+ detail?: string;
156
+ tenant?: {
157
+ id?: string;
158
+ name?: string;
159
+ };
160
+ _id?: string;
161
+ createdAt?: Date;
162
+ }, {
163
+ entity?: string;
164
+ user?: {
165
+ id?: string;
166
+ username?: string;
167
+ rolName?: string;
168
+ };
169
+ action?: string;
170
+ ip?: string;
171
+ userAgent?: string;
172
+ changes?: {
173
+ field?: string;
174
+ old?: string;
175
+ new?: string;
176
+ }[];
177
+ sessionId?: string;
178
+ requestId?: string;
179
+ detail?: string;
180
+ tenant?: {
181
+ id?: string;
182
+ name?: string;
183
+ };
184
+ _id?: string;
185
+ createdAt?: Date;
186
+ }>;
187
+ export default AuditSchema;
188
+ export { AuditSchema, AuditBaseSchema };
189
+ //# sourceMappingURL=AuditSchema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuditSchema.d.ts","sourceRoot":"","sources":["../../src/schemas/AuditSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAGtB,QAAA,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwBnB,CAAC;AAEH,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKX,CAAA;AAEN,eAAe,WAAW,CAAC;AAC3B,OAAO,EAAC,WAAW,EAAE,eAAe,EAAC,CAAA"}
@@ -0,0 +1,10 @@
1
+ import type { IAuditRepository } from "../interfaces/IAuditRepository";
2
+ import type { IAuditBase, IAudit } from "@drax/audit-share";
3
+ import { AbstractService } from "@drax/crud-back";
4
+ import type { ZodObject, ZodRawShape } from "zod";
5
+ declare class AuditService extends AbstractService<IAudit, IAuditBase, IAuditBase> {
6
+ constructor(AuditRepository: IAuditRepository, schema?: ZodObject<ZodRawShape>);
7
+ }
8
+ export default AuditService;
9
+ export { AuditService };
10
+ //# sourceMappingURL=AuditService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuditService.d.ts","sourceRoot":"","sources":["../../src/services/AuditService.ts"],"names":[],"mappings":"AACA,OAAO,KAAI,EAAC,gBAAgB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,KAAK,EAAC,UAAU,EAAE,MAAM,EAAC,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAC,eAAe,EAAC,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,EAAC,SAAS,EAAE,WAAW,EAAC,MAAM,KAAK,CAAC;AAEhD,cAAM,YAAa,SAAQ,eAAe,CAAC,MAAM,EAAE,UAAU,EAAE,UAAU,CAAC;gBAE1D,eAAe,EAAE,gBAAgB,EAAE,MAAM,CAAC,EAAE,SAAS,CAAC,WAAW,CAAC;CAIjF;AAED,eAAe,YAAY,CAAA;AAC3B,OAAO,EAAC,YAAY,EAAC,CAAA"}
@@ -0,0 +1,5 @@
1
+ import { IDraxCrudEvent } from "@drax/crud-share";
2
+ declare function RegisterCrudEvent(crudEventData: IDraxCrudEvent): Promise<import("@drax/audit-share").IAudit>;
3
+ export { RegisterCrudEvent };
4
+ export default RegisterCrudEvent;
5
+ //# sourceMappingURL=RegisterCrudEvent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RegisterCrudEvent.d.ts","sourceRoot":"","sources":["../../src/utils/RegisterCrudEvent.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAShD,iBAAe,iBAAiB,CAAC,aAAa,EAAE,cAAc,+CA0E7D;AAED,OAAO,EAAC,iBAAiB,EAAC,CAAA;AAC1B,eAAe,iBAAiB,CAAA"}