@gigapay-dev/contracts 1.2.4 → 1.2.6

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.
@@ -8,6 +8,8 @@ exports.PromoCodeCreateSchema = zod_1.z.object({
8
8
  discountValue: zod_1.z.string(),
9
9
  expiredAt: zod_1.z.coerce.date().nullable().optional(),
10
10
  startedAt: zod_1.z.coerce.date().nullable().optional(),
11
+ createdAt: zod_1.z.coerce.date().nullable().optional(),
12
+ updatedAt: zod_1.z.coerce.date().nullable().optional(),
11
13
  activationLimit: zod_1.z.coerce.number().positive().nullable().optional(),
12
14
  activationPerUserLimit: zod_1.z.coerce.number().positive().nullable().optional(),
13
15
  type: enums_1.PromoCodeType,
@@ -12,6 +12,8 @@ exports.PromoCodeReadResponseSchema = zod_1.default.object({
12
12
  discountValue: zod_1.default.string(),
13
13
  startedAt: zod_1.default.coerce.date().nullable().optional(),
14
14
  expiredAt: zod_1.default.coerce.date().nullable().optional(),
15
+ createdAt: zod_1.default.coerce.date().nullable().optional(),
16
+ updatedAt: zod_1.default.coerce.date().nullable().optional(),
15
17
  activationLimit: zod_1.default.coerce.number().positive().nullable().optional(),
16
18
  activationPerUserLimit: zod_1.default.coerce.number().positive().nullable().optional(),
17
19
  type: enums_1.PromoCodeType,
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UserCreateSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const enums_1 = require("./enums");
6
+ exports.UserCreateSchema = zod_1.z.object({
7
+ username: zod_1.z.string(),
8
+ picture: zod_1.z.string(),
9
+ email: zod_1.z.string(),
10
+ password: zod_1.z.string(),
11
+ role: enums_1.UserRoleEnum,
12
+ status: enums_1.UserStatusEnum,
13
+ });
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UserEndpoints = void 0;
4
+ const zod_1 = require("zod");
5
+ const create_1 = require("./create");
6
+ const read_1 = require("./read");
7
+ const update_1 = require("./update");
8
+ exports.UserEndpoints = {
9
+ create: {
10
+ method: "POST",
11
+ path: "/users",
12
+ request: create_1.UserCreateSchema,
13
+ response: read_1.UserReadResponseSchema,
14
+ },
15
+ list: {
16
+ method: "GET",
17
+ path: "/users",
18
+ request: zod_1.z.object({}),
19
+ response: zod_1.z.array(read_1.UserReadResponseSchema),
20
+ },
21
+ getById: {
22
+ method: "GET",
23
+ path: "/users/:id",
24
+ request: zod_1.z.object({
25
+ id: zod_1.z.coerce.number().positive(),
26
+ }),
27
+ response: read_1.UserReadResponseSchema,
28
+ },
29
+ update: {
30
+ method: "PATCH",
31
+ path: "/users/:id",
32
+ request: zod_1.z.object({
33
+ id: zod_1.z.coerce.number().positive(),
34
+ body: update_1.UserUpdateSchema,
35
+ }),
36
+ response: read_1.UserReadResponseSchema,
37
+ },
38
+ };
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.UserStatusEnum = exports.UserRoleEnum = void 0;
7
+ const zod_1 = __importDefault(require("zod"));
8
+ exports.UserRoleEnum = zod_1.default.enum(["USER", "ADMIN"]);
9
+ exports.UserStatusEnum = zod_1.default.enum(["ACTIVE", "BLOCKED"]);
@@ -0,0 +1,21 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./create"), exports);
18
+ __exportStar(require("./read"), exports);
19
+ __exportStar(require("./update"), exports);
20
+ __exportStar(require("./enums"), exports);
21
+ __exportStar(require("./endpoints"), exports);
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.UserReadResponseSchema = void 0;
7
+ const zod_1 = __importDefault(require("zod"));
8
+ const enums_1 = require("./enums");
9
+ exports.UserReadResponseSchema = zod_1.default.object({
10
+ id: zod_1.default.coerce.number().positive(),
11
+ username: zod_1.default.string(),
12
+ picture: zod_1.default.string(),
13
+ email: zod_1.default.string(),
14
+ steamId: zod_1.default.string(),
15
+ telegramId: zod_1.default.string(),
16
+ vkId: zod_1.default.string(),
17
+ googleId: zod_1.default.string(),
18
+ createdAt: zod_1.default.coerce.date().nullable().optional(),
19
+ updatedAt: zod_1.default.coerce.date().nullable().optional(),
20
+ blockedAt: zod_1.default.coerce.date().nullable().optional(),
21
+ isConfirmEmail: zod_1.default.boolean(),
22
+ isOnline: zod_1.default.boolean(),
23
+ role: enums_1.UserRoleEnum,
24
+ status: enums_1.UserStatusEnum,
25
+ });
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UserUpdateSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const enums_1 = require("./enums");
6
+ exports.UserUpdateSchema = zod_1.z.object({
7
+ username: zod_1.z.string(),
8
+ picture: zod_1.z.string(),
9
+ email: zod_1.z.string(),
10
+ password: zod_1.z.string(),
11
+ role: enums_1.UserRoleEnum,
12
+ status: enums_1.UserStatusEnum,
13
+ });
@@ -6,6 +6,8 @@ export const PromoCodeCreateSchema = z.object({
6
6
  discountValue: z.string(),
7
7
  expiredAt: z.coerce.date().nullable().optional(),
8
8
  startedAt: z.coerce.date().nullable().optional(),
9
+ createdAt: z.coerce.date().nullable().optional(),
10
+ updatedAt: z.coerce.date().nullable().optional(),
9
11
  activationLimit: z.coerce.number().positive().nullable().optional(),
10
12
  activationPerUserLimit: z.coerce.number().positive().nullable().optional(),
11
13
  type: PromoCodeType,
@@ -7,6 +7,8 @@ export const PromoCodeReadResponseSchema = z.object({
7
7
  discountValue: z.string(),
8
8
  startedAt: z.coerce.date().nullable().optional(),
9
9
  expiredAt: z.coerce.date().nullable().optional(),
10
+ createdAt: z.coerce.date().nullable().optional(),
11
+ updatedAt: z.coerce.date().nullable().optional(),
10
12
  activationLimit: z.coerce.number().positive().nullable().optional(),
11
13
  activationPerUserLimit: z.coerce.number().positive().nullable().optional(),
12
14
  type: PromoCodeType,
@@ -0,0 +1,13 @@
1
+ import { z } from "zod";
2
+ import { UserRoleEnum, UserStatusEnum } from "./enums";
3
+
4
+ export const UserCreateSchema = z.object({
5
+ username: z.string(),
6
+ picture: z.string(),
7
+ email: z.string(),
8
+ password: z.string(),
9
+ role: UserRoleEnum,
10
+ status: UserStatusEnum,
11
+ });
12
+
13
+ export type UserCreate = z.infer<typeof UserCreateSchema>;
@@ -0,0 +1,46 @@
1
+ import { z } from "zod";
2
+ import { EndpointContract } from "../../types";
3
+ import { UserCreateSchema } from "./create";
4
+ import { UserReadResponseSchema } from "./read";
5
+ import { UserUpdateSchema } from "./update";
6
+
7
+ export const UserEndpoints = {
8
+ create: {
9
+ method: "POST",
10
+ path: "/users",
11
+ request: UserCreateSchema,
12
+ response: UserReadResponseSchema,
13
+ },
14
+ list: {
15
+ method: "GET",
16
+ path: "/users",
17
+ request: z.object({}),
18
+ response: z.array(UserReadResponseSchema),
19
+ },
20
+ getById: {
21
+ method: "GET",
22
+ path: "/users/:id",
23
+ request: z.object({
24
+ id: z.coerce.number().positive(),
25
+ }),
26
+ response: UserReadResponseSchema,
27
+ },
28
+ update: {
29
+ method: "PATCH",
30
+ path: "/users/:id",
31
+ request: z.object({
32
+ id: z.coerce.number().positive(),
33
+ body: UserUpdateSchema,
34
+ }),
35
+ response: UserReadResponseSchema,
36
+ },
37
+
38
+ } satisfies Record<string, EndpointContract>;
39
+
40
+ export type UserEndpointKey = keyof typeof UserEndpoints;
41
+
42
+ export type GetPromoCodeRequest<K extends UserEndpointKey> =
43
+ z.infer<typeof UserEndpoints[K]["request"]>;
44
+
45
+ export type GetPromoCodeResponse<K extends UserEndpointKey> =
46
+ z.infer<typeof UserEndpoints[K]["response"]>;
@@ -0,0 +1,9 @@
1
+ import z from "zod";
2
+
3
+ export const UserRoleEnum = z.enum(["USER", "ADMIN"]);
4
+ export const UserStatusEnum = z.enum(["ACTIVE", "BLOCKED"]);
5
+
6
+ export type UserRoleType = z.infer<typeof UserRoleEnum>;
7
+ export type UserStatusType = z.infer<typeof UserStatusEnum>;
8
+
9
+
@@ -0,0 +1,5 @@
1
+ export * from "./create"
2
+ export * from "./read"
3
+ export * from "./update"
4
+ export * from "./enums"
5
+ export * from "./endpoints"
@@ -0,0 +1,22 @@
1
+ import z from "zod";
2
+ import { UserRoleEnum, UserStatusEnum } from "./enums";
3
+
4
+ export const UserReadResponseSchema = z.object({
5
+ id: z.coerce.number().positive(),
6
+ username: z.string(),
7
+ picture: z.string(),
8
+ email: z.string(),
9
+ steamId: z.string(),
10
+ telegramId: z.string(),
11
+ vkId: z.string(),
12
+ googleId: z.string(),
13
+ createdAt: z.coerce.date().nullable().optional(),
14
+ updatedAt: z.coerce.date().nullable().optional(),
15
+ blockedAt: z.coerce.date().nullable().optional(),
16
+ isConfirmEmail: z.boolean(),
17
+ isOnline: z.boolean(),
18
+ role: UserRoleEnum,
19
+ status: UserStatusEnum,
20
+ });
21
+
22
+ export type UserReadResponse = z.infer<typeof UserReadResponseSchema>;
@@ -0,0 +1,13 @@
1
+ import { z } from "zod";
2
+ import { UserRoleEnum, UserStatusEnum } from "./enums";
3
+
4
+ export const UserUpdateSchema = z.object({
5
+ username: z.string(),
6
+ picture: z.string(),
7
+ email: z.string(),
8
+ password: z.string(),
9
+ role: UserRoleEnum,
10
+ status: UserStatusEnum,
11
+ })
12
+
13
+ export type UserUpdate = z.infer<typeof UserUpdateSchema>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gigapay-dev/contracts",
3
- "version": "1.2.4",
3
+ "version": "1.2.6",
4
4
  "main": "./build/index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",