@gigapay-dev/contracts 1.3.7 → 1.3.9
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.
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.StatsEndpoints = void 0;
|
|
4
|
-
const zod_1 = require("zod");
|
|
5
4
|
const read_1 = require("./read");
|
|
5
|
+
const query_1 = require("./query");
|
|
6
6
|
exports.StatsEndpoints = {
|
|
7
7
|
list: {
|
|
8
8
|
method: "GET",
|
|
9
9
|
path: "/stats",
|
|
10
|
-
request:
|
|
10
|
+
request: query_1.StatsReadRequestSchema,
|
|
11
11
|
response: read_1.StatsReadResponseSchema,
|
|
12
12
|
},
|
|
13
13
|
};
|
|
@@ -0,0 +1,15 @@
|
|
|
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.StatsReadRequestSchema = void 0;
|
|
7
|
+
const zod_1 = __importDefault(require("zod"));
|
|
8
|
+
exports.StatsReadRequestSchema = zod_1.default
|
|
9
|
+
.object({
|
|
10
|
+
period: zod_1.default.enum(["day", "week", "month", "year", "custom"]).default("day"),
|
|
11
|
+
start: zod_1.default.string().datetime().optional(),
|
|
12
|
+
end: zod_1.default.string().datetime().optional(),
|
|
13
|
+
})
|
|
14
|
+
.refine(v => v.period !== "custom" || (v.start && v.end), { message: "from/to обязательны при period=custom" })
|
|
15
|
+
.refine(v => v.period !== "custom" || (new Date(v.start) < new Date(v.end)), { message: "from должен быть раньше to" });
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { EndpointContract } from "../../types";
|
|
3
3
|
import { StatsReadResponseSchema } from "./read";
|
|
4
|
+
import { StatsReadRequestSchema } from "./query";
|
|
4
5
|
|
|
5
6
|
export const StatsEndpoints = {
|
|
6
7
|
list: {
|
|
7
8
|
method: "GET",
|
|
8
9
|
path: "/stats",
|
|
9
|
-
request:
|
|
10
|
+
request: StatsReadRequestSchema,
|
|
10
11
|
response: StatsReadResponseSchema,
|
|
11
12
|
},
|
|
12
13
|
} satisfies Record<string, EndpointContract>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
|
|
3
|
+
export const StatsReadRequestSchema = z
|
|
4
|
+
.object({
|
|
5
|
+
period: z.enum(["day", "week", "month", "year", "custom"]).default("day"),
|
|
6
|
+
start: z.string().datetime().optional(),
|
|
7
|
+
end: z.string().datetime().optional(),
|
|
8
|
+
})
|
|
9
|
+
.refine(
|
|
10
|
+
v => v.period !== "custom" || (v.start && v.end),
|
|
11
|
+
{ message: "from/to обязательны при period=custom" }
|
|
12
|
+
)
|
|
13
|
+
.refine(
|
|
14
|
+
v => v.period !== "custom" || (new Date(v.start!) < new Date(v.end!)),
|
|
15
|
+
{ message: "from должен быть раньше to" }
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
export type StatsReadRequest = z.infer<typeof StatsReadRequestSchema>;
|