@lyxa.ai/core 1.4.218 → 1.4.220
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/libraries/logger-kit/logger.service.d.ts +6 -5
- package/dist/libraries/logger-kit/logger.service.js +21 -40
- package/dist/libraries/logger-kit/logger.service.js.map +1 -1
- package/dist/libraries/logger-kit/types.d.ts +1 -0
- package/dist/libraries/logger-kit/types.js.map +1 -1
- package/dist/libraries/mongo/models/user.model.d.ts +1 -1
- package/dist/libraries/trpc/context.js +1 -0
- package/dist/libraries/trpc/context.js.map +1 -1
- package/dist/libraries/trpc/index.js +0 -1
- package/dist/libraries/trpc/index.js.map +1 -1
- package/dist/libraries/trpc/middlewares/auth.d.ts +1 -1
- package/dist/libraries/trpc/middlewares/createRoleProtectedProcedure.d.ts +1 -1
- package/dist/libraries/trpc/middlewares/phone-verified.d.ts +1 -1
- package/dist/libraries/trpc/middlewares/publicUserDecoder.d.ts +1 -1
- package/dist/types/README.md +1 -1
- package/dist/types/package.json +1 -1
- package/dist/types/utilities/enum.d.ts +3 -2
- package/dist/types/utilities/enum.js +2 -1
- package/dist/types/utilities/enum.js.map +1 -1
- package/dist/types/utilities/validation/common-validation.d.ts +2 -78
- package/dist/types/utilities/validation/global-validation.d.ts +14 -38
- package/dist/utilities/enum.d.ts +3 -2
- package/dist/utilities/enum.js +2 -1
- package/dist/utilities/enum.js.map +1 -1
- package/dist/utilities/error-handler.d.ts +0 -1
- package/dist/utilities/error-handler.js +6 -24
- package/dist/utilities/error-handler.js.map +1 -1
- package/dist/utilities/error-middleware.d.ts +1 -1
- package/dist/utilities/error-middleware.js +75 -173
- package/dist/utilities/error-middleware.js.map +1 -1
- package/dist/utilities/validation/common-validation.d.ts +2 -78
- package/dist/utilities/validation/global-validation.d.ts +14 -38
- package/package.json +1 -1
|
@@ -1,187 +1,89 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
3
|
exports.handleTRPCError = handleTRPCError;
|
|
37
4
|
const server_1 = require("@trpc/server");
|
|
5
|
+
const http_1 = require("@trpc/server/http");
|
|
38
6
|
const error_handler_1 = require("./error-handler");
|
|
39
|
-
const util = __importStar(require("util"));
|
|
40
7
|
const __1 = require("..");
|
|
41
8
|
const enum_1 = require("./enum");
|
|
42
|
-
function
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
logger.error('TRPC Error', error, {
|
|
54
|
-
tag: enum_1.LogTag.SYSTEM_ERROR,
|
|
55
|
-
context: errorContext,
|
|
56
|
-
});
|
|
57
|
-
console.error(error);
|
|
58
|
-
console.error('\n\n');
|
|
59
|
-
console.error('╔═══════════════════════════════════════════════════════════════════╗');
|
|
60
|
-
console.error('║ 🔥 TRPC ERROR 🔥 ║');
|
|
61
|
-
console.error('╚═══════════════════════════════════════════════════════════════════╝');
|
|
62
|
-
console.error('\n📋 Error Context:');
|
|
63
|
-
console.error('┌─────────────────────────────────────────────────────────────────┐');
|
|
64
|
-
console.error(`│ Path: ${errorContext.procedurePath.padEnd(52)} │`);
|
|
65
|
-
console.error(`│ Type: ${errorContext.procedureType.padEnd(52)} │`);
|
|
66
|
-
console.error(`│ Request ID: ${errorContext.requestId.padEnd(51)} │`);
|
|
67
|
-
console.error(`│ Timestamp: ${errorContext.timestamp.padEnd(51)} │`);
|
|
68
|
-
console.error('└─────────────────────────────────────────────────────────────────┘');
|
|
69
|
-
if (error instanceof server_1.TRPCError) {
|
|
70
|
-
console.error('\n🚨 Error Details:');
|
|
71
|
-
console.error('┌─────────────────────────────────────────────────────────────────┐');
|
|
72
|
-
console.error(`│ Code: ${error.code.padEnd(54)} │`);
|
|
73
|
-
console.error('└─────────────────────────────────────────────────────────────────┘');
|
|
74
|
-
if (error.code === 'BAD_REQUEST') {
|
|
75
|
-
try {
|
|
76
|
-
if (error.message.trim().startsWith('[') && error.message.includes('"code"')) {
|
|
77
|
-
const validationErrors = JSON.parse(error.message);
|
|
78
|
-
console.error('\n📋 Validation Errors:');
|
|
79
|
-
validationErrors.forEach((err, index) => {
|
|
80
|
-
const fieldPath = err.path.join('.');
|
|
81
|
-
console.error(`│ ${(index + 1).toString().padStart(2)}. Field: ${fieldPath.padEnd(52)} │`);
|
|
82
|
-
console.error(`│ Error: ${err.message.padEnd(53)} │`);
|
|
83
|
-
console.error(`│ Expected: ${err.expected?.padEnd(50) || 'N/A'.padEnd(50)} │`);
|
|
84
|
-
console.error(`│ Received: ${err.received?.padEnd(50) || 'N/A'.padEnd(50)} │`);
|
|
85
|
-
if (index < validationErrors.length - 1) {
|
|
86
|
-
console.error('│ │');
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
const fieldErrors = validationErrors.map(err => `(${err.path.join('.')}: ${err.message})`);
|
|
90
|
-
error.message = `Validation failed: ${fieldErrors.join(', ')}`;
|
|
91
|
-
console.error('\n📤 Client Response Message:');
|
|
92
|
-
const message = error.message;
|
|
93
|
-
const chunkSize = 65;
|
|
94
|
-
for (let i = 0; i < message.length; i += chunkSize) {
|
|
95
|
-
const chunk = message.substring(i, i + chunkSize);
|
|
96
|
-
console.error(`│ ${chunk.padEnd(65)}`);
|
|
97
|
-
}
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
catch (parseError) {
|
|
102
|
-
console.error('\n⚠️ Error Parsing Validation Error:');
|
|
103
|
-
console.error(`│ ${parseError instanceof Error ? parseError.message.padEnd(65) : String(parseError).padEnd(65)}`);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
console.error('\n📝 Error Message:');
|
|
107
|
-
const message = error.message;
|
|
108
|
-
const chunkSize = 65;
|
|
109
|
-
for (let i = 0; i < message.length; i += chunkSize) {
|
|
110
|
-
const chunk = message.substring(i, i + chunkSize);
|
|
111
|
-
console.error(`│ ${chunk.padEnd(65)}`);
|
|
112
|
-
}
|
|
113
|
-
if (error.cause) {
|
|
114
|
-
console.error('\n🔍 Error Cause:');
|
|
115
|
-
const causeString = util.inspect(error.cause, { depth: 4, colors: true });
|
|
116
|
-
const causeLines = causeString.split('\n');
|
|
117
|
-
causeLines.forEach(line => {
|
|
118
|
-
const plainLine = line.replace(/\x1b\[\d+m/g, '');
|
|
119
|
-
console.error(`│ ${line.padEnd(65 - (line.length - plainLine.length))}`);
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
if (error.stack) {
|
|
123
|
-
console.error('\n📚 Stack Trace:');
|
|
124
|
-
const stackLines = error.stack.split('\n');
|
|
125
|
-
stackLines.forEach(line => {
|
|
126
|
-
if (line.length > 65) {
|
|
127
|
-
for (let i = 0; i < line.length; i += 65) {
|
|
128
|
-
const chunk = line.substring(i, i + 65);
|
|
129
|
-
console.error(`│ ${chunk.padEnd(65)}`);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
console.error(`│ ${line.padEnd(65)}`);
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
else if (error instanceof Error) {
|
|
139
|
-
console.error('\n🚨 Standard Error:');
|
|
140
|
-
console.error('┌─────────────────────────────────────────────────────────────────┐');
|
|
141
|
-
console.error(`│ Name: ${error.name.padEnd(54)} │`);
|
|
142
|
-
console.error(`│ Message: ${error.message.padEnd(54)} │`);
|
|
143
|
-
console.error('└─────────────────────────────────────────────────────────────────┘');
|
|
144
|
-
if (error.stack) {
|
|
145
|
-
console.error('\n📚 Stack Trace:');
|
|
146
|
-
const stackLines = error.stack.split('\n');
|
|
147
|
-
stackLines.forEach(line => {
|
|
148
|
-
if (line.length > 65) {
|
|
149
|
-
for (let i = 0; i < line.length; i += 65) {
|
|
150
|
-
const chunk = line.substring(i, i + 65);
|
|
151
|
-
console.error(`│ ${chunk.padEnd(65)} │`);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
else {
|
|
155
|
-
console.error(`│ ${line.padEnd(65)} │`);
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
}
|
|
9
|
+
function isTRPCError(error) {
|
|
10
|
+
return error instanceof server_1.TRPCError || (error instanceof Error && error.name === 'TRPCError' && 'code' in error);
|
|
11
|
+
}
|
|
12
|
+
function formatValidationError(error) {
|
|
13
|
+
if (!(error.message.trim().startsWith('[') && error.message.includes('"code"')))
|
|
14
|
+
return null;
|
|
15
|
+
try {
|
|
16
|
+
const validationErrors = JSON.parse(error.message);
|
|
17
|
+
const fieldErrors = validationErrors.map(err => `(${err.path.join('.')}: ${err.message})`);
|
|
18
|
+
error.message = `Validation failed: ${fieldErrors.join(', ')}`;
|
|
19
|
+
return validationErrors;
|
|
159
20
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
const errorString = util.inspect(error, { depth: 4, colors: true });
|
|
163
|
-
const errorLines = errorString.split('\n');
|
|
164
|
-
errorLines.forEach(line => {
|
|
165
|
-
const plainLine = line.replace(/\x1b\[\d+m/g, '');
|
|
166
|
-
console.error(`│ ${line.padEnd(65 - (line.length - plainLine.length))}`);
|
|
167
|
-
});
|
|
21
|
+
catch {
|
|
22
|
+
return null;
|
|
168
23
|
}
|
|
24
|
+
}
|
|
25
|
+
const ERROR_PLUMBING = ['error-common', 'error-handler', 'error-middleware', 'logger.service'];
|
|
26
|
+
function getErrorSource(error) {
|
|
27
|
+
const stack = error instanceof Error ? error.stack : undefined;
|
|
28
|
+
if (!stack)
|
|
29
|
+
return undefined;
|
|
30
|
+
const frames = stack.split('\n').slice(1).map(l => l.trim());
|
|
31
|
+
const isNoise = (l) => l.includes('node_modules') || l.includes('node:') || ERROR_PLUMBING.some(f => l.includes(f));
|
|
32
|
+
return (frames.find(l => !isNoise(l)) ?? frames[0])?.trim();
|
|
33
|
+
}
|
|
34
|
+
function resolveInput(input, req) {
|
|
35
|
+
if (input !== undefined && input !== null)
|
|
36
|
+
return input;
|
|
37
|
+
const url = req?.url ?? '';
|
|
38
|
+
if (!url)
|
|
39
|
+
return input;
|
|
169
40
|
try {
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
metaLines.forEach(line => {
|
|
176
|
-
const plainLine = line.replace(/\x1b\[\d+m/g, '');
|
|
177
|
-
console.error(`│ ${line.padEnd(65 - (line.length - plainLine.length))}`);
|
|
178
|
-
});
|
|
179
|
-
}
|
|
41
|
+
const raw = new URL(url, 'http://localhost').searchParams.get('input');
|
|
42
|
+
return raw ? JSON.parse(raw) : input;
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return input;
|
|
180
46
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
47
|
+
}
|
|
48
|
+
function handleTRPCError({ error, type, path, ctx, req, input }) {
|
|
49
|
+
const resolvedInput = resolveInput(input, req);
|
|
50
|
+
const source = getErrorSource(error_handler_1.ErrorHandler.extractErrorMetadata(error).originalError ?? error);
|
|
51
|
+
const startTime = req?._startTime;
|
|
52
|
+
const durationMs = typeof startTime === 'number' ? Date.now() - startTime : undefined;
|
|
53
|
+
const statusCode = isTRPCError(error) ? (0, http_1.getHTTPStatusCodeFromError)(error) : 500;
|
|
54
|
+
const isClientError = statusCode < 500;
|
|
55
|
+
const validationErrors = isTRPCError(error) && error.code === 'BAD_REQUEST' ? formatValidationError(error) : null;
|
|
56
|
+
const logger = (0, __1.getLibraries)().getLoggerKit();
|
|
57
|
+
const logOptions = {
|
|
58
|
+
tag: enum_1.LogTag.SYSTEM_ERROR,
|
|
59
|
+
status: statusCode,
|
|
60
|
+
request: {
|
|
61
|
+
method: req?.method,
|
|
62
|
+
url: req?.url,
|
|
63
|
+
headers: req?.headers,
|
|
64
|
+
},
|
|
65
|
+
data: {
|
|
66
|
+
procedurePath: path ?? 'unknown',
|
|
67
|
+
procedureType: type,
|
|
68
|
+
input: resolvedInput,
|
|
69
|
+
source,
|
|
70
|
+
caller: {
|
|
71
|
+
userType: ctx?.entity?.type,
|
|
72
|
+
ip: req?.headers?.['x-forwarded-for'] ?? req?.socket?.remoteAddress,
|
|
73
|
+
userAgent: req?.headers?.['user-agent'],
|
|
74
|
+
},
|
|
75
|
+
...(durationMs !== undefined && { durationMs }),
|
|
76
|
+
validationErrors,
|
|
77
|
+
},
|
|
78
|
+
metadata: {
|
|
79
|
+
userId: ctx?.entity?.id,
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
if (isClientError) {
|
|
83
|
+
logger.warn('TRPC Error', { ...logOptions, error });
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
logger.error('TRPC Error', error, logOptions);
|
|
184
87
|
}
|
|
185
|
-
console.error('\n\n');
|
|
186
88
|
}
|
|
187
89
|
//# sourceMappingURL=error-middleware.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-middleware.js","sourceRoot":"/","sources":["utilities/error-middleware.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkEA,0CAsMC;AAxQD,yCAAyC;AACzC,mDAA+C;AAC/C,2CAA6B;AAC7B,0BAAkC;AAClC,iCAAgC;AA8DhC,SAAgB,eAAe,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAsB;IAC7E,MAAM,YAAY,GAAG;QACpB,aAAa,EAAE,IAAI,IAAI,SAAS;QAChC,aAAa,EAAE,IAAI;QACnB,SAAS,EAAE,GAAG,EAAE,SAAS,IAAI,SAAS;QACtC,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;KACnC,CAAC;IAGF,MAAM,MAAM,GAAG,IAAA,gBAAY,GAAE,CAAC,YAAY,EAAE,CAAC;IAC7C,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE;QACnB,GAAG,EAAE,aAAM,CAAC,YAAY;KACxB,CAAC,CAAC;IACH,MAAM,CAAC,KAAK,CAAC,YAAY,EAAE,KAAK,EAAE;QACjC,GAAG,EAAE,aAAM,CAAC,YAAY;QACxB,OAAO,EAAE,YAAY;KACrB,CAAC,CAAC;IACH,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAGrB,OAAO,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E;gBAExB,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;gBAClD,OAAO,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC;YAC1E,CAAC,CAAC,CAAC;QACJ,CAAC;IACF,CAAC;IAAC,OAAO,aAAa,EAAE,CAAC;QACxB,OAAO,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAC;QACvD,OAAO,CAAC,KAAK,CACZ,KACC,aAAa,YAAY,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,MAAM,CAAC,EAAE,CACpG,EAAE,CACF,CAAC;IACH,CAAC;IAED,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AACvB,CAAC","sourcesContent":["import { TRPCError } from '@trpc/server';\nimport { ErrorHandler } from './error-handler';\nimport * as util from 'util';\nimport { getLibraries } from '..';\nimport { LogTag } from './enum';\n\n/**\n * Parameters for the tRPC error handler\n * @typedef {Object} ErrorHandlerParams\n * @property {TRPCError|Error|unknown} error - The error object to handle\n * @property {'query'|'mutation'|'subscription'|'unknown'} type - The type of tRPC procedure\n * @property {string|undefined} path - The path of the tRPC procedure\n * @property {Record<string,any>|undefined} ctx - The context of the request\n * @property {any} req - The request object\n * @property {unknown} input - The input parameters for the procedure\n */\ninterface ErrorHandlerParams {\n\terror: TRPCError | Error | unknown;\n\ttype: 'query' | 'mutation' | 'subscription' | 'unknown';\n\tpath: string | undefined;\n\tctx: Record<string, any> | undefined;\n\treq: any;\n\tinput: unknown;\n}\n\n/**\n * Structure of validation errors from zod validation\n * @typedef {Object} ValidationError\n * @property {string} code - The error code (e.g., 'invalid_type')\n * @property {string} expected - The expected type or value\n * @property {string} received - The received type or value\n * @property {(string|number)[]} path - The path to the field with the error\n * @property {string} message - The error message\n */\ninterface ValidationError {\n\tcode: string;\n\texpected: string;\n\treceived: string;\n\tpath: (string | number)[];\n\tmessage: string;\n}\n\n/**\n * Central error handler for tRPC HTTP server.\n *\n * This handler provides comprehensive error logging with structured, formatted output in the console.\n * It specializes in handling validation errors from zod schemas, presenting them in a readable format\n * both for console debugging and client response.\n *\n * Key features:\n * - Beautiful console formatting with box-styled outputs\n * - Special handling for validation errors with field-by-field breakdown\n * - Proper handling of nested error objects and stack traces\n * - Integration with ErrorHandler utility for extracting additional metadata\n * - Client-friendly error message formatting for validation errors\n *\n * @param {ErrorHandlerParams} params - The error handler parameters\n * @param {TRPCError|Error|unknown} params.error - The error that occurred\n * @param {'query'|'mutation'|'subscription'|'unknown'} params.type - Type of tRPC procedure\n * @param {string|undefined} params.path - Path of the tRPC procedure\n * @param {Record<string,any>|undefined} params.ctx - Request context\n * @param {any} params.req - The request object\n * @param {unknown} params.input - The input parameters\n *\n * @returns {void}\n */\nexport function handleTRPCError({ error, type, path, ctx }: ErrorHandlerParams): void {\n\tconst errorContext = {\n\t\tprocedurePath: path ?? 'unknown',\n\t\tprocedureType: type,\n\t\trequestId: ctx?.requestId ?? 'unknown',\n\t\ttimestamp: new Date().toISOString(),\n\t};\n\n\n\tconst logger = getLibraries().getLoggerKit();\n\tlogger.info('Test', {\n\t\ttag: LogTag.HTTP_REQUEST,\n\t});\n\tlogger.error('TRPC Error', error, {\n\t\ttag: LogTag.SYSTEM_ERROR,\n\t\tcontext: errorContext,\n\t});\n\tconsole.error(error);\n\n\t// Print a clear error header with context\n\tconsole.error('\\n\\n');\n\tconsole.error('╔═══════════════════════════════════════════════════════════════════╗');\n\tconsole.error('║ 🔥 TRPC ERROR 🔥 ║');\n\tconsole.error('╚═══════════════════════════════════════════════════════════════════╝');\n\n\t// Print context information in a structured format\n\tconsole.error('\\n📋 Error Context:');\n\tconsole.error('┌─────────────────────────────────────────────────────────────────┐');\n\tconsole.error(`│ Path: ${errorContext.procedurePath.padEnd(52)} │`);\n\tconsole.error(`│ Type: ${errorContext.procedureType.padEnd(52)} │`);\n\tconsole.error(`│ Request ID: ${errorContext.requestId.padEnd(51)} │`);\n\tconsole.error(`│ Timestamp: ${errorContext.timestamp.padEnd(51)} │`);\n\tconsole.error('└─────────────────────────────────────────────────────────────────┘');\n\n\tif (error instanceof TRPCError) {\n\t\t// Print basic error info\n\t\tconsole.error('\\n🚨 Error Details:');\n\t\tconsole.error('┌─────────────────────────────────────────────────────────────────┐');\n\t\tconsole.error(`│ Code: ${error.code.padEnd(54)} │`);\n\t\tconsole.error('└─────────────────────────────────────────────────────────────────┘');\n\n\t\t// Handle validation errors specially\n\t\tif (error.code === 'BAD_REQUEST') {\n\t\t\ttry {\n\t\t\t\tif (error.message.trim().startsWith('[') && error.message.includes('\"code\"')) {\n\t\t\t\t\tconst validationErrors = JSON.parse(error.message) as ValidationError[];\n\n\t\t\t\t\tconsole.error('\\n📋 Validation Errors:');\n\n\t\t\t\t\tvalidationErrors.forEach((err, index) => {\n\t\t\t\t\t\tconst fieldPath = err.path.join('.');\n\t\t\t\t\t\tconsole.error(`│ ${(index + 1).toString().padStart(2)}. Field: ${fieldPath.padEnd(52)} │`);\n\t\t\t\t\t\tconsole.error(`│ Error: ${err.message.padEnd(53)} │`);\n\t\t\t\t\t\tconsole.error(`│ Expected: ${err.expected?.padEnd(50) || 'N/A'.padEnd(50)} │`);\n\t\t\t\t\t\tconsole.error(`│ Received: ${err.received?.padEnd(50) || 'N/A'.padEnd(50)} │`);\n\n\t\t\t\t\t\t// Add a separator between errors, except for the last one\n\t\t\t\t\t\tif (index < validationErrors.length - 1) {\n\t\t\t\t\t\t\tconsole.error('│ │');\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\n\t\t\t\t\t// Format field errors for the client response\n\t\t\t\t\tconst fieldErrors = validationErrors.map(err => `(${err.path.join('.')}: ${err.message})`);\n\n\t\t\t\t\terror.message = `Validation failed: ${fieldErrors.join(', ')}`;\n\n\t\t\t\t\t// Print the formatted client message\n\t\t\t\t\tconsole.error('\\n📤 Client Response Message:');\n\n\t\t\t\t\t// Split the message into multiple lines if it's too long\n\t\t\t\t\tconst message = error.message;\n\t\t\t\t\tconst chunkSize = 65;\n\n\t\t\t\t\tfor (let i = 0; i < message.length; i += chunkSize) {\n\t\t\t\t\t\tconst chunk = message.substring(i, i + chunkSize);\n\t\t\t\t\t\tconsole.error(`│ ${chunk.padEnd(65)}`);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t} catch (parseError) {\n\t\t\t\tconsole.error('\\n⚠️ Error Parsing Validation Error:');\n\t\t\t\tconsole.error(\n\t\t\t\t\t`│ ${parseError instanceof Error ? parseError.message.padEnd(65) : String(parseError).padEnd(65)}`\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t// Print the error message\n\t\tconsole.error('\\n📝 Error Message:');\n\n\t\t// Split the message into multiple lines if it's too long\n\t\tconst message = error.message;\n\t\tconst chunkSize = 65;\n\n\t\tfor (let i = 0; i < message.length; i += chunkSize) {\n\t\t\tconst chunk = message.substring(i, i + chunkSize);\n\t\t\tconsole.error(`│ ${chunk.padEnd(65)}`);\n\t\t}\n\n\t\t// Print the error cause if available\n\t\tif (error.cause) {\n\t\t\tconsole.error('\\n🔍 Error Cause:');\n\n\t\t\t// Use util.inspect to format the cause object nicely\n\t\t\tconst causeString = util.inspect(error.cause, { depth: 4, colors: true });\n\t\t\tconst causeLines = causeString.split('\\n');\n\n\t\t\tcauseLines.forEach(line => {\n\t\t\t\t// Remove ANSI color codes for padding calculation\n\t\t\t\tconst plainLine = line.replace(/\\x1b\\[\\d+m/g, '');\n\t\t\t\tconsole.error(`│ ${line.padEnd(65 - (line.length - plainLine.length))}`);\n\t\t\t});\n\t\t}\n\n\t\t// Print stack trace if available\n\t\tif (error.stack) {\n\t\t\tconsole.error('\\n📚 Stack Trace:');\n\n\t\t\tconst stackLines = error.stack.split('\\n');\n\t\t\tstackLines.forEach(line => {\n\t\t\t\t// Truncate or split long lines\n\t\t\t\tif (line.length > 65) {\n\t\t\t\t\tfor (let i = 0; i < line.length; i += 65) {\n\t\t\t\t\t\tconst chunk = line.substring(i, i + 65);\n\t\t\t\t\t\tconsole.error(`│ ${chunk.padEnd(65)}`);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tconsole.error(`│ ${line.padEnd(65)}`);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t} else if (error instanceof Error) {\n\t\t// Handle standard errors\n\t\tconsole.error('\\n🚨 Standard Error:');\n\t\tconsole.error('┌─────────────────────────────────────────────────────────────────┐');\n\t\tconsole.error(`│ Name: ${error.name.padEnd(54)} │`);\n\t\tconsole.error(`│ Message: ${error.message.padEnd(54)} │`);\n\t\tconsole.error('└─────────────────────────────────────────────────────────────────┘');\n\n\t\t// Print stack trace if available\n\t\tif (error.stack) {\n\t\t\tconsole.error('\\n📚 Stack Trace:');\n\n\t\t\tconst stackLines = error.stack.split('\\n');\n\t\t\tstackLines.forEach(line => {\n\t\t\t\t// Truncate or split long lines\n\t\t\t\tif (line.length > 65) {\n\t\t\t\t\tfor (let i = 0; i < line.length; i += 65) {\n\t\t\t\t\t\tconst chunk = line.substring(i, i + 65);\n\t\t\t\t\t\tconsole.error(`│ ${chunk.padEnd(65)} │`);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tconsole.error(`│ ${line.padEnd(65)} │`);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t} else {\n\t\t// Handle unknown errors\n\t\tconsole.error('\\n❓ Unknown Error:');\n\n\t\tconst errorString = util.inspect(error, { depth: 4, colors: true });\n\t\tconst errorLines = errorString.split('\\n');\n\n\t\terrorLines.forEach(line => {\n\t\t\t// Remove ANSI color codes for padding calculation\n\t\t\tconst plainLine = line.replace(/\\x1b\\[\\d+m/g, '');\n\t\t\tconsole.error(`│ ${line.padEnd(65 - (line.length - plainLine.length))}`);\n\t\t});\n\t}\n\n\t// Use ErrorHandler's methods for additional metadata\n\ttry {\n\t\tconst errorMeta = ErrorHandler.extractErrorMetadata(error);\n\n\t\tif (errorMeta && Object.keys(errorMeta).length > 0) {\n\t\t\tconsole.error('\\n🔬 Additional Error Metadata:');\n\n\t\t\tconst metaString = util.inspect(errorMeta, { depth: 4, colors: true });\n\t\t\tconst metaLines = metaString.split('\\n');\n\n\t\t\tmetaLines.forEach(line => {\n\t\t\t\t// Remove ANSI color codes for padding calculation\n\t\t\t\tconst plainLine = line.replace(/\\x1b\\[\\d+m/g, '');\n\t\t\t\tconsole.error(`│ ${line.padEnd(65 - (line.length - plainLine.length))}`);\n\t\t\t});\n\t\t}\n\t} catch (handlingError) {\n\t\tconsole.error('\\n⚠️ Error While Extracting Metadata:');\n\t\tconsole.error(\n\t\t\t`│ ${\n\t\t\t\thandlingError instanceof Error ? handlingError.message.padEnd(65) : String(handlingError).padEnd(65)\n\t\t\t}`\n\t\t);\n\t}\n\n\tconsole.error('\\n\\n');\n}\n"]}
|
|
1
|
+
{"version":3,"file":"error-middleware.js","sourceRoot":"/","sources":["utilities/error-middleware.ts"],"names":[],"mappings":";;AA4GA,0CA+CC;AA3JD,yCAAyC;AACzC,4CAA+D;AAC/D,mDAA+C;AAC/C,0BAAkC;AAClC,iCAAgC;AA0ChC,SAAS,WAAW,CAAC,KAAc;IAClC,OAAO,KAAK,YAAY,kBAAS,IAAI,CAAC,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW,IAAI,MAAM,IAAI,KAAK,CAAC,CAAC;AAChH,CAAC;AAMD,SAAS,qBAAqB,CAAC,KAAgB;IAC9C,IAAI,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IAE7F,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AACF,CAAC","sourcesContent":["import { TRPCError } from '@trpc/server';\nimport { getHTTPStatusCodeFromError } from '@trpc/server/http';\nimport { ErrorHandler } from './error-handler';\nimport { getLibraries } from '..';\nimport { LogTag } from './enum';\n\n/**\n * Parameters for the tRPC error handler\n * @typedef {Object} ErrorHandlerParams\n * @property {TRPCError|Error|unknown} error - The error object to handle\n * @property {'query'|'mutation'|'subscription'|'unknown'} type - The type of tRPC procedure\n * @property {string|undefined} path - The path of the tRPC procedure\n * @property {Record<string,any>|undefined} ctx - The context of the request\n * @property {any} req - The request object\n * @property {unknown} input - The input parameters for the procedure\n */\ninterface ErrorHandlerParams {\n\terror: TRPCError | Error | unknown;\n\ttype: 'query' | 'mutation' | 'subscription' | 'unknown';\n\tpath: string | undefined;\n\tctx: Record<string, any> | undefined;\n\treq: any;\n\tinput: unknown;\n}\n\n/**\n * Structure of validation errors from zod validation\n * @typedef {Object} ValidationError\n * @property {string} code - The error code (e.g., 'invalid_type')\n * @property {string} expected - The expected type or value\n * @property {string} received - The received type or value\n * @property {(string|number)[]} path - The path to the field with the error\n * @property {string} message - The error message\n */\ninterface ValidationError {\n\tcode: string;\n\texpected: string;\n\treceived: string;\n\tpath: (string | number)[];\n\tmessage: string;\n}\n\n/**\n * Structural check for TRPCError, since `instanceof` can fail when the error\n * crosses a package boundary that resolves a different copy of @trpc/server.\n */\nfunction isTRPCError(error: unknown): error is TRPCError {\n\treturn error instanceof TRPCError || (error instanceof Error && error.name === 'TRPCError' && 'code' in error);\n}\n\n/**\n * Parses a zod field-error message into a client-friendly summary, mutating\n * error.message in place. Returns null if the message isn't a zod validation array.\n */\nfunction formatValidationError(error: TRPCError): ValidationError[] | null {\n\tif (!(error.message.trim().startsWith('[') && error.message.includes('\"code\"'))) return null;\n\n\ttry {\n\t\tconst validationErrors = JSON.parse(error.message) as ValidationError[];\n\t\tconst fieldErrors = validationErrors.map(err => `(${err.path.join('.')}: ${err.message})`);\n\t\terror.message = `Validation failed: ${fieldErrors.join(', ')}`;\n\t\treturn validationErrors;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\n// Frames in these files are error plumbing (factories/handlers), not where the error\n// actually originated, so skip them when picking the source frame.\nconst ERROR_PLUMBING = ['error-common', 'error-handler', 'error-middleware', 'logger.service'];\n\n/**\n * Returns the first stack frame originating from real business code, skipping node\n * internals, node_modules, and our own error-construction helpers, so logs point at\n * the actual call site instead of the error factory (e.g. unauthorizedError()).\n */\nfunction getErrorSource(error: unknown): string | undefined {\n\tconst stack = error instanceof Error ? error.stack : undefined;\n\tif (!stack) return undefined;\n\tconst frames = stack.split('\\n').slice(1).map(l => l.trim());\n\tconst isNoise = (l: string) =>\n\t\tl.includes('node_modules') || l.includes('node:') || ERROR_PLUMBING.some(f => l.includes(f));\n\treturn (frames.find(l => !isNoise(l)) ?? frames[0])?.trim();\n}\n\n/**\n * tRPC passes parsed `input` for mutations, but for GET queries the args live in the\n * URL `input` query param. Fall back to parsing the URL so params are always captured.\n */\nfunction resolveInput(input: unknown, req: any): unknown {\n\tif (input !== undefined && input !== null) return input;\n\tconst url: string = req?.url ?? '';\n\tif (!url) return input;\n\ttry {\n\t\tconst raw = new URL(url, 'http://localhost').searchParams.get('input');\n\t\treturn raw ? JSON.parse(raw) : input;\n\t} catch {\n\t\treturn input;\n\t}\n}\n\n/**\n * Central error handler for tRPC HTTP server. Logs structured error data via the\n * logger, plus a readable dump to the console for local debugging.\n *\n * @param {ErrorHandlerParams} params - The error handler parameters\n * @returns {void}\n */\nexport function handleTRPCError({ error, type, path, ctx, req, input }: ErrorHandlerParams): void {\n\tconst resolvedInput = resolveInput(input, req);\n\tconst source = getErrorSource(ErrorHandler.extractErrorMetadata(error).originalError ?? error);\n\t// _startTime is set on req at context creation; absent for requests that fail before context.\n\tconst startTime = (req as any)?._startTime;\n\tconst durationMs = typeof startTime === 'number' ? Date.now() - startTime : undefined;\n\n\tconst statusCode = isTRPCError(error) ? getHTTPStatusCodeFromError(error) : 500;\n\tconst isClientError = statusCode < 500;\n\n\tconst validationErrors = isTRPCError(error) && error.code === 'BAD_REQUEST' ? formatValidationError(error) : null;\n\n\tconst logger = getLibraries().getLoggerKit();\n\t// Each field has a single home to avoid duplicate copies in the persisted document:\n\t// `data` is the human-facing summary (also what prints to the terminal), `request` is\n\t// pure HTTP transport, `metadata.userId` is the indexed/filterable field.\n\tconst logOptions = {\n\t\ttag: LogTag.SYSTEM_ERROR,\n\t\tstatus: statusCode,\n\t\trequest: {\n\t\t\tmethod: req?.method,\n\t\t\turl: req?.url,\n\t\t\theaders: req?.headers,\n\t\t},\n\t\tdata: {\n\t\t\tprocedurePath: path ?? 'unknown',\n\t\t\tprocedureType: type,\n\t\t\tinput: resolvedInput,\n\t\t\tsource,\n\t\t\tcaller: {\n\t\t\t\tuserType: ctx?.entity?.type,\n\t\t\t\tip: (req?.headers?.['x-forwarded-for'] as string) ?? req?.socket?.remoteAddress,\n\t\t\t\tuserAgent: req?.headers?.['user-agent'],\n\t\t\t},\n\t\t\t...(durationMs !== undefined && { durationMs }),\n\t\t\tvalidationErrors,\n\t\t},\n\t\tmetadata: {\n\t\t\tuserId: ctx?.entity?.id,\n\t\t},\n\t};\n\n\tif (isClientError) {\n\t\tlogger.warn('TRPC Error', { ...logOptions, error });\n\t} else {\n\t\tlogger.error('TRPC Error', error, logOptions);\n\t}\n}\n"]}
|
|
@@ -648,7 +648,7 @@ export declare const createResponseSchema: <T>(schema: z.ZodSchema<T>) => z.ZodO
|
|
|
648
648
|
totalPages: number;
|
|
649
649
|
} | undefined;
|
|
650
650
|
}>, z.ZodType<T, z.ZodTypeDef, T>]>>;
|
|
651
|
-
}>, any> extends infer T_1 ? { [k in keyof T_1]: z.
|
|
651
|
+
}>, any> extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never, z.baseObjectInputType<{
|
|
652
652
|
success: z.ZodBoolean;
|
|
653
653
|
message: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
|
654
654
|
data: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
|
|
@@ -686,83 +686,7 @@ export declare const createResponseSchema: <T>(schema: z.ZodSchema<T>) => z.ZodO
|
|
|
686
686
|
totalPages: number;
|
|
687
687
|
} | undefined;
|
|
688
688
|
}>, z.ZodType<T, z.ZodTypeDef, T>]>>;
|
|
689
|
-
}
|
|
690
|
-
success: z.ZodBoolean;
|
|
691
|
-
message: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
|
692
|
-
data: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
|
|
693
|
-
metadata: z.ZodOptional<z.ZodObject<{
|
|
694
|
-
page: z.ZodNumber;
|
|
695
|
-
size: z.ZodNumber;
|
|
696
|
-
totalElements: z.ZodNumber;
|
|
697
|
-
totalPages: z.ZodNumber;
|
|
698
|
-
}, "strip", z.ZodTypeAny, {
|
|
699
|
-
page: number;
|
|
700
|
-
size: number;
|
|
701
|
-
totalElements: number;
|
|
702
|
-
totalPages: number;
|
|
703
|
-
}, {
|
|
704
|
-
page: number;
|
|
705
|
-
size: number;
|
|
706
|
-
totalElements: number;
|
|
707
|
-
totalPages: number;
|
|
708
|
-
}>>;
|
|
709
|
-
documents: z.ZodArray<z.ZodType<T, z.ZodTypeDef, T>, "many">;
|
|
710
|
-
}, "strip", z.ZodTypeAny, {
|
|
711
|
-
documents: T[];
|
|
712
|
-
metadata?: {
|
|
713
|
-
page: number;
|
|
714
|
-
size: number;
|
|
715
|
-
totalElements: number;
|
|
716
|
-
totalPages: number;
|
|
717
|
-
} | undefined;
|
|
718
|
-
}, {
|
|
719
|
-
documents: T[];
|
|
720
|
-
metadata?: {
|
|
721
|
-
page: number;
|
|
722
|
-
size: number;
|
|
723
|
-
totalElements: number;
|
|
724
|
-
totalPages: number;
|
|
725
|
-
} | undefined;
|
|
726
|
-
}>, z.ZodType<T, z.ZodTypeDef, T>]>>;
|
|
727
|
-
}> extends infer T_2 ? { [k_1 in keyof T_2]: z.baseObjectInputType<{
|
|
728
|
-
success: z.ZodBoolean;
|
|
729
|
-
message: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
|
730
|
-
data: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
|
|
731
|
-
metadata: z.ZodOptional<z.ZodObject<{
|
|
732
|
-
page: z.ZodNumber;
|
|
733
|
-
size: z.ZodNumber;
|
|
734
|
-
totalElements: z.ZodNumber;
|
|
735
|
-
totalPages: z.ZodNumber;
|
|
736
|
-
}, "strip", z.ZodTypeAny, {
|
|
737
|
-
page: number;
|
|
738
|
-
size: number;
|
|
739
|
-
totalElements: number;
|
|
740
|
-
totalPages: number;
|
|
741
|
-
}, {
|
|
742
|
-
page: number;
|
|
743
|
-
size: number;
|
|
744
|
-
totalElements: number;
|
|
745
|
-
totalPages: number;
|
|
746
|
-
}>>;
|
|
747
|
-
documents: z.ZodArray<z.ZodType<T, z.ZodTypeDef, T>, "many">;
|
|
748
|
-
}, "strip", z.ZodTypeAny, {
|
|
749
|
-
documents: T[];
|
|
750
|
-
metadata?: {
|
|
751
|
-
page: number;
|
|
752
|
-
size: number;
|
|
753
|
-
totalElements: number;
|
|
754
|
-
totalPages: number;
|
|
755
|
-
} | undefined;
|
|
756
|
-
}, {
|
|
757
|
-
documents: T[];
|
|
758
|
-
metadata?: {
|
|
759
|
-
page: number;
|
|
760
|
-
size: number;
|
|
761
|
-
totalElements: number;
|
|
762
|
-
totalPages: number;
|
|
763
|
-
} | undefined;
|
|
764
|
-
}>, z.ZodType<T, z.ZodTypeDef, T>]>>;
|
|
765
|
-
}>[k_1]; } : never>;
|
|
689
|
+
}> extends infer T_2 ? { [k_1 in keyof T_2]: T_2[k_1]; } : never>;
|
|
766
690
|
export type PaginatedDTO<T> = {
|
|
767
691
|
metadata: DTO<typeof metadataSchema>;
|
|
768
692
|
documents: T[];
|
|
@@ -76,34 +76,22 @@ export declare class SchemaBuilder<T extends z.ZodRawShape> {
|
|
|
76
76
|
private baseSchema;
|
|
77
77
|
constructor(baseFields: T, includeTimestamps?: boolean, includeTracking?: boolean);
|
|
78
78
|
private createBaseSchema;
|
|
79
|
-
getBaseSchema(): z.ZodObject<T, "strict", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any> extends infer T_1 ? { [k in keyof T_1]:
|
|
79
|
+
getBaseSchema(): z.ZodObject<T, "strict", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any> extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never, z.baseObjectInputType<T> extends infer T_2 ? { [k_1 in keyof T_2]: T_2[k_1]; } : never>;
|
|
80
80
|
getEntitySchema(): z.ZodObject<z.objectUtil.extendShape<T, {
|
|
81
81
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
82
|
-
}> extends infer T_1 extends z.ZodRawShape ? { [k in keyof T_1]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
82
|
+
}> extends infer T_1 extends z.ZodRawShape ? { [k in keyof T_1]: z.ZodOptional<T_1[k]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
|
|
83
83
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
84
|
-
}>[k]>; } : never,
|
|
84
|
+
}> extends infer T_2 extends z.ZodRawShape ? { [k in keyof T_2]: z.ZodOptional<T_2[k]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
|
|
85
85
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
86
|
-
}> extends infer
|
|
87
|
-
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
88
|
-
}>[k]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
|
|
89
|
-
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
90
|
-
}> extends infer T_3 extends z.ZodRawShape ? { [k in keyof T_3]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
91
|
-
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
92
|
-
}>[k]>; } : never, z.ZodTypeAny, "passthrough">>;
|
|
86
|
+
}> extends infer T_3 extends z.ZodRawShape ? { [k in keyof T_3]: z.ZodOptional<T_3[k]>; } : never, z.ZodTypeAny, "passthrough">>;
|
|
93
87
|
getIdSchema(): z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
94
88
|
getUpdateSchema(excludeFields?: ExcludeFromUpdate): z.ZodObject<z.objectUtil.extendShape<T, {
|
|
95
89
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
96
|
-
}> extends infer T_1 extends z.ZodRawShape ? { [k in keyof T_1]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
97
|
-
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
98
|
-
}>[k]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
|
|
99
|
-
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
100
|
-
}> extends infer T_2 extends z.ZodRawShape ? { [k in keyof T_2]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
101
|
-
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
102
|
-
}>[k]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
|
|
90
|
+
}> extends infer T_1 extends z.ZodRawShape ? { [k in keyof T_1]: z.ZodOptional<T_1[k]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
|
|
103
91
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
104
|
-
}> extends infer
|
|
92
|
+
}> extends infer T_2 extends z.ZodRawShape ? { [k in keyof T_2]: z.ZodOptional<T_2[k]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
|
|
105
93
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
106
|
-
}>[k]>; } : never, z.ZodTypeAny, "passthrough">> | z.ZodObject<{
|
|
94
|
+
}> extends infer T_3 extends z.ZodRawShape ? { [k in keyof T_3]: z.ZodOptional<T_3[k]>; } : never, z.ZodTypeAny, "passthrough">> | z.ZodObject<{
|
|
107
95
|
[x: string]: z.ZodOptional<z.ZodTypeAny>;
|
|
108
96
|
}, "strict", z.ZodTypeAny, {
|
|
109
97
|
[x: string]: any;
|
|
@@ -126,34 +114,22 @@ export declare class SchemaBuilder<T extends z.ZodRawShape> {
|
|
|
126
114
|
[x: string]: any;
|
|
127
115
|
}>;
|
|
128
116
|
getAllSchemas(excludeFromUpdate?: ExcludeFromUpdate): {
|
|
129
|
-
BaseSchema: z.ZodObject<T, "strict", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any> extends infer T_1 ? { [k in keyof T_1]:
|
|
117
|
+
BaseSchema: z.ZodObject<T, "strict", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any> extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never, z.baseObjectInputType<T> extends infer T_2 ? { [k_1 in keyof T_2]: T_2[k_1]; } : never>;
|
|
130
118
|
EntitySchema: z.ZodObject<z.objectUtil.extendShape<T, {
|
|
131
119
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
132
|
-
}> extends infer T_3 extends z.ZodRawShape ? { [k_2 in keyof T_3]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
120
|
+
}> extends infer T_3 extends z.ZodRawShape ? { [k_2 in keyof T_3]: z.ZodOptional<T_3[k_2]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
|
|
133
121
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
134
|
-
}>[k_2]>; } : never,
|
|
122
|
+
}> extends infer T_4 extends z.ZodRawShape ? { [k_2 in keyof T_4]: z.ZodOptional<T_4[k_2]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
|
|
135
123
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
136
|
-
}> extends infer
|
|
137
|
-
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
138
|
-
}>[k_2]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
|
|
139
|
-
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
140
|
-
}> extends infer T_5 extends z.ZodRawShape ? { [k_2 in keyof T_5]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
141
|
-
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
142
|
-
}>[k_2]>; } : never, z.ZodTypeAny, "passthrough">>;
|
|
124
|
+
}> extends infer T_5 extends z.ZodRawShape ? { [k_2 in keyof T_5]: z.ZodOptional<T_5[k_2]>; } : never, z.ZodTypeAny, "passthrough">>;
|
|
143
125
|
IdSchema: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
144
126
|
UpdateSchema: z.ZodObject<z.objectUtil.extendShape<T, {
|
|
145
127
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
146
|
-
}> extends infer T_6 extends z.ZodRawShape ? { [k_2 in keyof T_6]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
147
|
-
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
148
|
-
}>[k_2]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
|
|
149
|
-
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
150
|
-
}> extends infer T_7 extends z.ZodRawShape ? { [k_2 in keyof T_7]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
151
|
-
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
152
|
-
}>[k_2]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
|
|
128
|
+
}> extends infer T_6 extends z.ZodRawShape ? { [k_2 in keyof T_6]: z.ZodOptional<T_6[k_2]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
|
|
153
129
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
154
|
-
}> extends infer
|
|
130
|
+
}> extends infer T_7 extends z.ZodRawShape ? { [k_2 in keyof T_7]: z.ZodOptional<T_7[k_2]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
|
|
155
131
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
156
|
-
}>[k_2]>; } : never, z.ZodTypeAny, "passthrough">> | z.ZodObject<{
|
|
132
|
+
}> extends infer T_8 extends z.ZodRawShape ? { [k_2 in keyof T_8]: z.ZodOptional<T_8[k_2]>; } : never, z.ZodTypeAny, "passthrough">> | z.ZodObject<{
|
|
157
133
|
[x: string]: z.ZodOptional<z.ZodTypeAny>;
|
|
158
134
|
}, "strict", z.ZodTypeAny, {
|
|
159
135
|
[x: string]: any;
|