@lucaapp/service-utils 1.35.0 → 1.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -41,6 +41,16 @@ declare const notFoundErrorSchema: z.ZodObject<{
41
41
  message: string;
42
42
  error: HTTPStatus.NOT_FOUND;
43
43
  }>;
44
+ declare const conflictErrorSchema: z.ZodObject<{
45
+ error: z.ZodLiteral<HTTPStatus.CONFLICT>;
46
+ message: z.ZodString;
47
+ }, "strip", z.ZodTypeAny, {
48
+ message: string;
49
+ error: HTTPStatus.CONFLICT;
50
+ }, {
51
+ message: string;
52
+ error: HTTPStatus.CONFLICT;
53
+ }>;
44
54
  declare const tooManyRequestsErrorSchema: z.ZodObject<{
45
55
  error: z.ZodLiteral<HTTPStatus.TOO_MANY_REQUESTS>;
46
56
  message: z.ZodString;
@@ -86,6 +96,11 @@ export declare const notFoundResponse: () => {
86
96
  description: string;
87
97
  schema: typeof notFoundErrorSchema;
88
98
  };
99
+ export declare const conflictResponse: () => {
100
+ status: 409;
101
+ description: string;
102
+ schema: typeof conflictErrorSchema;
103
+ };
89
104
  export declare const tooManyRequestsResponse: () => {
90
105
  status: 429;
91
106
  description: string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.tooManyRequestsResponse = exports.notFoundResponse = exports.forbiddenResponse = exports.unauthorizedResponse = exports.badRequestResponse = exports.noContentResponse = exports.createdResponse = exports.okResponse = void 0;
3
+ exports.tooManyRequestsResponse = exports.conflictResponse = exports.notFoundResponse = exports.forbiddenResponse = exports.unauthorizedResponse = exports.badRequestResponse = exports.noContentResponse = exports.createdResponse = exports.okResponse = void 0;
4
4
  const zod_to_openapi_1 = require("@asteasolutions/zod-to-openapi");
5
5
  const zod_1 = require("zod");
6
6
  const http_1 = require("./types/http");
@@ -23,6 +23,10 @@ const notFoundErrorSchema = zod_1.z.object({
23
23
  error: zod_1.z.literal(http_1.HTTPStatus.NOT_FOUND),
24
24
  message: zod_1.z.string(),
25
25
  });
26
+ const conflictErrorSchema = zod_1.z.object({
27
+ error: zod_1.z.literal(http_1.HTTPStatus.CONFLICT),
28
+ message: zod_1.z.string(),
29
+ });
26
30
  const tooManyRequestsErrorSchema = zod_1.z.object({
27
31
  error: zod_1.z.literal(http_1.HTTPStatus.TOO_MANY_REQUESTS),
28
32
  message: zod_1.z.string(),
@@ -70,6 +74,12 @@ const notFoundResponse = () => ({
70
74
  schema: notFoundErrorSchema,
71
75
  });
72
76
  exports.notFoundResponse = notFoundResponse;
77
+ const conflictResponse = () => ({
78
+ status: 409,
79
+ description: 'Conflict',
80
+ schema: conflictErrorSchema,
81
+ });
82
+ exports.conflictResponse = conflictResponse;
73
83
  const tooManyRequestsResponse = () => ({
74
84
  status: 429,
75
85
  description: 'Too Many Requests',
@@ -39,3 +39,10 @@ export declare const notFound: (message?: string) => {
39
39
  message: string;
40
40
  };
41
41
  };
42
+ export declare const conflict: (message?: string) => {
43
+ status: 409;
44
+ body: {
45
+ error: HTTPStatus.CONFLICT;
46
+ message: string;
47
+ };
48
+ };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.notFound = exports.forbidden = exports.unauthorized = exports.badRequest = exports.noContent = exports.created = exports.ok = void 0;
3
+ exports.conflict = exports.notFound = exports.forbidden = exports.unauthorized = exports.badRequest = exports.noContent = exports.created = exports.ok = void 0;
4
4
  const http_1 = require("./types/http");
5
5
  const ok = (body) => ({
6
6
  status: 200,
@@ -49,3 +49,11 @@ const notFound = (message) => ({
49
49
  },
50
50
  });
51
51
  exports.notFound = notFound;
52
+ const conflict = (message) => ({
53
+ status: 409,
54
+ body: {
55
+ error: http_1.HTTPStatus.CONFLICT,
56
+ message: message || 'Conflict',
57
+ },
58
+ });
59
+ exports.conflict = conflict;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lucaapp/service-utils",
3
- "version": "1.35.0",
3
+ "version": "1.36.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [