@gigapay-dev/contracts 1.0.2 → 1.0.4
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/build/commands/auth/confirm.js +10 -0
- package/build/commands/auth/endpoints.js +26 -0
- package/build/commands/auth/index.js +3 -0
- package/build/commands/auth/reset.js +8 -0
- package/build/commands/orders/endpoints.js +48 -0
- package/build/commands/orders/index.js +1 -0
- package/build/commands/promocodes/endpoints.js +46 -0
- package/build/commands/promocodes/index.js +1 -0
- package/build/commands/promocodes/update.js +3 -3
- package/build/commands/refresh-sessions/enums.js +1 -1
- package/build/commands/refresh-sessions/update.js +3 -3
- package/build/types.js +2 -0
- package/commands/auth/confirm.ts +9 -0
- package/commands/auth/endpoints.ts +31 -0
- package/commands/auth/index.ts +4 -1
- package/commands/auth/reset.ts +8 -0
- package/commands/orders/endpoints.ts +56 -0
- package/commands/orders/index.ts +2 -1
- package/commands/promocodes/endpoints.ts +62 -0
- package/commands/promocodes/index.ts +2 -1
- package/package.json +1 -1
- package/types.ts +9 -0
|
@@ -0,0 +1,10 @@
|
|
|
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.ConfirmCodeRequestSchema = void 0;
|
|
7
|
+
const zod_1 = __importDefault(require("zod"));
|
|
8
|
+
exports.ConfirmCodeRequestSchema = zod_1.default.object({
|
|
9
|
+
code: zod_1.default.string().min(4),
|
|
10
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AuthEndpoints = void 0;
|
|
4
|
+
const login_1 = require("./login");
|
|
5
|
+
const register_1 = require("./register");
|
|
6
|
+
const confirm_1 = require("./confirm");
|
|
7
|
+
exports.AuthEndpoints = {
|
|
8
|
+
login: {
|
|
9
|
+
method: "POST",
|
|
10
|
+
path: "/auth/login",
|
|
11
|
+
request: login_1.UserLoginRequestSchema,
|
|
12
|
+
response: login_1.UserLoginResponseSchema,
|
|
13
|
+
},
|
|
14
|
+
register: {
|
|
15
|
+
method: "POST",
|
|
16
|
+
path: "/auth/sign-up",
|
|
17
|
+
request: register_1.UserRegisterRequestSchema,
|
|
18
|
+
response: login_1.UserLoginResponseSchema,
|
|
19
|
+
},
|
|
20
|
+
confirm: {
|
|
21
|
+
method: "GET",
|
|
22
|
+
path: "/auth/confirm-code/:code",
|
|
23
|
+
request: confirm_1.ConfirmCodeRequestSchema,
|
|
24
|
+
response: login_1.UserLoginResponseSchema,
|
|
25
|
+
}
|
|
26
|
+
};
|
|
@@ -16,3 +16,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./login"), exports);
|
|
18
18
|
__exportStar(require("./register"), exports);
|
|
19
|
+
__exportStar(require("./confirm"), exports);
|
|
20
|
+
__exportStar(require("./reset"), exports);
|
|
21
|
+
__exportStar(require("./endpoints"), exports);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UserResetRequestSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
exports.UserResetRequestSchema = zod_1.z.object({
|
|
6
|
+
email: zod_1.z.string().email(),
|
|
7
|
+
password: zod_1.z.string().min(6),
|
|
8
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
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.OrderEndpoints = void 0;
|
|
7
|
+
const zod_1 = __importDefault(require("zod"));
|
|
8
|
+
const read_1 = require("./read");
|
|
9
|
+
const create_1 = require("./create");
|
|
10
|
+
exports.OrderEndpoints = {
|
|
11
|
+
create: {
|
|
12
|
+
method: "POST",
|
|
13
|
+
path: "/orders",
|
|
14
|
+
request: create_1.OrderCreateRequestSchema,
|
|
15
|
+
response: create_1.OrderCreateResponseSchema,
|
|
16
|
+
},
|
|
17
|
+
list: {
|
|
18
|
+
method: "GET",
|
|
19
|
+
path: "/orders",
|
|
20
|
+
request: zod_1.default.object({}),
|
|
21
|
+
response: zod_1.default.array(read_1.OrderReadResponseSchema),
|
|
22
|
+
},
|
|
23
|
+
getById: {
|
|
24
|
+
method: "GET",
|
|
25
|
+
path: "/orders/:id",
|
|
26
|
+
request: zod_1.default.object({
|
|
27
|
+
id: zod_1.default.coerce.number().positive(),
|
|
28
|
+
}),
|
|
29
|
+
response: read_1.OrderReadResponseSchema,
|
|
30
|
+
},
|
|
31
|
+
getUserOrders: {
|
|
32
|
+
method: "GET",
|
|
33
|
+
path: "/orders/user/:userId",
|
|
34
|
+
request: zod_1.default.object({
|
|
35
|
+
userId: zod_1.default.coerce.number().positive(),
|
|
36
|
+
}),
|
|
37
|
+
response: zod_1.default.array(read_1.OrderReadResponseSchema),
|
|
38
|
+
},
|
|
39
|
+
getUserOrderById: {
|
|
40
|
+
method: "GET",
|
|
41
|
+
path: "/orders/user/:userId/:orderId",
|
|
42
|
+
request: zod_1.default.object({
|
|
43
|
+
userId: zod_1.default.coerce.number().positive(),
|
|
44
|
+
orderId: zod_1.default.coerce.number().positive(),
|
|
45
|
+
}),
|
|
46
|
+
response: read_1.OrderReadResponseSchema,
|
|
47
|
+
},
|
|
48
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PromoCodeEndpoints = 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.PromoCodeEndpoints = {
|
|
9
|
+
create: {
|
|
10
|
+
method: "POST",
|
|
11
|
+
path: "/promo-codes",
|
|
12
|
+
request: create_1.PromoCodeCreateSchema,
|
|
13
|
+
response: read_1.PromoCodeReadResponseSchema,
|
|
14
|
+
},
|
|
15
|
+
list: {
|
|
16
|
+
method: "GET",
|
|
17
|
+
path: "/promo-codes",
|
|
18
|
+
request: zod_1.z.object({}),
|
|
19
|
+
response: zod_1.z.array(read_1.PromoCodeReadResponseSchema),
|
|
20
|
+
},
|
|
21
|
+
getById: {
|
|
22
|
+
method: "GET",
|
|
23
|
+
path: "/promo-codes/:id",
|
|
24
|
+
request: zod_1.z.object({
|
|
25
|
+
id: zod_1.z.coerce.number().positive(),
|
|
26
|
+
}),
|
|
27
|
+
response: read_1.PromoCodeReadResponseSchema,
|
|
28
|
+
},
|
|
29
|
+
getByValue: {
|
|
30
|
+
method: "GET",
|
|
31
|
+
path: "/promo-codes/value/:value",
|
|
32
|
+
request: zod_1.z.object({
|
|
33
|
+
value: zod_1.z.string(),
|
|
34
|
+
}),
|
|
35
|
+
response: read_1.PromoCodeReadResponseSchema,
|
|
36
|
+
},
|
|
37
|
+
update: {
|
|
38
|
+
method: "PATCH",
|
|
39
|
+
path: "/promo-codes/:id",
|
|
40
|
+
request: zod_1.z.object({
|
|
41
|
+
id: zod_1.z.coerce.number().positive(),
|
|
42
|
+
body: update_1.PromoCodeUpdateSchema,
|
|
43
|
+
}),
|
|
44
|
+
response: read_1.PromoCodeReadResponseSchema,
|
|
45
|
+
},
|
|
46
|
+
};
|
|
@@ -5,10 +5,10 @@ const zod_1 = require("zod");
|
|
|
5
5
|
const enums_1 = require("./enums");
|
|
6
6
|
exports.PromoCodeUpdateSchema = zod_1.z.object({
|
|
7
7
|
value: zod_1.z.string().optional(),
|
|
8
|
-
discountValue: zod_1.z.string(),
|
|
8
|
+
discountValue: zod_1.z.string().optional(),
|
|
9
9
|
expiredAt: zod_1.z.coerce.date().nullable().optional(),
|
|
10
10
|
activationLimit: zod_1.z.number().positive().nullable().optional(),
|
|
11
11
|
activationPerUserLimit: zod_1.z.number().positive().nullable().optional(),
|
|
12
|
-
type: enums_1.PromoCodeType,
|
|
13
|
-
status: enums_1.PromoCodeStatus,
|
|
12
|
+
type: enums_1.PromoCodeType.optional(),
|
|
13
|
+
status: enums_1.PromoCodeStatus.optional(),
|
|
14
14
|
});
|
|
@@ -5,4 +5,4 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.RefreshSessionStatus = void 0;
|
|
7
7
|
const zod_1 = __importDefault(require("zod"));
|
|
8
|
-
exports.RefreshSessionStatus = zod_1.default.enum(['ACTIVE', 'EXPIRED', 'BLOCKED']);
|
|
8
|
+
exports.RefreshSessionStatus = zod_1.default.enum(['ACTIVE', 'EXPIRED', 'BLOCKED', 'TERMINATED']);
|
|
@@ -7,10 +7,10 @@ exports.RefreshSessionUpdateSchema = void 0;
|
|
|
7
7
|
const zod_1 = __importDefault(require("zod"));
|
|
8
8
|
const enums_1 = require("./enums");
|
|
9
9
|
exports.RefreshSessionUpdateSchema = zod_1.default.object({
|
|
10
|
-
userId: zod_1.default.number(),
|
|
11
|
-
refreshToken: zod_1.default.string(),
|
|
10
|
+
userId: zod_1.default.number().optional(),
|
|
11
|
+
refreshToken: zod_1.default.string().optional(),
|
|
12
12
|
expiredAt: zod_1.default.coerce.date().nullable().optional(),
|
|
13
|
-
status: enums_1.RefreshSessionStatus,
|
|
13
|
+
status: enums_1.RefreshSessionStatus.optional(),
|
|
14
14
|
IP: zod_1.default.string().nullable().optional(),
|
|
15
15
|
UA: zod_1.default.string().nullable().optional(),
|
|
16
16
|
});
|
package/build/types.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
import { UserLoginResponseSchema } from "./login";
|
|
3
|
+
|
|
4
|
+
export const ConfirmCodeRequestSchema = z.object({
|
|
5
|
+
code: z.string().min(4),
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
export type ConfirmCodeRequest = z.infer<typeof ConfirmCodeRequestSchema>;
|
|
9
|
+
export type ConfirmCodeResponse = z.infer<typeof UserLoginResponseSchema>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
import { UserLoginRequestSchema, UserLoginResponseSchema } from "./login";
|
|
3
|
+
import { UserRegisterRequestSchema } from "./register";
|
|
4
|
+
import { EndpointContract } from "../../types";
|
|
5
|
+
import { ConfirmCodeRequestSchema } from "./confirm";
|
|
6
|
+
|
|
7
|
+
export const AuthEndpoints = {
|
|
8
|
+
login: {
|
|
9
|
+
method: "POST",
|
|
10
|
+
path: "/auth/login",
|
|
11
|
+
request: UserLoginRequestSchema,
|
|
12
|
+
response: UserLoginResponseSchema,
|
|
13
|
+
},
|
|
14
|
+
register: {
|
|
15
|
+
method: "POST",
|
|
16
|
+
path: "/auth/sign-up",
|
|
17
|
+
request: UserRegisterRequestSchema,
|
|
18
|
+
response: UserLoginResponseSchema,
|
|
19
|
+
},
|
|
20
|
+
confirm: {
|
|
21
|
+
method: "GET",
|
|
22
|
+
path: "/auth/confirm-code/:code",
|
|
23
|
+
request: ConfirmCodeRequestSchema,
|
|
24
|
+
response: UserLoginResponseSchema,
|
|
25
|
+
}
|
|
26
|
+
} satisfies Record<string, EndpointContract>;
|
|
27
|
+
|
|
28
|
+
export type AuthEndpointKey = keyof typeof AuthEndpoints;
|
|
29
|
+
|
|
30
|
+
export type GetAuthRequest<K extends AuthEndpointKey> = z.infer<typeof AuthEndpoints[K]["request"]>;
|
|
31
|
+
export type GetAuthResponse<K extends AuthEndpointKey> = z.infer<typeof AuthEndpoints[K]["response"]>;
|
package/commands/auth/index.ts
CHANGED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
OrderReadResponseSchema,
|
|
5
|
+
} from "./read";
|
|
6
|
+
|
|
7
|
+
import { EndpointContract } from "../../types";
|
|
8
|
+
import { OrderCreateRequestSchema, OrderCreateResponseSchema } from "./create";
|
|
9
|
+
|
|
10
|
+
export const OrderEndpoints = {
|
|
11
|
+
create: {
|
|
12
|
+
method: "POST",
|
|
13
|
+
path: "/orders",
|
|
14
|
+
request: OrderCreateRequestSchema,
|
|
15
|
+
response: OrderCreateResponseSchema,
|
|
16
|
+
},
|
|
17
|
+
list: {
|
|
18
|
+
method: "GET",
|
|
19
|
+
path: "/orders",
|
|
20
|
+
request: z.object({}),
|
|
21
|
+
response: z.array(OrderReadResponseSchema),
|
|
22
|
+
},
|
|
23
|
+
getById: {
|
|
24
|
+
method: "GET",
|
|
25
|
+
path: "/orders/:id",
|
|
26
|
+
request: z.object({
|
|
27
|
+
id: z.coerce.number().positive(),
|
|
28
|
+
}),
|
|
29
|
+
response: OrderReadResponseSchema,
|
|
30
|
+
},
|
|
31
|
+
getUserOrders: {
|
|
32
|
+
method: "GET",
|
|
33
|
+
path: "/orders/user/:userId",
|
|
34
|
+
request: z.object({
|
|
35
|
+
userId: z.coerce.number().positive(),
|
|
36
|
+
}),
|
|
37
|
+
response: z.array(OrderReadResponseSchema),
|
|
38
|
+
},
|
|
39
|
+
getUserOrderById: {
|
|
40
|
+
method: "GET",
|
|
41
|
+
path: "/orders/user/:userId/:orderId",
|
|
42
|
+
request: z.object({
|
|
43
|
+
userId: z.coerce.number().positive(),
|
|
44
|
+
orderId: z.coerce.number().positive(),
|
|
45
|
+
}),
|
|
46
|
+
response: OrderReadResponseSchema,
|
|
47
|
+
},
|
|
48
|
+
} satisfies Record<string, EndpointContract>;
|
|
49
|
+
|
|
50
|
+
export type OrderEndpointKey = keyof typeof OrderEndpoints;
|
|
51
|
+
|
|
52
|
+
export type GetOrderRequest<K extends OrderEndpointKey> =
|
|
53
|
+
z.infer<typeof OrderEndpoints[K]["request"]>;
|
|
54
|
+
|
|
55
|
+
export type GetOrderResponse<K extends OrderEndpointKey> =
|
|
56
|
+
z.infer<typeof OrderEndpoints[K]["response"]>;
|
package/commands/orders/index.ts
CHANGED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { EndpointContract } from "../../types";
|
|
3
|
+
import {
|
|
4
|
+
PromoCodeCreateSchema,
|
|
5
|
+
} from "./create";
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
PromoCodeReadResponseSchema,
|
|
9
|
+
} from "./read";
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
PromoCodeUpdateSchema,
|
|
13
|
+
} from "./update";
|
|
14
|
+
|
|
15
|
+
export const PromoCodeEndpoints = {
|
|
16
|
+
create: {
|
|
17
|
+
method: "POST",
|
|
18
|
+
path: "/promo-codes",
|
|
19
|
+
request: PromoCodeCreateSchema,
|
|
20
|
+
response: PromoCodeReadResponseSchema,
|
|
21
|
+
},
|
|
22
|
+
list: {
|
|
23
|
+
method: "GET",
|
|
24
|
+
path: "/promo-codes",
|
|
25
|
+
request: z.object({}),
|
|
26
|
+
response: z.array(PromoCodeReadResponseSchema),
|
|
27
|
+
},
|
|
28
|
+
getById: {
|
|
29
|
+
method: "GET",
|
|
30
|
+
path: "/promo-codes/:id",
|
|
31
|
+
request: z.object({
|
|
32
|
+
id: z.coerce.number().positive(),
|
|
33
|
+
}),
|
|
34
|
+
response: PromoCodeReadResponseSchema,
|
|
35
|
+
},
|
|
36
|
+
getByValue: {
|
|
37
|
+
method: "GET",
|
|
38
|
+
path: "/promo-codes/value/:value",
|
|
39
|
+
request: z.object({
|
|
40
|
+
value: z.string(),
|
|
41
|
+
}),
|
|
42
|
+
response: PromoCodeReadResponseSchema,
|
|
43
|
+
},
|
|
44
|
+
update: {
|
|
45
|
+
method: "PATCH",
|
|
46
|
+
path: "/promo-codes/:id",
|
|
47
|
+
request: z.object({
|
|
48
|
+
id: z.coerce.number().positive(),
|
|
49
|
+
body: PromoCodeUpdateSchema,
|
|
50
|
+
}),
|
|
51
|
+
response: PromoCodeReadResponseSchema,
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
} satisfies Record<string, EndpointContract>;
|
|
55
|
+
|
|
56
|
+
export type PromoCodeEndpointKey = keyof typeof PromoCodeEndpoints;
|
|
57
|
+
|
|
58
|
+
export type GetPromoCodeRequest<K extends PromoCodeEndpointKey> =
|
|
59
|
+
z.infer<typeof PromoCodeEndpoints[K]["request"]>;
|
|
60
|
+
|
|
61
|
+
export type GetPromoCodeResponse<K extends PromoCodeEndpointKey> =
|
|
62
|
+
z.infer<typeof PromoCodeEndpoints[K]["response"]>;
|
package/package.json
CHANGED