@giftup/zod 10.0.7
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/endpoints/auth.ts +35 -0
- package/endpoints/cases.ts +49 -0
- package/endpoints/crash.ts +6 -0
- package/endpoints/gifts.ts +41 -0
- package/endpoints/referrals.ts +20 -0
- package/endpoints/schema.ts +72 -0
- package/index.ts +6 -0
- package/models.ts +89 -0
- package/package.json +16 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
|
|
3
|
+
export const ValidateInitDataRequestSchema = z.object({
|
|
4
|
+
raw: z.string(),
|
|
5
|
+
})
|
|
6
|
+
|
|
7
|
+
export const ValidateInitDataResponseSchema = z.object({
|
|
8
|
+
isValid: z.boolean(),
|
|
9
|
+
token: z.string().optional(),
|
|
10
|
+
error: z.string().optional(),
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
export const MeResponseSchema = z.object({
|
|
14
|
+
id: z.string(),
|
|
15
|
+
chatId: z.number(),
|
|
16
|
+
firstName: z.string(),
|
|
17
|
+
lastName: z.string().optional().nullable(),
|
|
18
|
+
username: z.string().optional().nullable(),
|
|
19
|
+
languageCode: z.string(),
|
|
20
|
+
utmSource: z.string().nullable(),
|
|
21
|
+
photoUrl: z.string(),
|
|
22
|
+
isPremium: z.boolean(),
|
|
23
|
+
referrerId: z.number().nullable(),
|
|
24
|
+
isAdmin: z.boolean(),
|
|
25
|
+
balance: z.number(),
|
|
26
|
+
refBalance: z.number(),
|
|
27
|
+
createdAt: z.string(),
|
|
28
|
+
updatedAt: z.string(),
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
export type ValidateInitDataRequest = z.infer<typeof ValidateInitDataRequestSchema>
|
|
32
|
+
|
|
33
|
+
export type ValidateInitDataResponse = z.infer<typeof ValidateInitDataResponseSchema>
|
|
34
|
+
|
|
35
|
+
export type MeResponse = z.infer<typeof MeResponseSchema>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
import { CaseSchema } from '../models'
|
|
3
|
+
|
|
4
|
+
export const CasesListResponseSchema = z.object({
|
|
5
|
+
cases: z.array(CaseSchema),
|
|
6
|
+
})
|
|
7
|
+
|
|
8
|
+
export const CasesSpinRequestSchema = z.object({
|
|
9
|
+
caseId: z.string().cuid().min(1, 'api_error_case_id_required'),
|
|
10
|
+
count: z.number().int().min(1).max(3, 'api_error_case_count_max_3'),
|
|
11
|
+
isDemo: z.boolean().optional(),
|
|
12
|
+
promocode: z.string().min(1, 'api_error_promocode_invalid').optional().nullable(),
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
export const CasesSpinResponseSchema = z.object({
|
|
16
|
+
ok: z.boolean(),
|
|
17
|
+
isDemo: z.boolean().optional(),
|
|
18
|
+
gifts: z.array(
|
|
19
|
+
z.object({
|
|
20
|
+
id: z.string().cuid(),
|
|
21
|
+
giftUniqueId: z.string(),
|
|
22
|
+
baseName: z.string(),
|
|
23
|
+
name: z.string(),
|
|
24
|
+
price: z.number(),
|
|
25
|
+
sellPercent: z.number(),
|
|
26
|
+
})
|
|
27
|
+
),
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
export const CasesInfoResponseSchema = z.object({
|
|
31
|
+
access: z.object({
|
|
32
|
+
canOpen: z.boolean(),
|
|
33
|
+
reason: z.string(),
|
|
34
|
+
depositsSum: z.number(),
|
|
35
|
+
requiredAmount: z.number(),
|
|
36
|
+
}),
|
|
37
|
+
|
|
38
|
+
currentStep: z.number().int().nonnegative().optional(),
|
|
39
|
+
lastUsedDepositAt: z.date().optional(),
|
|
40
|
+
|
|
41
|
+
// FREE_DAILY поля
|
|
42
|
+
openedToday: z.boolean().optional(),
|
|
43
|
+
lastOpenedAt: z.date().optional(),
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
export type CasesListResponse = z.infer<typeof CasesListResponseSchema>
|
|
47
|
+
export type CasesSpinRequest = z.infer<typeof CasesSpinRequestSchema>
|
|
48
|
+
export type CasesSpinResponse = z.infer<typeof CasesSpinResponseSchema>
|
|
49
|
+
export type CasesInfoResponse = z.infer<typeof CasesInfoResponseSchema>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
|
|
3
|
+
export const CrashPlaceBetRequestSchema = z.object({
|
|
4
|
+
giftIds: z.array(z.string().cuid()).min(1, 'giftIds must contain at least one valid UUID').optional(),
|
|
5
|
+
amount: z.number().positive().min(0.01, 'Amount must be greater than 0.01').optional(),
|
|
6
|
+
})
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
import { FloorGiftSchema, GiftSchema } from '../models'
|
|
3
|
+
|
|
4
|
+
export const GiftsOwnedListResponseSchema = z.object({
|
|
5
|
+
gifts: z.array(GiftSchema),
|
|
6
|
+
})
|
|
7
|
+
|
|
8
|
+
const GiftPriceRange = FloorGiftSchema.extend({
|
|
9
|
+
from: z.number(),
|
|
10
|
+
to: z.number(),
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
export const GiftsPriceRangeResponseSchema = z.object({
|
|
14
|
+
ranges: z.array(GiftPriceRange),
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
export const GiftsWithdrawRequestSchema = z.object({
|
|
18
|
+
giftIds: z.array(z.string()),
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
export const GiftsWithdrawResponseSchema = z.object({
|
|
22
|
+
success: z.boolean(),
|
|
23
|
+
countWithdrawn: z.number(),
|
|
24
|
+
manuallyWithdrawnGiftsCount: z.number(),
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
export const GiftsSellRequestSchema = z.object({
|
|
28
|
+
giftIds: z.array(z.string().cuid()).min(1, 'giftIds must contain at least one valid CUID'),
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
export const GiftsSellResponseSchema = z.object({
|
|
32
|
+
success: z.boolean(),
|
|
33
|
+
amount: z.number(),
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
export type GiftsOwnedListResponse = z.infer<typeof GiftsOwnedListResponseSchema>
|
|
37
|
+
|
|
38
|
+
export type GiftsPriceRangeResponse = z.infer<typeof GiftsPriceRangeResponseSchema>
|
|
39
|
+
|
|
40
|
+
export type GiftPriceRange = z.infer<typeof GiftPriceRange>
|
|
41
|
+
export type GiftsSellResponse = z.infer<typeof GiftsSellResponseSchema>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
|
|
3
|
+
export const referralsListResponseSchema = z.object({
|
|
4
|
+
referrals: z.array(
|
|
5
|
+
z.object({
|
|
6
|
+
user: z.object({
|
|
7
|
+
id: z.string(),
|
|
8
|
+
chatId: z.number(),
|
|
9
|
+
firstName: z.string(),
|
|
10
|
+
lastName: z.string().optional().nullable(),
|
|
11
|
+
username: z.string().optional().nullable(),
|
|
12
|
+
languageCode: z.string(),
|
|
13
|
+
photoUrl: z.string(),
|
|
14
|
+
}),
|
|
15
|
+
totalAmount: z.number(),
|
|
16
|
+
})
|
|
17
|
+
),
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
export type referralsListResponse = z.infer<typeof referralsListResponseSchema>
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export const endpoints = {
|
|
2
|
+
app: {
|
|
3
|
+
maintenance_settings: {
|
|
4
|
+
url: '/app/maintenance_settings',
|
|
5
|
+
method: 'GET',
|
|
6
|
+
},
|
|
7
|
+
},
|
|
8
|
+
auth: {
|
|
9
|
+
validate_init_data: { url: '/auth/validateInitData', method: 'POST' },
|
|
10
|
+
me: { url: '/auth/me', method: 'GET' },
|
|
11
|
+
},
|
|
12
|
+
boxes: {
|
|
13
|
+
list: { url: '/boxes', method: 'GET' },
|
|
14
|
+
get: { url: '/boxes/:id', method: 'GET' },
|
|
15
|
+
spin: { url: '/boxes/:id/spin', method: 'POST' },
|
|
16
|
+
},
|
|
17
|
+
gifts: {
|
|
18
|
+
list: {
|
|
19
|
+
url: '/gifts',
|
|
20
|
+
method: 'GET',
|
|
21
|
+
},
|
|
22
|
+
price_range: {
|
|
23
|
+
url: '/gifts/price_range',
|
|
24
|
+
method: 'GET',
|
|
25
|
+
},
|
|
26
|
+
withdraw: {
|
|
27
|
+
url: '/gifts/withdraw',
|
|
28
|
+
method: 'POST',
|
|
29
|
+
},
|
|
30
|
+
sell: {
|
|
31
|
+
url: '/gifts/sell',
|
|
32
|
+
method: 'POST',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
cases: {
|
|
36
|
+
list: { url: '/cases', method: 'GET' },
|
|
37
|
+
spin: { url: '/cases/spin', method: 'POST' },
|
|
38
|
+
caseInfo: { url: '/cases/info', method: 'GET' },
|
|
39
|
+
checkSubscribe: { url: '/cases/check_subscribe', method: 'GET' },
|
|
40
|
+
},
|
|
41
|
+
referrals: {
|
|
42
|
+
list: { url: '/referrals', method: 'GET' },
|
|
43
|
+
prepared_share_message_id: {
|
|
44
|
+
url: '/referrals/prepared_share_message_id',
|
|
45
|
+
method: 'GET',
|
|
46
|
+
},
|
|
47
|
+
referral_link: {
|
|
48
|
+
url: '/referrals/referral_link',
|
|
49
|
+
method: 'GET',
|
|
50
|
+
},
|
|
51
|
+
balance: {
|
|
52
|
+
url: '/referrals/balance',
|
|
53
|
+
method: 'GET',
|
|
54
|
+
},
|
|
55
|
+
withdraw: {
|
|
56
|
+
url: '/referrals/withdraw',
|
|
57
|
+
method: 'POST',
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
banners: {
|
|
61
|
+
list: { url: '/banners', method: 'GET' },
|
|
62
|
+
},
|
|
63
|
+
balance: {
|
|
64
|
+
deposit: { url: '/balance/deposit', method: 'POST' },
|
|
65
|
+
},
|
|
66
|
+
promocodes: {
|
|
67
|
+
check: {
|
|
68
|
+
url: '/promocodes/check',
|
|
69
|
+
method: 'GET',
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
}
|
package/index.ts
ADDED
package/models.ts
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
|
|
3
|
+
export const GiftSchema = z.object({
|
|
4
|
+
id: z.string().cuid(),
|
|
5
|
+
baseName: z.string(),
|
|
6
|
+
ownedGiftId: z.string(),
|
|
7
|
+
name: z.string(),
|
|
8
|
+
number: z.number().int(),
|
|
9
|
+
ownerId: z.bigint(),
|
|
10
|
+
floorPrice: z.number().nonnegative().optional().nullable(),
|
|
11
|
+
sellPrice: z.number().int().nonnegative(),
|
|
12
|
+
createdAt: z.date(),
|
|
13
|
+
updatedAt: z.date(),
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
export const PromocodeSchema = z.object({
|
|
17
|
+
id: z.string().cuid(),
|
|
18
|
+
name: z.string().min(1),
|
|
19
|
+
code: z.string().min(1),
|
|
20
|
+
discount: z.number().int().min(0).max(100),
|
|
21
|
+
isActive: z.boolean(),
|
|
22
|
+
expiresAt: z.date().nullable(),
|
|
23
|
+
|
|
24
|
+
usageLimit: z.number().int().positive().nullable(),
|
|
25
|
+
usageCount: z.number().int().nonnegative(),
|
|
26
|
+
|
|
27
|
+
caseId: z.string().min(1),
|
|
28
|
+
|
|
29
|
+
createdAt: z.date(),
|
|
30
|
+
updatedAt: z.date(),
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
export const PromocodeActivationSchema = z.object({
|
|
34
|
+
id: z.string().cuid(),
|
|
35
|
+
promocodeId: z.string().min(1),
|
|
36
|
+
userId: z.string().min(1),
|
|
37
|
+
activatedAt: z.date(),
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
export const FloorGiftSchema = z.object({
|
|
41
|
+
id: z.string().cuid(),
|
|
42
|
+
baseName: z.string(),
|
|
43
|
+
name: z.string(),
|
|
44
|
+
sellPercent: z.number().int().nonnegative(),
|
|
45
|
+
price: z.number(),
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
export const CaseItemSchema = z.object({
|
|
49
|
+
id: z.string().cuid(),
|
|
50
|
+
caseId: z.string(),
|
|
51
|
+
type: z.enum(['gift', 'ton']),
|
|
52
|
+
isCrossOut: z.boolean().default(false).optional(),
|
|
53
|
+
sequence: z.number().int().default(0).optional(),
|
|
54
|
+
amount: z.number().int().nonnegative().default(1).optional(),
|
|
55
|
+
giftId: z.string().optional(),
|
|
56
|
+
gift: FloorGiftSchema.optional(),
|
|
57
|
+
createdAt: z.date(),
|
|
58
|
+
updatedAt: z.date(),
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
export const CaseSchema = z.object({
|
|
62
|
+
id: z.string().cuid(),
|
|
63
|
+
name: z.string(),
|
|
64
|
+
price: z.number().int().nonnegative(),
|
|
65
|
+
image: z.string(),
|
|
66
|
+
sequence: z.number().int().default(0).optional(),
|
|
67
|
+
chanceMiddle: z.number().int().default(0).optional(),
|
|
68
|
+
margin: z.number().int().default(0).optional(),
|
|
69
|
+
bank: z.number().int().default(0).optional(),
|
|
70
|
+
items: z.array(CaseItemSchema),
|
|
71
|
+
|
|
72
|
+
isNeedPromo: z.boolean().default(false).optional(),
|
|
73
|
+
isAllowPromo: z.boolean().default(false).optional(),
|
|
74
|
+
isNeedSubscribe: z.boolean().default(false).optional(),
|
|
75
|
+
|
|
76
|
+
type: z.enum(['PAID', 'FREE_SCALING', 'FREE_DAILY']),
|
|
77
|
+
|
|
78
|
+
minDeposit: z.number().optional(),
|
|
79
|
+
scalingMultiplier: z.number().optional(),
|
|
80
|
+
|
|
81
|
+
dailyDepositThreshold: z.number().optional(),
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
export type Gift = z.infer<typeof GiftSchema>
|
|
85
|
+
export type Case = z.infer<typeof CaseSchema>
|
|
86
|
+
export type CaseItem = z.infer<typeof CaseItemSchema>
|
|
87
|
+
export type FloorGift = z.infer<typeof FloorGiftSchema>
|
|
88
|
+
export type Promocode = z.infer<typeof PromocodeSchema>
|
|
89
|
+
export type PromocodeActivation = z.infer<typeof PromocodeActivationSchema>
|
package/package.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@giftup/zod",
|
|
3
|
+
"version": "10.0.7",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
7
|
+
"prepublish": "rm -rf build && tsc"
|
|
8
|
+
},
|
|
9
|
+
"author": "",
|
|
10
|
+
"license": "ISC",
|
|
11
|
+
"description": "",
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"giftup-zod": "^1.0.29",
|
|
14
|
+
"zod": "^3.24.3"
|
|
15
|
+
}
|
|
16
|
+
}
|