@palmetto/nestjs-log-history 0.0.1 → 0.0.2
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/dto.d.ts
CHANGED
|
@@ -15,8 +15,8 @@ export declare const HistoryDtoSchema: z.ZodObject<{
|
|
|
15
15
|
originalDocument: z.ZodOptional<z.ZodUnknown>;
|
|
16
16
|
logs: z.ZodArray<z.ZodObject<{
|
|
17
17
|
fieldName: z.ZodString;
|
|
18
|
-
oldValue: z.ZodOptional<z.
|
|
19
|
-
newValue: z.ZodOptional<z.
|
|
18
|
+
oldValue: z.ZodOptional<z.ZodAny>;
|
|
19
|
+
newValue: z.ZodOptional<z.ZodAny>;
|
|
20
20
|
changeType: z.ZodEnum<{
|
|
21
21
|
add: "add";
|
|
22
22
|
edit: "edit";
|
|
@@ -40,8 +40,8 @@ declare const HistoryDto_base: import("nestjs-zod").ZodDto<z.ZodObject<{
|
|
|
40
40
|
originalDocument: z.ZodOptional<z.ZodUnknown>;
|
|
41
41
|
logs: z.ZodArray<z.ZodObject<{
|
|
42
42
|
fieldName: z.ZodString;
|
|
43
|
-
oldValue: z.ZodOptional<z.
|
|
44
|
-
newValue: z.ZodOptional<z.
|
|
43
|
+
oldValue: z.ZodOptional<z.ZodAny>;
|
|
44
|
+
newValue: z.ZodOptional<z.ZodAny>;
|
|
45
45
|
changeType: z.ZodEnum<{
|
|
46
46
|
add: "add";
|
|
47
47
|
edit: "edit";
|
package/dist/dto.js
CHANGED
|
@@ -16,8 +16,8 @@ exports.HistoryDtoSchema = zod_1.z.strictObject({
|
|
|
16
16
|
originalDocument: zod_1.z.unknown().optional(),
|
|
17
17
|
logs: zod_1.z.array(zod_1.z.strictObject({
|
|
18
18
|
fieldName: zod_1.z.string(),
|
|
19
|
-
oldValue: zod_1.z.any().
|
|
20
|
-
newValue: zod_1.z.any().
|
|
19
|
+
oldValue: zod_1.z.any().optional(),
|
|
20
|
+
newValue: zod_1.z.any().optional(),
|
|
21
21
|
changeType: zod_1.z.enum(["add", "edit", "remove"]),
|
|
22
22
|
})),
|
|
23
23
|
});
|
|
@@ -7,9 +7,9 @@ export declare const FieldLogSchema: z.ZodObject<{
|
|
|
7
7
|
edit: "edit";
|
|
8
8
|
remove: "remove";
|
|
9
9
|
}>;
|
|
10
|
-
fromValue: z.ZodOptional<z.
|
|
11
|
-
toValue: z.ZodOptional<z.
|
|
12
|
-
context: z.ZodOptional<z.
|
|
10
|
+
fromValue: z.ZodOptional<z.ZodString>;
|
|
11
|
+
toValue: z.ZodOptional<z.ZodString>;
|
|
12
|
+
context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
13
13
|
}, z.core.$strip>;
|
|
14
14
|
export type FieldLog = z.infer<typeof FieldLogSchema>;
|
|
15
15
|
export declare function fieldLogFromEntry(entry: LogHistoryFieldLog): FieldLog;
|
|
@@ -12,13 +12,13 @@ exports.FieldLogSchema = zod_1.z.object({
|
|
|
12
12
|
.meta({ description: "The type of change made to the field" }),
|
|
13
13
|
fromValue: zod_1.z
|
|
14
14
|
.string()
|
|
15
|
-
.
|
|
15
|
+
.optional()
|
|
16
16
|
.meta({ description: "The previous value of the field" }),
|
|
17
17
|
toValue: zod_1.z
|
|
18
18
|
.string()
|
|
19
|
-
.
|
|
19
|
+
.optional()
|
|
20
20
|
.meta({ description: "The new value of the field" }),
|
|
21
|
-
context: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).
|
|
21
|
+
context: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional().meta({
|
|
22
22
|
description: "Additional context specific to this field change",
|
|
23
23
|
}),
|
|
24
24
|
});
|
|
@@ -26,8 +26,8 @@ function fieldLogFromEntry(entry) {
|
|
|
26
26
|
return {
|
|
27
27
|
fieldName: entry.field_name,
|
|
28
28
|
changeType: entry.change_type,
|
|
29
|
-
fromValue: entry.from_value,
|
|
30
|
-
toValue: entry.to_value,
|
|
29
|
+
fromValue: entry.from_value === null ? undefined : entry.from_value,
|
|
30
|
+
toValue: entry.to_value === null ? undefined : entry.to_value,
|
|
31
31
|
context: entry.context,
|
|
32
32
|
};
|
|
33
33
|
}
|
|
@@ -16,13 +16,13 @@ export declare const LogHistoryEntitySchema: z.ZodObject<{
|
|
|
16
16
|
edit: "edit";
|
|
17
17
|
remove: "remove";
|
|
18
18
|
}>;
|
|
19
|
-
fromValue: z.ZodOptional<z.
|
|
20
|
-
toValue: z.ZodOptional<z.
|
|
21
|
-
context: z.ZodOptional<z.
|
|
19
|
+
fromValue: z.ZodOptional<z.ZodString>;
|
|
20
|
+
toValue: z.ZodOptional<z.ZodString>;
|
|
21
|
+
context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
22
22
|
}, z.core.$strip>>;
|
|
23
|
-
context: z.ZodOptional<z.
|
|
24
|
-
originalDocument: z.ZodOptional<z.
|
|
25
|
-
updatedDocument: z.ZodOptional<z.
|
|
23
|
+
context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
24
|
+
originalDocument: z.ZodOptional<z.ZodUnknown>;
|
|
25
|
+
updatedDocument: z.ZodOptional<z.ZodUnknown>;
|
|
26
26
|
isDeleted: z.ZodBoolean;
|
|
27
27
|
createdBy: z.ZodString;
|
|
28
28
|
createdAt: z.ZodDate;
|
|
@@ -16,12 +16,12 @@ exports.LogHistoryEntitySchema = zod_1.z.object({
|
|
|
16
16
|
.meta({ description: "Array of individual field changes" }),
|
|
17
17
|
context: zod_1.z
|
|
18
18
|
.record(zod_1.z.string(), zod_1.z.unknown())
|
|
19
|
-
.
|
|
19
|
+
.optional()
|
|
20
20
|
.meta({ description: "Global context information for this change" }),
|
|
21
|
-
originalDocument: zod_1.z.unknown().
|
|
21
|
+
originalDocument: zod_1.z.unknown().optional().meta({
|
|
22
22
|
description: "Complete original document snapshot (if saveWholeDoc is enabled)",
|
|
23
23
|
}),
|
|
24
|
-
updatedDocument: zod_1.z.unknown().
|
|
24
|
+
updatedDocument: zod_1.z.unknown().optional().meta({
|
|
25
25
|
description: "Complete updated document snapshot (if saveWholeDoc is enabled)",
|
|
26
26
|
}),
|
|
27
27
|
isDeleted: zod_1.z.boolean().meta({
|
|
@@ -34,15 +34,20 @@ exports.LogHistoryEntitySchema = zod_1.z.object({
|
|
|
34
34
|
.date()
|
|
35
35
|
.meta({ description: "Timestamp when the log entry was created" }),
|
|
36
36
|
});
|
|
37
|
+
function isNull(obj) {
|
|
38
|
+
return obj === null;
|
|
39
|
+
}
|
|
37
40
|
function entryToEntity(entry) {
|
|
38
41
|
return {
|
|
39
42
|
_id: new mongoose_1.Types.ObjectId(),
|
|
40
43
|
modelId: new mongoose_1.Types.ObjectId(entry.model_id),
|
|
41
44
|
changeType: entry.change_type,
|
|
42
45
|
logs: entry.logs.map(field_log_js_1.fieldLogFromEntry),
|
|
43
|
-
context: entry.context,
|
|
44
|
-
originalDocument: entry.original_doc
|
|
45
|
-
|
|
46
|
+
context: isNull(entry.context) ? undefined : entry.context,
|
|
47
|
+
originalDocument: isNull(entry.original_doc)
|
|
48
|
+
? undefined
|
|
49
|
+
: entry.original_doc,
|
|
50
|
+
updatedDocument: isNull(entry.updated_doc) ? undefined : entry.updated_doc,
|
|
46
51
|
isDeleted: entry.is_deleted,
|
|
47
52
|
createdBy: typeof entry.created_by === "string" ? entry.created_by : "unknown",
|
|
48
53
|
createdAt: entry.created_at,
|
package/dist/history-schema.d.ts
CHANGED
|
@@ -9,14 +9,14 @@ export declare function createLogHistorySchema(options: HistoryPluginConfig): im
|
|
|
9
9
|
logs: {
|
|
10
10
|
fieldName: string;
|
|
11
11
|
changeType: "add" | "edit" | "remove";
|
|
12
|
-
fromValue?: string |
|
|
13
|
-
toValue?: string |
|
|
14
|
-
context?: Record<string, unknown> |
|
|
12
|
+
fromValue?: string | undefined;
|
|
13
|
+
toValue?: string | undefined;
|
|
14
|
+
context?: Record<string, unknown> | undefined;
|
|
15
15
|
}[];
|
|
16
16
|
isDeleted: boolean;
|
|
17
17
|
createdBy: string;
|
|
18
18
|
createdAt: Date;
|
|
19
|
-
context?: Record<string, unknown> |
|
|
19
|
+
context?: Record<string, unknown> | undefined;
|
|
20
20
|
originalDocument?: unknown;
|
|
21
21
|
updatedDocument?: unknown;
|
|
22
22
|
}, import("mongoose").Model<{
|
|
@@ -25,14 +25,14 @@ export declare function createLogHistorySchema(options: HistoryPluginConfig): im
|
|
|
25
25
|
logs: {
|
|
26
26
|
fieldName: string;
|
|
27
27
|
changeType: "add" | "edit" | "remove";
|
|
28
|
-
fromValue?: string |
|
|
29
|
-
toValue?: string |
|
|
30
|
-
context?: Record<string, unknown> |
|
|
28
|
+
fromValue?: string | undefined;
|
|
29
|
+
toValue?: string | undefined;
|
|
30
|
+
context?: Record<string, unknown> | undefined;
|
|
31
31
|
}[];
|
|
32
32
|
isDeleted: boolean;
|
|
33
33
|
createdBy: string;
|
|
34
34
|
createdAt: Date;
|
|
35
|
-
context?: Record<string, unknown> |
|
|
35
|
+
context?: Record<string, unknown> | undefined;
|
|
36
36
|
originalDocument?: unknown;
|
|
37
37
|
updatedDocument?: unknown;
|
|
38
38
|
}, {}, {}, {}, import("mongoose").Document<unknown, {}, {
|
|
@@ -41,14 +41,14 @@ export declare function createLogHistorySchema(options: HistoryPluginConfig): im
|
|
|
41
41
|
logs: {
|
|
42
42
|
fieldName: string;
|
|
43
43
|
changeType: "add" | "edit" | "remove";
|
|
44
|
-
fromValue?: string |
|
|
45
|
-
toValue?: string |
|
|
46
|
-
context?: Record<string, unknown> |
|
|
44
|
+
fromValue?: string | undefined;
|
|
45
|
+
toValue?: string | undefined;
|
|
46
|
+
context?: Record<string, unknown> | undefined;
|
|
47
47
|
}[];
|
|
48
48
|
isDeleted: boolean;
|
|
49
49
|
createdBy: string;
|
|
50
50
|
createdAt: Date;
|
|
51
|
-
context?: Record<string, unknown> |
|
|
51
|
+
context?: Record<string, unknown> | undefined;
|
|
52
52
|
originalDocument?: unknown;
|
|
53
53
|
updatedDocument?: unknown;
|
|
54
54
|
}, {}, {}> & {
|
|
@@ -57,14 +57,14 @@ export declare function createLogHistorySchema(options: HistoryPluginConfig): im
|
|
|
57
57
|
logs: {
|
|
58
58
|
fieldName: string;
|
|
59
59
|
changeType: "add" | "edit" | "remove";
|
|
60
|
-
fromValue?: string |
|
|
61
|
-
toValue?: string |
|
|
62
|
-
context?: Record<string, unknown> |
|
|
60
|
+
fromValue?: string | undefined;
|
|
61
|
+
toValue?: string | undefined;
|
|
62
|
+
context?: Record<string, unknown> | undefined;
|
|
63
63
|
}[];
|
|
64
64
|
isDeleted: boolean;
|
|
65
65
|
createdBy: string;
|
|
66
66
|
createdAt: Date;
|
|
67
|
-
context?: Record<string, unknown> |
|
|
67
|
+
context?: Record<string, unknown> | undefined;
|
|
68
68
|
originalDocument?: unknown;
|
|
69
69
|
updatedDocument?: unknown;
|
|
70
70
|
} & {
|
|
@@ -77,14 +77,14 @@ export declare function createLogHistorySchema(options: HistoryPluginConfig): im
|
|
|
77
77
|
logs: {
|
|
78
78
|
fieldName: string;
|
|
79
79
|
changeType: "add" | "edit" | "remove";
|
|
80
|
-
fromValue?: string |
|
|
81
|
-
toValue?: string |
|
|
82
|
-
context?: Record<string, unknown> |
|
|
80
|
+
fromValue?: string | undefined;
|
|
81
|
+
toValue?: string | undefined;
|
|
82
|
+
context?: Record<string, unknown> | undefined;
|
|
83
83
|
}[];
|
|
84
84
|
isDeleted: boolean;
|
|
85
85
|
createdBy: string;
|
|
86
86
|
createdAt: Date;
|
|
87
|
-
context?: Record<string, unknown> |
|
|
87
|
+
context?: Record<string, unknown> | undefined;
|
|
88
88
|
originalDocument?: unknown;
|
|
89
89
|
updatedDocument?: unknown;
|
|
90
90
|
}, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
|
|
@@ -93,14 +93,14 @@ export declare function createLogHistorySchema(options: HistoryPluginConfig): im
|
|
|
93
93
|
logs: {
|
|
94
94
|
fieldName: string;
|
|
95
95
|
changeType: "add" | "edit" | "remove";
|
|
96
|
-
fromValue?: string |
|
|
97
|
-
toValue?: string |
|
|
98
|
-
context?: Record<string, unknown> |
|
|
96
|
+
fromValue?: string | undefined;
|
|
97
|
+
toValue?: string | undefined;
|
|
98
|
+
context?: Record<string, unknown> | undefined;
|
|
99
99
|
}[];
|
|
100
100
|
isDeleted: boolean;
|
|
101
101
|
createdBy: string;
|
|
102
102
|
createdAt: Date;
|
|
103
|
-
context?: Record<string, unknown> |
|
|
103
|
+
context?: Record<string, unknown> | undefined;
|
|
104
104
|
originalDocument?: unknown;
|
|
105
105
|
updatedDocument?: unknown;
|
|
106
106
|
}>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<{
|
|
@@ -109,14 +109,14 @@ export declare function createLogHistorySchema(options: HistoryPluginConfig): im
|
|
|
109
109
|
logs: {
|
|
110
110
|
fieldName: string;
|
|
111
111
|
changeType: "add" | "edit" | "remove";
|
|
112
|
-
fromValue?: string |
|
|
113
|
-
toValue?: string |
|
|
114
|
-
context?: Record<string, unknown> |
|
|
112
|
+
fromValue?: string | undefined;
|
|
113
|
+
toValue?: string | undefined;
|
|
114
|
+
context?: Record<string, unknown> | undefined;
|
|
115
115
|
}[];
|
|
116
116
|
isDeleted: boolean;
|
|
117
117
|
createdBy: string;
|
|
118
118
|
createdAt: Date;
|
|
119
|
-
context?: Record<string, unknown> |
|
|
119
|
+
context?: Record<string, unknown> | undefined;
|
|
120
120
|
originalDocument?: unknown;
|
|
121
121
|
updatedDocument?: unknown;
|
|
122
122
|
}> & {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@palmetto/nestjs-log-history",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"main": "./dist/main.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"lint": "yarn run -T eslint --fix ./src",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@palmetto/nestjs-mongoose": "^2.2.6",
|
|
29
29
|
"@palmetto/nestjs-toolbelt": "^1.1.9",
|
|
30
30
|
"@palmetto/nestjs-zod-dto": "^2.0.1",
|
|
31
|
-
"@palmetto/zod-mongoose-schema": "^0.2.
|
|
31
|
+
"@palmetto/zod-mongoose-schema": "^0.2.5",
|
|
32
32
|
"@swc/core": "^1.13.3",
|
|
33
33
|
"@types/node": "^24.2.1",
|
|
34
34
|
"mongodb": "~6.20.0",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"typescript": "5.7.3",
|
|
37
37
|
"unplugin-swc": "^1.5.6",
|
|
38
38
|
"vitest": "^3.2.4",
|
|
39
|
-
"zod": "^4.
|
|
39
|
+
"zod": "^4.1.13"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"@nestjs/common": "^11.1.6",
|
|
@@ -46,10 +46,10 @@
|
|
|
46
46
|
"@palmetto/nestjs-mongoose": "^2.2.6",
|
|
47
47
|
"@palmetto/nestjs-toolbelt": "^1.1.9",
|
|
48
48
|
"@palmetto/nestjs-zod-dto": "^2.0.1",
|
|
49
|
-
"@palmetto/zod-mongoose-schema": "^0.2.
|
|
49
|
+
"@palmetto/zod-mongoose-schema": "^0.2.5",
|
|
50
50
|
"mongodb": "~6.20.0",
|
|
51
51
|
"mongoose": "^8.19.3",
|
|
52
|
-
"zod": "^4.
|
|
52
|
+
"zod": "^4.1.13"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"reflect-metadata": "^0.2.2",
|