@vritti/api-sdk 0.3.2 → 0.3.5

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 (145) hide show
  1. package/dist/auth.cjs +942 -0
  2. package/dist/auth.cjs.map +1 -0
  3. package/dist/auth.d.cts +95 -0
  4. package/dist/auth.d.ts +95 -0
  5. package/dist/auth.js +884 -0
  6. package/dist/auth.js.map +1 -0
  7. package/dist/cache.cjs +182 -14
  8. package/dist/cache.cjs.map +1 -1
  9. package/dist/cache.d.cts +48 -4
  10. package/dist/cache.d.ts +48 -4
  11. package/dist/cache.js +177 -12
  12. package/dist/cache.js.map +1 -1
  13. package/dist/catalog-resolver.cjs +226 -51
  14. package/dist/catalog-resolver.cjs.map +1 -1
  15. package/dist/catalog-resolver.d.cts +41 -19
  16. package/dist/catalog-resolver.d.ts +41 -19
  17. package/dist/catalog-resolver.js +212 -46
  18. package/dist/catalog-resolver.js.map +1 -1
  19. package/dist/code-pattern-BP4zkNtT.d.cts +12 -0
  20. package/dist/code-pattern-BP4zkNtT.d.ts +12 -0
  21. package/dist/context.cjs +93 -0
  22. package/dist/context.cjs.map +1 -0
  23. package/dist/context.d.cts +19 -0
  24. package/dist/context.d.ts +19 -0
  25. package/dist/context.js +64 -0
  26. package/dist/context.js.map +1 -0
  27. package/dist/countries.cjs +1559 -0
  28. package/dist/countries.cjs.map +1 -0
  29. package/dist/countries.d.cts +13 -0
  30. package/dist/countries.d.ts +13 -0
  31. package/dist/countries.js +1532 -0
  32. package/dist/countries.js.map +1 -0
  33. package/dist/data-table.cjs +1280 -0
  34. package/dist/data-table.cjs.map +1 -0
  35. package/dist/data-table.d.cts +123 -0
  36. package/dist/data-table.d.ts +123 -0
  37. package/dist/data-table.js +1260 -0
  38. package/dist/data-table.js.map +1 -0
  39. package/dist/database.cjs +1510 -0
  40. package/dist/database.cjs.map +1 -0
  41. package/dist/database.d.cts +287 -0
  42. package/dist/database.d.ts +287 -0
  43. package/dist/database.js +1469 -0
  44. package/dist/database.js.map +1 -0
  45. package/dist/decimal.d.cts +0 -1
  46. package/dist/decimal.d.ts +0 -1
  47. package/dist/decorators.cjs +1817 -0
  48. package/dist/decorators.cjs.map +1 -0
  49. package/dist/decorators.d.cts +24 -0
  50. package/dist/decorators.d.ts +24 -0
  51. package/dist/decorators.js +1780 -0
  52. package/dist/decorators.js.map +1 -0
  53. package/dist/document-BoS0NIbf.d.cts +12 -0
  54. package/dist/document-BoS0NIbf.d.ts +12 -0
  55. package/dist/drizzle-pg-core.cjs +25 -0
  56. package/dist/drizzle-pg-core.cjs.map +1 -1
  57. package/dist/drizzle-pg-core.d.cts +7 -0
  58. package/dist/drizzle-pg-core.d.ts +7 -0
  59. package/dist/drizzle-pg-core.js +22 -0
  60. package/dist/drizzle-pg-core.js.map +1 -1
  61. package/dist/exceptions.cjs +301 -0
  62. package/dist/exceptions.cjs.map +1 -0
  63. package/dist/exceptions.d.cts +90 -0
  64. package/dist/exceptions.d.ts +90 -0
  65. package/dist/exceptions.js +257 -0
  66. package/dist/exceptions.js.map +1 -0
  67. package/dist/filter.types-PuARU9XD.d.cts +50 -0
  68. package/dist/filter.types-PuARU9XD.d.ts +50 -0
  69. package/dist/filters.cjs +407 -0
  70. package/dist/filters.cjs.map +1 -0
  71. package/dist/filters.d.cts +55 -0
  72. package/dist/filters.d.ts +55 -0
  73. package/dist/filters.js +377 -0
  74. package/dist/filters.js.map +1 -0
  75. package/dist/index.cjs +0 -5423
  76. package/dist/index.cjs.map +1 -1
  77. package/dist/index.d.cts +93 -854
  78. package/dist/index.d.ts +93 -854
  79. package/dist/index.js +0 -5301
  80. package/dist/index.js.map +1 -1
  81. package/dist/is-country.decorator-CcNwSSr5.d.cts +5 -0
  82. package/dist/is-country.decorator-CcNwSSr5.d.ts +5 -0
  83. package/dist/license.cjs +9 -56
  84. package/dist/license.cjs.map +1 -1
  85. package/dist/license.d.cts +3 -14
  86. package/dist/license.d.ts +3 -14
  87. package/dist/license.js +8 -51
  88. package/dist/license.js.map +1 -1
  89. package/dist/lodash.cjs.map +1 -1
  90. package/dist/lodash.js.map +1 -1
  91. package/dist/logger.cjs +862 -0
  92. package/dist/logger.cjs.map +1 -0
  93. package/dist/logger.d.cts +118 -0
  94. package/dist/logger.d.ts +118 -0
  95. package/dist/logger.js +816 -0
  96. package/dist/logger.js.map +1 -0
  97. package/dist/migrate.cjs +2 -2
  98. package/dist/migrate.cjs.map +1 -1
  99. package/dist/migrate.d.cts +2 -0
  100. package/dist/migrate.d.ts +2 -0
  101. package/dist/migrate.js +2 -2
  102. package/dist/migrate.js.map +1 -1
  103. package/dist/money.cjs +18 -3
  104. package/dist/money.cjs.map +1 -1
  105. package/dist/money.d.cts +13 -13
  106. package/dist/money.d.ts +13 -13
  107. package/dist/money.js +18 -3
  108. package/dist/money.js.map +1 -1
  109. package/dist/nats.cjs +34 -35
  110. package/dist/nats.cjs.map +1 -1
  111. package/dist/nats.d.cts +14 -14
  112. package/dist/nats.d.ts +14 -14
  113. package/dist/nats.js +32 -33
  114. package/dist/nats.js.map +1 -1
  115. package/dist/root.cjs +225 -0
  116. package/dist/root.cjs.map +1 -0
  117. package/dist/root.d.cts +4 -0
  118. package/dist/root.d.ts +4 -0
  119. package/dist/root.js +200 -0
  120. package/dist/root.js.map +1 -0
  121. package/dist/signing.cjs +159 -0
  122. package/dist/signing.cjs.map +1 -0
  123. package/dist/signing.d.cts +35 -0
  124. package/dist/signing.d.ts +35 -0
  125. package/dist/signing.js +128 -0
  126. package/dist/signing.js.map +1 -0
  127. package/dist/{types-DQRwj5rr.d.cts → types-C9jPdQqH.d.cts} +32 -6
  128. package/dist/{types-DQRwj5rr.d.ts → types-C9jPdQqH.d.ts} +32 -6
  129. package/dist/types.cjs +19 -0
  130. package/dist/types.cjs.map +1 -0
  131. package/dist/types.d.cts +17 -0
  132. package/dist/types.d.ts +17 -0
  133. package/dist/types.js +1 -0
  134. package/dist/types.js.map +1 -0
  135. package/dist/utils.cjs +273 -0
  136. package/dist/utils.cjs.map +1 -0
  137. package/dist/utils.d.cts +8 -0
  138. package/dist/utils.d.ts +8 -0
  139. package/dist/utils.js +245 -0
  140. package/dist/utils.js.map +1 -0
  141. package/package.json +132 -1
  142. package/dist/cache.service-_SuJIcNA.d.cts +0 -20
  143. package/dist/cache.service-_SuJIcNA.d.ts +0 -20
  144. package/dist/fastify-augmentation-CQPBNS5a.d.cts +0 -105
  145. package/dist/fastify-augmentation-CQPBNS5a.d.ts +0 -105
@@ -0,0 +1,377 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ // src/filters/error-code.ts
5
+ import { HttpStatus } from "@nestjs/common";
6
+ var ErrorCode = /* @__PURE__ */ (function(ErrorCode2) {
7
+ ErrorCode2["UNAUTHENTICATED"] = "UNAUTHENTICATED";
8
+ ErrorCode2["FORBIDDEN"] = "FORBIDDEN";
9
+ ErrorCode2["NOT_FOUND"] = "NOT_FOUND";
10
+ ErrorCode2["VALIDATION_FAILED"] = "VALIDATION_FAILED";
11
+ ErrorCode2["CONFLICT"] = "CONFLICT";
12
+ ErrorCode2["RATE_LIMITED"] = "RATE_LIMITED";
13
+ ErrorCode2["BAD_REQUEST"] = "BAD_REQUEST";
14
+ ErrorCode2["INTERNAL"] = "INTERNAL";
15
+ return ErrorCode2;
16
+ })({});
17
+ function errorCodeFromStatus(status) {
18
+ switch (status) {
19
+ case HttpStatus.UNAUTHORIZED:
20
+ return "UNAUTHENTICATED";
21
+ case HttpStatus.FORBIDDEN:
22
+ return "FORBIDDEN";
23
+ case HttpStatus.NOT_FOUND:
24
+ return "NOT_FOUND";
25
+ case HttpStatus.BAD_REQUEST:
26
+ case HttpStatus.UNPROCESSABLE_ENTITY:
27
+ return "VALIDATION_FAILED";
28
+ case HttpStatus.CONFLICT:
29
+ return "CONFLICT";
30
+ case HttpStatus.TOO_MANY_REQUESTS:
31
+ return "RATE_LIMITED";
32
+ default:
33
+ if (status >= 400 && status < 500) {
34
+ return "BAD_REQUEST";
35
+ }
36
+ return "INTERNAL";
37
+ }
38
+ }
39
+ __name(errorCodeFromStatus, "errorCodeFromStatus");
40
+
41
+ // src/filters/problem-extraction.ts
42
+ import { HttpStatus as HttpStatus2 } from "@nestjs/common";
43
+ function getHttpStatusTitle(status) {
44
+ const enumKey = Object.entries(HttpStatus2).find(([key, value]) => value === status && Number.isNaN(Number(key)))?.[0];
45
+ if (!enumKey) {
46
+ return "Error";
47
+ }
48
+ return enumKey.split("_").map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(" ");
49
+ }
50
+ __name(getHttpStatusTitle, "getHttpStatusTitle");
51
+ function extractValidationFieldErrors(message) {
52
+ return message.map((msg) => {
53
+ if (typeof msg === "object" && "property" in msg && "constraints" in msg) {
54
+ const constraintValues = Object.values(msg.constraints);
55
+ return {
56
+ field: msg.property,
57
+ message: constraintValues[0] ?? "Validation failed"
58
+ };
59
+ }
60
+ return null;
61
+ }).filter((error) => error !== null);
62
+ }
63
+ __name(extractValidationFieldErrors, "extractValidationFieldErrors");
64
+ function extractProblemFromResponse(exceptionResponse, problemFallbackDetail) {
65
+ let type = "about:blank";
66
+ let label;
67
+ let detail;
68
+ let errors = [];
69
+ if (typeof exceptionResponse === "string") {
70
+ detail = exceptionResponse;
71
+ return {
72
+ type,
73
+ label,
74
+ detail,
75
+ errors
76
+ };
77
+ }
78
+ if (exceptionResponse !== null && typeof exceptionResponse === "object") {
79
+ const responseObj = exceptionResponse;
80
+ if ("type" in responseObj || "label" in responseObj || "errors" in responseObj) {
81
+ const problemResponse = responseObj;
82
+ type = problemResponse.type ?? "about:blank";
83
+ label = problemResponse.label;
84
+ detail = problemResponse.detail ?? problemFallbackDetail;
85
+ errors = problemResponse.errors ?? [];
86
+ } else if ("message" in responseObj && Array.isArray(responseObj.message)) {
87
+ errors = extractValidationFieldErrors(responseObj.message);
88
+ detail = "Validation failed";
89
+ } else if ("message" in responseObj) {
90
+ const message = responseObj.message;
91
+ detail = Array.isArray(message) ? message.join(", ") : message;
92
+ }
93
+ }
94
+ return {
95
+ type,
96
+ label,
97
+ detail,
98
+ errors
99
+ };
100
+ }
101
+ __name(extractProblemFromResponse, "extractProblemFromResponse");
102
+
103
+ // src/filters/graphql-format-error.ts
104
+ function isHttpExceptionLike(error) {
105
+ return error instanceof Error && typeof error.getStatus === "function" && typeof error.getResponse === "function";
106
+ }
107
+ __name(isHttpExceptionLike, "isHttpExceptionLike");
108
+ function isProblemLike(error) {
109
+ if (error == null || typeof error !== "object") {
110
+ return false;
111
+ }
112
+ const o = error;
113
+ return typeof o.status === "number" || typeof o.statusCode === "number";
114
+ }
115
+ __name(isProblemLike, "isProblemLike");
116
+ function findProblemSource(error) {
117
+ let current = error;
118
+ for (let depth = 0; current && depth < 10; depth++) {
119
+ if (isHttpExceptionLike(current)) {
120
+ const status = current.getStatus();
121
+ return {
122
+ status,
123
+ response: current.getResponse(),
124
+ fallback: current.message ?? getHttpStatusTitle(status)
125
+ };
126
+ }
127
+ if (isProblemLike(current)) {
128
+ const status = current.status ?? current.statusCode ?? 500;
129
+ return {
130
+ status,
131
+ response: current,
132
+ fallback: current.detail ?? current.message ?? getHttpStatusTitle(status)
133
+ };
134
+ }
135
+ const next = current;
136
+ current = next.originalError ?? next.thrownValue;
137
+ }
138
+ return void 0;
139
+ }
140
+ __name(findProblemSource, "findProblemSource");
141
+ var GENERIC_INTERNAL_MESSAGE = "Internal server error";
142
+ function createGraphqlFormatError(opts) {
143
+ const { isProduction, getTraceId } = opts;
144
+ return (formattedError, error) => {
145
+ const gqlError = error ?? void 0;
146
+ const source = findProblemSource(gqlError);
147
+ let status = 500;
148
+ let detail;
149
+ let label;
150
+ let fieldErrors = [];
151
+ if (source) {
152
+ status = source.status;
153
+ const extracted = extractProblemFromResponse(source.response, source.fallback);
154
+ detail = extracted.detail;
155
+ label = extracted.label;
156
+ fieldErrors = extracted.errors;
157
+ }
158
+ const code = errorCodeFromStatus(status);
159
+ let message = detail ?? formattedError.message;
160
+ if (code === "INTERNAL" && isProduction) {
161
+ message = GENERIC_INTERNAL_MESSAGE;
162
+ }
163
+ const incoming = {
164
+ ...formattedError.extensions ?? {}
165
+ };
166
+ const traceId = getTraceId?.();
167
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString();
168
+ const extensions = {
169
+ ...incoming,
170
+ // Always our canonical code — overrides Apollo's default INTERNAL_SERVER_ERROR.
171
+ code,
172
+ ...traceId !== void 0 ? {
173
+ traceId
174
+ } : {},
175
+ timestamp,
176
+ ...label !== void 0 ? {
177
+ label
178
+ } : {},
179
+ ...fieldErrors.length > 0 ? {
180
+ fieldErrors
181
+ } : {}
182
+ };
183
+ if (isProduction) {
184
+ delete extensions.stacktrace;
185
+ delete extensions.exception;
186
+ delete extensions.originalError;
187
+ }
188
+ const result = {
189
+ message,
190
+ extensions
191
+ };
192
+ if (formattedError.locations) result.locations = formattedError.locations;
193
+ if (formattedError.path) result.path = formattedError.path;
194
+ return result;
195
+ };
196
+ }
197
+ __name(createGraphqlFormatError, "createGraphqlFormatError");
198
+
199
+ // src/filters/http-exception.filter.ts
200
+ import { Catch, HttpStatus as HttpStatus4, Logger } from "@nestjs/common";
201
+
202
+ // src/exceptions/conflict.exception.ts
203
+ import { HttpStatus as HttpStatus3 } from "@nestjs/common";
204
+
205
+ // src/exceptions/base-field.exception.ts
206
+ import { HttpException } from "@nestjs/common";
207
+ var HttpProblemException = class extends HttpException {
208
+ static {
209
+ __name(this, "HttpProblemException");
210
+ }
211
+ constructor(detailOrOptions, httpStatus) {
212
+ const options = typeof detailOrOptions === "string" ? {
213
+ detail: detailOrOptions
214
+ } : detailOrOptions;
215
+ super({
216
+ type: options.type ?? "about:blank",
217
+ label: options.label,
218
+ detail: options.detail,
219
+ errors: options.errors ?? []
220
+ }, httpStatus);
221
+ }
222
+ };
223
+
224
+ // src/exceptions/conflict.exception.ts
225
+ var ConflictException = class extends HttpProblemException {
226
+ static {
227
+ __name(this, "ConflictException");
228
+ }
229
+ constructor(detailOrOptions) {
230
+ super(detailOrOptions ?? "Conflict", HttpStatus3.CONFLICT);
231
+ }
232
+ };
233
+
234
+ // src/filters/pg-error.translator.ts
235
+ var PG_UNIQUE_VIOLATION = "23505";
236
+ function tryTranslatePgError(error) {
237
+ const pgError = findPgError(error);
238
+ if (!pgError) return void 0;
239
+ const { code, constraint, table, detail } = pgError;
240
+ if (code !== PG_UNIQUE_VIOLATION) return void 0;
241
+ return new ConflictException({
242
+ label: "Duplicate Entry",
243
+ detail: detail?.trim() || "A record with these values already exists.",
244
+ errors: [],
245
+ ...constraint || table ? {
246
+ meta: {
247
+ constraint,
248
+ table
249
+ }
250
+ } : {}
251
+ });
252
+ }
253
+ __name(tryTranslatePgError, "tryTranslatePgError");
254
+ function findPgError(error, depth = 0) {
255
+ if (!error || typeof error !== "object" || depth > 5) return void 0;
256
+ const candidate = error;
257
+ if (typeof candidate.code === "string") return candidate;
258
+ return findPgError(candidate.cause, depth + 1);
259
+ }
260
+ __name(findPgError, "findPgError");
261
+
262
+ // src/filters/http-exception.filter.ts
263
+ function _ts_decorate(decorators, target, key, desc) {
264
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
265
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
266
+ 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;
267
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
268
+ }
269
+ __name(_ts_decorate, "_ts_decorate");
270
+ var HttpExceptionFilter = class _HttpExceptionFilter {
271
+ static {
272
+ __name(this, "HttpExceptionFilter");
273
+ }
274
+ logger = new Logger(_HttpExceptionFilter.name);
275
+ catch(exception, host) {
276
+ const ctx = host.switchToHttp();
277
+ const response = ctx.getResponse();
278
+ const request = ctx.getRequest();
279
+ const translatedPgError = tryTranslatePgError(exception);
280
+ if (translatedPgError) exception = translatedPgError;
281
+ let status = HttpStatus4.INTERNAL_SERVER_ERROR;
282
+ let type = "about:blank";
283
+ let label;
284
+ let detail = "Internal server error";
285
+ let errors = [];
286
+ if (this.isHttpException(exception)) {
287
+ status = exception.getStatus();
288
+ const exceptionResponse = exception.getResponse();
289
+ const extracted = extractProblemFromResponse(exceptionResponse, exception.message ?? getHttpStatusTitle(status));
290
+ type = extracted.type;
291
+ label = extracted.label;
292
+ detail = extracted.detail ?? detail;
293
+ errors = extracted.errors;
294
+ } else if (this.isProblemLikeObject(exception)) {
295
+ const problemObj = exception;
296
+ const statusCandidate = problemObj.status ?? problemObj.statusCode;
297
+ if (typeof statusCandidate === "number" && statusCandidate >= 400 && statusCandidate <= 599) {
298
+ status = statusCandidate;
299
+ }
300
+ type = typeof problemObj.type === "string" ? problemObj.type : "about:blank";
301
+ label = typeof problemObj.label === "string" ? problemObj.label : void 0;
302
+ detail = typeof problemObj.detail === "string" ? problemObj.detail : typeof problemObj.message === "string" ? problemObj.message : getHttpStatusTitle(status);
303
+ errors = Array.isArray(problemObj.errors) ? problemObj.errors : [];
304
+ } else if (this.isAxiosError(exception)) {
305
+ const axiosStatus = exception.response?.status;
306
+ const axiosDetail = exception.response?.data?.message || exception.response?.data?.detail || exception.message;
307
+ const url = exception.config?.url;
308
+ status = HttpStatus4.BAD_GATEWAY;
309
+ detail = `Upstream service error${axiosStatus ? ` (${axiosStatus})` : ""}: ${axiosDetail}`;
310
+ this.logger.error(`Upstream API error [${axiosStatus}]: ${axiosDetail} \u2014 URL: ${url}`, exception.stack);
311
+ } else {
312
+ detail = "An unexpected error occurred";
313
+ }
314
+ const problemDetails = {
315
+ type,
316
+ title: getHttpStatusTitle(status),
317
+ status,
318
+ ...label && {
319
+ label
320
+ },
321
+ detail,
322
+ instance: request.url,
323
+ errors
324
+ };
325
+ response.header("Content-Type", "application/problem+json").status(status).send(problemDetails);
326
+ }
327
+ // Duck-type check for HttpException — avoids instanceof failing across pnpm package instances
328
+ isHttpException(error) {
329
+ return error instanceof Error && typeof error.getStatus === "function" && typeof error.getResponse === "function";
330
+ }
331
+ // Duck-type check for AxiosError without importing axios
332
+ isAxiosError(error) {
333
+ return error instanceof Error && error.isAxiosError === true;
334
+ }
335
+ isProblemLikeObject(error) {
336
+ if (!error || typeof error !== "object") return false;
337
+ const obj = error;
338
+ return typeof obj.status === "number" || typeof obj.statusCode === "number" || typeof obj.detail === "string" || Array.isArray(obj.errors);
339
+ }
340
+ };
341
+ HttpExceptionFilter = _ts_decorate([
342
+ Catch()
343
+ ], HttpExceptionFilter);
344
+
345
+ // src/filters/transport-aware-exception.filter.ts
346
+ import { Catch as Catch2 } from "@nestjs/common";
347
+ function _ts_decorate2(decorators, target, key, desc) {
348
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
349
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
350
+ 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;
351
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
352
+ }
353
+ __name(_ts_decorate2, "_ts_decorate");
354
+ var TransportAwareExceptionFilter = class {
355
+ static {
356
+ __name(this, "TransportAwareExceptionFilter");
357
+ }
358
+ httpFilter = new HttpExceptionFilter();
359
+ catch(exception, host) {
360
+ if (host.getType() !== "http") {
361
+ throw exception;
362
+ }
363
+ this.httpFilter.catch(exception, host);
364
+ }
365
+ };
366
+ TransportAwareExceptionFilter = _ts_decorate2([
367
+ Catch2()
368
+ ], TransportAwareExceptionFilter);
369
+ export {
370
+ ErrorCode,
371
+ HttpExceptionFilter,
372
+ TransportAwareExceptionFilter,
373
+ createGraphqlFormatError,
374
+ errorCodeFromStatus,
375
+ getHttpStatusTitle
376
+ };
377
+ //# sourceMappingURL=filters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/filters/error-code.ts","../src/filters/problem-extraction.ts","../src/filters/graphql-format-error.ts","../src/filters/http-exception.filter.ts","../src/exceptions/conflict.exception.ts","../src/exceptions/base-field.exception.ts","../src/filters/pg-error.translator.ts","../src/filters/transport-aware-exception.filter.ts"],"sourcesContent":["import { HttpStatus } from '@nestjs/common';\n\nexport enum ErrorCode {\n UNAUTHENTICATED = 'UNAUTHENTICATED',\n FORBIDDEN = 'FORBIDDEN',\n NOT_FOUND = 'NOT_FOUND',\n VALIDATION_FAILED = 'VALIDATION_FAILED',\n CONFLICT = 'CONFLICT',\n RATE_LIMITED = 'RATE_LIMITED',\n BAD_REQUEST = 'BAD_REQUEST',\n INTERNAL = 'INTERNAL',\n}\n\n// Maps an HTTP status code to the canonical ErrorCode so HTTP and GraphQL classify identically.\nexport function errorCodeFromStatus(status: number): ErrorCode {\n switch (status) {\n case HttpStatus.UNAUTHORIZED: // 401\n return ErrorCode.UNAUTHENTICATED;\n case HttpStatus.FORBIDDEN: // 403\n return ErrorCode.FORBIDDEN;\n case HttpStatus.NOT_FOUND: // 404\n return ErrorCode.NOT_FOUND;\n case HttpStatus.BAD_REQUEST: // 400\n case HttpStatus.UNPROCESSABLE_ENTITY: // 422\n return ErrorCode.VALIDATION_FAILED;\n case HttpStatus.CONFLICT: // 409\n return ErrorCode.CONFLICT;\n case HttpStatus.TOO_MANY_REQUESTS: // 429\n return ErrorCode.RATE_LIMITED;\n default:\n // Any other 4xx is a generic bad request; 5xx and unknown collapse to INTERNAL.\n if (status >= 400 && status < 500) {\n return ErrorCode.BAD_REQUEST;\n }\n return ErrorCode.INTERNAL;\n }\n}\n","import { HttpStatus } from '@nestjs/common';\nimport type { FieldError } from '../types/error-response.types';\n\ninterface ProblemExceptionResponse {\n type?: string;\n label?: string;\n detail?: string;\n errors?: FieldError[];\n}\n\ninterface ValidationExceptionResponse {\n message: Array<string | { property: string; constraints: Record<string, string> }>;\n error?: string;\n}\n\ninterface StandardExceptionResponse {\n message: string | string[];\n error?: string;\n}\n\ntype ExceptionResponseObject = ProblemExceptionResponse | ValidationExceptionResponse | StandardExceptionResponse;\n\nexport interface ExtractedProblem {\n type: string;\n label?: string;\n detail?: string;\n errors: FieldError[];\n}\n\n// Converts an HTTP status code to its title string (e.g., 400 → \"Bad Request\")\nexport function getHttpStatusTitle(status: number): string {\n // Find the enum key for the given status code\n const enumKey = Object.entries(HttpStatus).find(([key, value]) => value === status && Number.isNaN(Number(key)))?.[0];\n\n if (!enumKey) {\n return 'Error';\n }\n\n // Convert enum key to title case (e.g., BAD_REQUEST -> Bad Request)\n return enumKey\n .split('_')\n .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())\n .join(' ');\n}\n\n// Extracts field-specific errors from a class-validator ValidationPipe message array, mirroring the RFC 9457 errors[].\nfunction extractValidationFieldErrors(\n message: Array<string | { property: string; constraints: Record<string, string> }>,\n): FieldError[] {\n return message\n .map((msg) => {\n if (typeof msg === 'object' && 'property' in msg && 'constraints' in msg) {\n const constraintValues = Object.values(msg.constraints);\n return {\n field: msg.property,\n message: constraintValues[0] ?? 'Validation failed',\n };\n }\n // Non-field-specific validation messages are ignored here; they belong at the detail level.\n return null;\n })\n .filter((error): error is FieldError => error !== null);\n}\n\n// Parses a NestJS HttpException response body into normalized problem fields across the SDK's three body shapes.\nexport function extractProblemFromResponse(\n exceptionResponse: string | object,\n problemFallbackDetail: string,\n): ExtractedProblem {\n let type = 'about:blank';\n let label: string | undefined;\n let detail: string | undefined;\n let errors: FieldError[] = [];\n\n if (typeof exceptionResponse === 'string') {\n detail = exceptionResponse;\n return { type, label, detail, errors };\n }\n\n if (exceptionResponse !== null && typeof exceptionResponse === 'object') {\n const responseObj = exceptionResponse as ExceptionResponseObject;\n\n // Custom HttpProblemException from @vritti/api-sdk\n if ('type' in responseObj || 'label' in responseObj || 'errors' in responseObj) {\n const problemResponse = responseObj as ProblemExceptionResponse;\n type = problemResponse.type ?? 'about:blank';\n label = problemResponse.label;\n detail = problemResponse.detail ?? problemFallbackDetail;\n errors = problemResponse.errors ?? [];\n }\n // class-validator DTO validation errors\n else if ('message' in responseObj && Array.isArray(responseObj.message)) {\n errors = extractValidationFieldErrors(responseObj.message);\n detail = 'Validation failed';\n }\n // Standard NestJS exceptions\n else if ('message' in responseObj) {\n const message = (responseObj as StandardExceptionResponse).message;\n detail = Array.isArray(message) ? message.join(', ') : message;\n }\n }\n\n return { type, label, detail, errors };\n}\n","import { type ErrorCode, errorCodeFromStatus } from './error-code';\nimport { extractProblemFromResponse, getHttpStatusTitle } from './problem-extraction';\n\n// graphql and @nestjs/graphql are optional peers not installed here, so we declare minimal structural shapes locally.\n\ninterface GraphqlFormattedErrorShape {\n message: string;\n locations?: ReadonlyArray<{ line: number; column: number }>;\n path?: ReadonlyArray<string | number>;\n extensions?: Record<string, unknown>;\n}\n\ninterface GraphqlErrorShape {\n message: string;\n originalError?: unknown;\n extensions?: Record<string, unknown>;\n}\n\ninterface HttpExceptionLike {\n getStatus(): number;\n getResponse(): string | object;\n message: string;\n}\n\nexport interface GraphqlFormatErrorOptions {\n isProduction: boolean;\n getTraceId?: () => string | undefined;\n}\n\nexport interface FormattedErrorExtensions {\n code: ErrorCode;\n traceId?: string;\n timestamp: string;\n fieldErrors?: Array<{ field: string; message: string }>;\n [key: string]: unknown;\n}\n\n// Duck-types a NestJS HttpException without importing @nestjs/common (cross-package-instance safe).\nfunction isHttpExceptionLike(error: unknown): error is HttpExceptionLike {\n return (\n error instanceof Error &&\n typeof (error as { getStatus?: unknown }).getStatus === 'function' &&\n typeof (error as { getResponse?: unknown }).getResponse === 'function'\n );\n}\n\ninterface ProblemLike {\n status?: number;\n statusCode?: number;\n detail?: string;\n message?: string;\n}\n\nfunction isProblemLike(error: unknown): error is ProblemLike {\n if (error == null || typeof error !== 'object') {\n return false;\n }\n const o = error as Record<string, unknown>;\n return typeof o.status === 'number' || typeof o.statusCode === 'number';\n}\n\ninterface ProblemSource {\n status: number;\n response: string | object;\n fallback: string;\n}\n\n// Walks the error chain to find the underlying HttpException or plain RFC 9457 problem via originalError/thrownValue.\nfunction findProblemSource(error: GraphqlErrorShape | undefined): ProblemSource | undefined {\n let current: unknown = error;\n // Bounded walk — guard against cyclic chains.\n for (let depth = 0; current && depth < 10; depth++) {\n if (isHttpExceptionLike(current)) {\n const status = current.getStatus();\n return { status, response: current.getResponse(), fallback: current.message ?? getHttpStatusTitle(status) };\n }\n if (isProblemLike(current)) {\n const status = current.status ?? current.statusCode ?? 500;\n return { status, response: current, fallback: current.detail ?? current.message ?? getHttpStatusTitle(status) };\n }\n const next = current as { originalError?: unknown; thrownValue?: unknown };\n current = next.originalError ?? next.thrownValue;\n }\n return undefined;\n}\n\nconst GENERIC_INTERNAL_MESSAGE = 'Internal server error';\n\n// Builds an Apollo formatError that normalizes every GraphQL error into a stable, transport-consistent shape.\nexport function createGraphqlFormatError(\n opts: GraphqlFormatErrorOptions,\n): (formattedError: GraphqlFormattedErrorShape, error: unknown) => GraphqlFormattedErrorShape {\n const { isProduction, getTraceId } = opts;\n\n return (formattedError, error) => {\n const gqlError = (error ?? undefined) as GraphqlErrorShape | undefined;\n const source = findProblemSource(gqlError);\n\n // Derive status + problem body from the underlying source since Apollo only copies .message and defaults code to INTERNAL.\n let status = 500;\n let detail: string | undefined;\n let label: string | undefined;\n let fieldErrors: Array<{ field: string; message: string }> = [];\n\n if (source) {\n status = source.status;\n const extracted = extractProblemFromResponse(source.response, source.fallback);\n detail = extracted.detail;\n label = extracted.label;\n fieldErrors = extracted.errors;\n }\n\n const code = errorCodeFromStatus(status);\n\n // Prefer the problem detail, then the formatted message; never surface internals for INTERNAL in production.\n let message = detail ?? formattedError.message;\n if (code === 'INTERNAL' && isProduction) {\n message = GENERIC_INTERNAL_MESSAGE;\n }\n\n // Start from Apollo's extensions so any framework-set keys survive, then normalize ours on top.\n const incoming: Record<string, unknown> = { ...(formattedError.extensions ?? {}) };\n\n const traceId = getTraceId?.();\n const timestamp = new Date().toISOString();\n\n const extensions: FormattedErrorExtensions = {\n ...incoming,\n // Always our canonical code — overrides Apollo's default INTERNAL_SERVER_ERROR.\n code,\n ...(traceId !== undefined ? { traceId } : {}),\n timestamp,\n ...(label !== undefined ? { label } : {}),\n ...(fieldErrors.length > 0 ? { fieldErrors } : {}),\n };\n\n if (isProduction) {\n // Strip anything that could leak server internals to clients.\n delete extensions.stacktrace;\n delete extensions.exception;\n delete extensions.originalError;\n }\n\n const result: GraphqlFormattedErrorShape = {\n message,\n extensions,\n };\n // Preserve location/path metadata GraphQL attaches (useful to clients, leaks nothing).\n if (formattedError.locations) result.locations = formattedError.locations;\n if (formattedError.path) result.path = formattedError.path;\n\n return result;\n };\n}\n","import {\n type ArgumentsHost,\n Catch,\n type ExceptionFilter,\n type HttpException,\n HttpStatus,\n Logger,\n} from '@nestjs/common';\nimport type { FastifyReply, FastifyRequest } from 'fastify';\nimport type { ApiErrorResponse, FieldError } from '../types/error-response.types';\nimport { tryTranslatePgError } from './pg-error.translator';\nimport { extractProblemFromResponse, getHttpStatusTitle } from './problem-extraction';\n\nexport { getHttpStatusTitle };\n\n@Catch()\nexport class HttpExceptionFilter implements ExceptionFilter {\n private readonly logger = new Logger(HttpExceptionFilter.name);\n\n catch(exception: unknown, host: ArgumentsHost) {\n const ctx = host.switchToHttp();\n const response = ctx.getResponse<FastifyReply>();\n const request = ctx.getRequest<FastifyRequest>();\n\n // Translate raw Postgres errors (e.g. 23505 unique_violation) into a ConflictException before classifying as 500.\n const translatedPgError = tryTranslatePgError(exception);\n if (translatedPgError) exception = translatedPgError;\n\n let status = HttpStatus.INTERNAL_SERVER_ERROR;\n let type = 'about:blank';\n let label: string | undefined;\n let detail = 'Internal server error';\n let errors: FieldError[] = [];\n\n if (this.isHttpException(exception)) {\n status = exception.getStatus();\n const exceptionResponse = exception.getResponse();\n\n // Reuse the shared extractor so HTTP and GraphQL surface identical problem details.\n const extracted = extractProblemFromResponse(exceptionResponse, exception.message ?? getHttpStatusTitle(status));\n type = extracted.type;\n label = extracted.label;\n // Keep the initial 'Internal server error' when the body matched no known shape (byte-identical HTTP output).\n detail = extracted.detail ?? detail;\n errors = extracted.errors;\n } else if (this.isProblemLikeObject(exception)) {\n const problemObj = exception as Record<string, unknown>;\n const statusCandidate = problemObj.status ?? problemObj.statusCode;\n if (typeof statusCandidate === 'number' && statusCandidate >= 400 && statusCandidate <= 599) {\n status = statusCandidate;\n }\n type = typeof problemObj.type === 'string' ? problemObj.type : 'about:blank';\n label = typeof problemObj.label === 'string' ? problemObj.label : undefined;\n detail =\n typeof problemObj.detail === 'string'\n ? problemObj.detail\n : typeof problemObj.message === 'string'\n ? problemObj.message\n : getHttpStatusTitle(status);\n errors = Array.isArray(problemObj.errors) ? (problemObj.errors as FieldError[]) : [];\n } else if (this.isAxiosError(exception)) {\n // Outgoing HTTP call failures (e.g., service-to-service calls)\n const axiosStatus = exception.response?.status;\n const axiosDetail = exception.response?.data?.message || exception.response?.data?.detail || exception.message;\n const url = exception.config?.url;\n status = HttpStatus.BAD_GATEWAY;\n detail = `Upstream service error${axiosStatus ? ` (${axiosStatus})` : ''}: ${axiosDetail}`;\n this.logger.error(`Upstream API error [${axiosStatus}]: ${axiosDetail} — URL: ${url}`, exception.stack);\n } else {\n // Unknown errors — logged by HttpLoggerInterceptor, no need to log again here\n detail = 'An unexpected error occurred';\n }\n\n const problemDetails: ApiErrorResponse = {\n type,\n title: getHttpStatusTitle(status),\n status,\n ...(label && { label }),\n detail,\n instance: request.url,\n errors,\n };\n\n response.header('Content-Type', 'application/problem+json').status(status).send(problemDetails);\n }\n\n // Duck-type check for HttpException — avoids instanceof failing across pnpm package instances\n private isHttpException(error: unknown): error is HttpException {\n return (\n error instanceof Error &&\n typeof (error as { getStatus?: unknown }).getStatus === 'function' &&\n typeof (error as { getResponse?: unknown }).getResponse === 'function'\n );\n }\n\n // Duck-type check for AxiosError without importing axios\n private isAxiosError(error: unknown): error is Error & {\n isAxiosError: true;\n response?: { status?: number; data?: Record<string, unknown> };\n config?: { url?: string };\n } {\n return error instanceof Error && (error as { isAxiosError?: boolean }).isAxiosError === true;\n }\n\n private isProblemLikeObject(error: unknown): error is Record<string, unknown> {\n if (!error || typeof error !== 'object') return false;\n const obj = error as Record<string, unknown>;\n return (\n typeof obj.status === 'number' ||\n typeof obj.statusCode === 'number' ||\n typeof obj.detail === 'string' ||\n Array.isArray(obj.errors)\n );\n }\n}\n","import { HttpStatus } from '@nestjs/common';\nimport { HttpProblemException, type ProblemOptions } from './base-field.exception';\n\nexport class ConflictException extends HttpProblemException {\n constructor(detailOrOptions?: string | ProblemOptions) {\n super(detailOrOptions ?? 'Conflict', HttpStatus.CONFLICT);\n }\n}\n","import { HttpException, HttpStatus } from '@nestjs/common';\nimport type { FieldError } from '../types/error-response.types';\n\n// Re-export FieldError for backwards compatibility\nexport type { FieldError } from '../types/error-response.types';\n\nexport interface ProblemOptions {\n type?: string;\n label?: string;\n detail?: string;\n errors?: FieldError[];\n}\n\nexport abstract class HttpProblemException extends HttpException {\n constructor(detailOrOptions: string | ProblemOptions, httpStatus: HttpStatus) {\n const options = typeof detailOrOptions === 'string' ? { detail: detailOrOptions } : detailOrOptions;\n\n super(\n {\n type: options.type ?? 'about:blank',\n label: options.label,\n detail: options.detail,\n errors: options.errors ?? [],\n },\n httpStatus,\n );\n }\n}\n","import { ConflictException } from '../exceptions/conflict.exception';\n\nconst PG_UNIQUE_VIOLATION = '23505';\n\nexport type PgErrorShape = {\n code?: string;\n message?: string;\n constraint?: string;\n table?: string;\n schema?: string;\n column?: string;\n detail?: string;\n hint?: string;\n};\n\n// Returns a ConflictException for a Postgres unique-violation error, otherwise undefined.\nexport function tryTranslatePgError(error: unknown): ConflictException | undefined {\n const pgError = findPgError(error);\n if (!pgError) return undefined;\n const { code, constraint, table, detail } = pgError;\n if (code !== PG_UNIQUE_VIOLATION) return undefined;\n return new ConflictException({\n label: 'Duplicate Entry',\n detail: detail?.trim() || 'A record with these values already exists.',\n errors: [],\n ...(constraint || table ? { meta: { constraint, table } } : {}),\n });\n}\n\n// Walks up to N levels of `.cause` looking for a pg-shaped error (has SQLSTATE `code`), capping depth.\nexport function findPgError(error: unknown, depth = 0): PgErrorShape | undefined {\n if (!error || typeof error !== 'object' || depth > 5) return undefined;\n const candidate = error as PgErrorShape & { cause?: unknown };\n if (typeof candidate.code === 'string') return candidate;\n return findPgError(candidate.cause, depth + 1);\n}\n","import { type ArgumentsHost, Catch, type ExceptionFilter } from '@nestjs/common';\nimport { HttpExceptionFilter } from './http-exception.filter';\n\n@Catch()\nexport class TransportAwareExceptionFilter implements ExceptionFilter {\n private readonly httpFilter = new HttpExceptionFilter();\n\n catch(exception: unknown, host: ArgumentsHost): void {\n if (host.getType() !== 'http') {\n throw exception;\n }\n this.httpFilter.catch(exception, host);\n }\n}\n"],"mappings":";;;;AAAA,SAASA,kBAAkB;AAEpB,IAAKC,YAAAA,0BAAAA,YAAAA;;;;;;;;;SAAAA;;AAYL,SAASC,oBAAoBC,QAAc;AAChD,UAAQA,QAAAA;IACN,KAAKC,WAAWC;AACd,aAAA;IACF,KAAKD,WAAWE;AACd,aAAA;IACF,KAAKF,WAAWG;AACd,aAAA;IACF,KAAKH,WAAWI;IAChB,KAAKJ,WAAWK;AACd,aAAA;IACF,KAAKL,WAAWM;AACd,aAAA;IACF,KAAKN,WAAWO;AACd,aAAA;IACF;AAEE,UAAIR,UAAU,OAAOA,SAAS,KAAK;AACjC,eAAA;MACF;AACA,aAAA;EACJ;AACF;AAtBgBD;;;ACdhB,SAASU,cAAAA,mBAAkB;AA8BpB,SAASC,mBAAmBC,QAAc;AAE/C,QAAMC,UAAUC,OAAOC,QAAQC,WAAAA,EAAYC,KAAK,CAAC,CAACC,KAAKC,KAAAA,MAAWA,UAAUP,UAAUQ,OAAOC,MAAMD,OAAOF,GAAAA,CAAAA,CAAAA,IAAS,CAAA;AAEnH,MAAI,CAACL,SAAS;AACZ,WAAO;EACT;AAGA,SAAOA,QACJS,MAAM,GAAA,EACNC,IAAI,CAACC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iBAAmC;MACvC3B;MACA4B,OAAOlB,mBAAmBb,MAAAA;MAC1BA;MACA,GAAII,SAAS;QAAEA;MAAM;MACrBC;MACA2B,UAAUpC,QAAQ6B;MAClBnB;IACF;AAEAZ,aAASuC,OAAO,gBAAgB,0BAAA,EAA4BjC,OAAOA,MAAAA,EAAQkC,KAAKJ,cAAAA;EAClF;;EAGQvB,gBAAgBqB,OAAwC;AAC9D,WACEA,iBAAiBO,SACjB,OAAQP,MAAkCpB,cAAc,cACxD,OAAQoB,MAAoCjC,gBAAgB;EAEhE;;EAGQ0B,aAAaO,OAInB;AACA,WAAOA,iBAAiBO,SAAUP,MAAqCP,iBAAiB;EAC1F;EAEQP,oBAAoBc,OAAkD;AAC5E,QAAI,CAACA,SAAS,OAAOA,UAAU,SAAU,QAAO;AAChD,UAAMQ,MAAMR;AACZ,WACE,OAAOQ,IAAIpC,WAAW,YACtB,OAAOoC,IAAInB,eAAe,YAC1B,OAAOmB,IAAI/B,WAAW,YACtBc,MAAMC,QAAQgB,IAAI9B,MAAM;EAE5B;AACF;;;;;;AIlHA,SAA6B+B,SAAAA,cAAmC;;;;;;;;AAIzD,IAAMC,gCAAN,MAAMA;SAAAA;;;EACMC,aAAa,IAAIC,oBAAAA;EAElCC,MAAMC,WAAoBC,MAA2B;AACnD,QAAIA,KAAKC,QAAO,MAAO,QAAQ;AAC7B,YAAMF;IACR;AACA,SAAKH,WAAWE,MAAMC,WAAWC,IAAAA;EACnC;AACF;;;;","names":["HttpStatus","ErrorCode","errorCodeFromStatus","status","HttpStatus","UNAUTHORIZED","FORBIDDEN","NOT_FOUND","BAD_REQUEST","UNPROCESSABLE_ENTITY","CONFLICT","TOO_MANY_REQUESTS","HttpStatus","getHttpStatusTitle","status","enumKey","Object","entries","HttpStatus","find","key","value","Number","isNaN","split","map","word","charAt","toUpperCase","slice","toLowerCase","join","extractValidationFieldErrors","message","msg","constraintValues","values","constraints","field","property","filter","error","extractProblemFromResponse","exceptionResponse","problemFallbackDetail","type","label","detail","errors","responseObj","problemResponse","Array","isArray","isHttpExceptionLike","error","Error","getStatus","getResponse","isProblemLike","o","status","statusCode","findProblemSource","current","depth","response","fallback","message","getHttpStatusTitle","detail","next","originalError","thrownValue","undefined","GENERIC_INTERNAL_MESSAGE","createGraphqlFormatError","opts","isProduction","getTraceId","formattedError","gqlError","source","label","fieldErrors","extracted","extractProblemFromResponse","errors","code","errorCodeFromStatus","incoming","extensions","traceId","timestamp","Date","toISOString","length","stacktrace","exception","result","locations","path","Catch","HttpStatus","Logger","HttpStatus","HttpException","HttpProblemException","HttpException","detailOrOptions","httpStatus","options","detail","type","label","errors","ConflictException","HttpProblemException","detailOrOptions","HttpStatus","CONFLICT","PG_UNIQUE_VIOLATION","tryTranslatePgError","error","pgError","findPgError","undefined","code","constraint","table","detail","ConflictException","label","trim","errors","meta","depth","candidate","cause","HttpExceptionFilter","logger","Logger","name","catch","exception","host","ctx","switchToHttp","response","getResponse","request","getRequest","translatedPgError","tryTranslatePgError","status","HttpStatus","INTERNAL_SERVER_ERROR","type","label","detail","errors","isHttpException","getStatus","exceptionResponse","extracted","extractProblemFromResponse","message","getHttpStatusTitle","isProblemLikeObject","problemObj","statusCandidate","statusCode","undefined","Array","isArray","isAxiosError","axiosStatus","axiosDetail","data","url","config","BAD_GATEWAY","error","stack","problemDetails","title","instance","header","send","Error","obj","Catch","TransportAwareExceptionFilter","httpFilter","HttpExceptionFilter","catch","exception","host","getType"]}