@vbotma/transformers 1.1.3
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/LICENSE +21 -0
- package/dist/dts/index.d.ts +5 -0
- package/dist/dts/parsers.d.ts +165 -0
- package/dist/dts/pipes.d.ts +17 -0
- package/dist/dts/rgb.d.ts +57 -0
- package/dist/dts/serializers.d.ts +15 -0
- package/dist/dts/structures.d.ts +250 -0
- package/dist/dts/transformers.d.ts +22 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.js +235 -0
- package/dist/index.js.map +1 -0
- package/package.json +46 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Vladislav Kibenko
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { either as E } from 'fp-ts';
|
|
2
|
+
import { ValiError } from 'valibot';
|
|
3
|
+
import { InitDataGenSchema, InitDataGenType, LaunchParamsGenSchema, LaunchParamsGenType } from './structures.js';
|
|
4
|
+
export type ParseInitDataQueryError = ValiError<InitDataGenSchema>;
|
|
5
|
+
export type ParseLaunchParamsQueryError = ValiError<LaunchParamsGenSchema>;
|
|
6
|
+
export declare function parseInitDataQueryFp(value: string | URLSearchParams): E.Either<ParseInitDataQueryError, InitDataGenType>;
|
|
7
|
+
export declare function parseLaunchParamsQueryFp(value: string | URLSearchParams): E.Either<ParseLaunchParamsQueryError, LaunchParamsGenType>;
|
|
8
|
+
export declare const parseInitDataQuery: ((value: string | URLSearchParams) => {
|
|
9
|
+
auth_date: Date;
|
|
10
|
+
can_send_after?: number | undefined;
|
|
11
|
+
chat?: ({
|
|
12
|
+
id: number;
|
|
13
|
+
photo_url?: string | undefined;
|
|
14
|
+
type: string;
|
|
15
|
+
title: string;
|
|
16
|
+
username?: string | undefined;
|
|
17
|
+
} & {
|
|
18
|
+
[key: string]: unknown;
|
|
19
|
+
}) | undefined;
|
|
20
|
+
chat_type?: string | undefined;
|
|
21
|
+
chat_instance?: string | undefined;
|
|
22
|
+
hash?: string | undefined;
|
|
23
|
+
query_id?: string | undefined;
|
|
24
|
+
receiver?: ({
|
|
25
|
+
added_to_attachment_menu?: boolean | undefined;
|
|
26
|
+
allows_write_to_pm?: boolean | undefined;
|
|
27
|
+
first_name: string;
|
|
28
|
+
id: number;
|
|
29
|
+
is_bot?: boolean | undefined;
|
|
30
|
+
is_premium?: boolean | undefined;
|
|
31
|
+
last_name?: string | undefined;
|
|
32
|
+
language_code?: string | undefined;
|
|
33
|
+
photo_url?: string | undefined;
|
|
34
|
+
username?: string | undefined;
|
|
35
|
+
} & {
|
|
36
|
+
[key: string]: unknown;
|
|
37
|
+
}) | undefined;
|
|
38
|
+
start_param?: string | undefined;
|
|
39
|
+
signature?: string | undefined;
|
|
40
|
+
user?: ({
|
|
41
|
+
added_to_attachment_menu?: boolean | undefined;
|
|
42
|
+
allows_write_to_pm?: boolean | undefined;
|
|
43
|
+
first_name: string;
|
|
44
|
+
id: number;
|
|
45
|
+
is_bot?: boolean | undefined;
|
|
46
|
+
is_premium?: boolean | undefined;
|
|
47
|
+
last_name?: string | undefined;
|
|
48
|
+
language_code?: string | undefined;
|
|
49
|
+
photo_url?: string | undefined;
|
|
50
|
+
username?: string | undefined;
|
|
51
|
+
} & {
|
|
52
|
+
[key: string]: unknown;
|
|
53
|
+
}) | undefined;
|
|
54
|
+
auth?: ({
|
|
55
|
+
projectCode: string;
|
|
56
|
+
uid: string;
|
|
57
|
+
sessionId: string;
|
|
58
|
+
rootToken: string;
|
|
59
|
+
} & {
|
|
60
|
+
[key: string]: unknown;
|
|
61
|
+
}) | undefined;
|
|
62
|
+
} & {
|
|
63
|
+
[key: string]: unknown;
|
|
64
|
+
}) & {};
|
|
65
|
+
export declare const parseLaunchParamsQuery: ((value: string | URLSearchParams) => {
|
|
66
|
+
vbWebAppBotInline?: boolean | undefined;
|
|
67
|
+
vbWebAppData?: ({
|
|
68
|
+
auth_date: Date;
|
|
69
|
+
can_send_after?: number | undefined;
|
|
70
|
+
chat?: ({
|
|
71
|
+
id: number;
|
|
72
|
+
photo_url?: string | undefined;
|
|
73
|
+
type: string;
|
|
74
|
+
title: string;
|
|
75
|
+
username?: string | undefined;
|
|
76
|
+
} & {
|
|
77
|
+
[key: string]: unknown;
|
|
78
|
+
}) | undefined;
|
|
79
|
+
chat_type?: string | undefined;
|
|
80
|
+
chat_instance?: string | undefined;
|
|
81
|
+
hash?: string | undefined;
|
|
82
|
+
query_id?: string | undefined;
|
|
83
|
+
receiver?: ({
|
|
84
|
+
added_to_attachment_menu?: boolean | undefined;
|
|
85
|
+
allows_write_to_pm?: boolean | undefined;
|
|
86
|
+
first_name: string;
|
|
87
|
+
id: number;
|
|
88
|
+
is_bot?: boolean | undefined;
|
|
89
|
+
is_premium?: boolean | undefined;
|
|
90
|
+
last_name?: string | undefined;
|
|
91
|
+
language_code?: string | undefined;
|
|
92
|
+
photo_url?: string | undefined;
|
|
93
|
+
username?: string | undefined;
|
|
94
|
+
} & {
|
|
95
|
+
[key: string]: unknown;
|
|
96
|
+
}) | undefined;
|
|
97
|
+
start_param?: string | undefined;
|
|
98
|
+
signature?: string | undefined;
|
|
99
|
+
user?: ({
|
|
100
|
+
added_to_attachment_menu?: boolean | undefined;
|
|
101
|
+
allows_write_to_pm?: boolean | undefined;
|
|
102
|
+
first_name: string;
|
|
103
|
+
id: number;
|
|
104
|
+
is_bot?: boolean | undefined;
|
|
105
|
+
is_premium?: boolean | undefined;
|
|
106
|
+
last_name?: string | undefined;
|
|
107
|
+
language_code?: string | undefined;
|
|
108
|
+
photo_url?: string | undefined;
|
|
109
|
+
username?: string | undefined;
|
|
110
|
+
} & {
|
|
111
|
+
[key: string]: unknown;
|
|
112
|
+
}) | undefined;
|
|
113
|
+
auth?: ({
|
|
114
|
+
projectCode: string;
|
|
115
|
+
uid: string;
|
|
116
|
+
sessionId: string;
|
|
117
|
+
rootToken: string;
|
|
118
|
+
} & {
|
|
119
|
+
[key: string]: unknown;
|
|
120
|
+
}) | undefined;
|
|
121
|
+
} & {
|
|
122
|
+
[key: string]: unknown;
|
|
123
|
+
}) | undefined;
|
|
124
|
+
vbWebAppDefaultColors?: {
|
|
125
|
+
accent_text_color?: `#${string}` | undefined;
|
|
126
|
+
bg_color?: `#${string}` | undefined;
|
|
127
|
+
button_color?: `#${string}` | undefined;
|
|
128
|
+
button_text_color?: `#${string}` | undefined;
|
|
129
|
+
bottom_bar_bg_color?: `#${string}` | undefined;
|
|
130
|
+
destructive_text_color?: `#${string}` | undefined;
|
|
131
|
+
header_bg_color?: `#${string}` | undefined;
|
|
132
|
+
hint_color?: `#${string}` | undefined;
|
|
133
|
+
link_color?: `#${string}` | undefined;
|
|
134
|
+
secondary_bg_color?: `#${string}` | undefined;
|
|
135
|
+
section_bg_color?: `#${string}` | undefined;
|
|
136
|
+
section_header_text_color?: `#${string}` | undefined;
|
|
137
|
+
section_separator_color?: `#${string}` | undefined;
|
|
138
|
+
subtitle_text_color?: `#${string}` | undefined;
|
|
139
|
+
text_color?: `#${string}` | undefined;
|
|
140
|
+
} | undefined;
|
|
141
|
+
vbWebAppFullscreen?: boolean | undefined;
|
|
142
|
+
vbWebAppPlatform: string;
|
|
143
|
+
vbWebAppShowSettings?: boolean | undefined;
|
|
144
|
+
vbWebAppStartParam?: string | undefined;
|
|
145
|
+
vbWebAppThemeParams: {
|
|
146
|
+
accent_text_color?: `#${string}` | undefined;
|
|
147
|
+
bg_color?: `#${string}` | undefined;
|
|
148
|
+
button_color?: `#${string}` | undefined;
|
|
149
|
+
button_text_color?: `#${string}` | undefined;
|
|
150
|
+
bottom_bar_bg_color?: `#${string}` | undefined;
|
|
151
|
+
destructive_text_color?: `#${string}` | undefined;
|
|
152
|
+
header_bg_color?: `#${string}` | undefined;
|
|
153
|
+
hint_color?: `#${string}` | undefined;
|
|
154
|
+
link_color?: `#${string}` | undefined;
|
|
155
|
+
secondary_bg_color?: `#${string}` | undefined;
|
|
156
|
+
section_bg_color?: `#${string}` | undefined;
|
|
157
|
+
section_header_text_color?: `#${string}` | undefined;
|
|
158
|
+
section_separator_color?: `#${string}` | undefined;
|
|
159
|
+
subtitle_text_color?: `#${string}` | undefined;
|
|
160
|
+
text_color?: `#${string}` | undefined;
|
|
161
|
+
};
|
|
162
|
+
vbWebAppVersion: string;
|
|
163
|
+
} & {
|
|
164
|
+
[key: string]: unknown;
|
|
165
|
+
}) & {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BaseIssue, BaseSchema, InstanceSchema, SchemaWithPipe, StringSchema, UnionSchema } from 'valibot';
|
|
2
|
+
import { TransformJsonToSchemaAction, TransformQueryToSchemaAction } from './transformers.js';
|
|
3
|
+
type RequiredSchema = BaseSchema<any, any, BaseIssue<any>>;
|
|
4
|
+
export type JsonToSchemaPipe<Schema extends RequiredSchema> = SchemaWithPipe<readonly [
|
|
5
|
+
StringSchema<undefined>,
|
|
6
|
+
TransformJsonToSchemaAction<Schema>
|
|
7
|
+
]>;
|
|
8
|
+
export type QueryToSchemaPipe<Schema extends RequiredSchema> = SchemaWithPipe<readonly [
|
|
9
|
+
UnionSchema<[
|
|
10
|
+
StringSchema<undefined>,
|
|
11
|
+
InstanceSchema<typeof URLSearchParams, undefined>
|
|
12
|
+
], undefined>,
|
|
13
|
+
TransformQueryToSchemaAction<Schema>
|
|
14
|
+
]>;
|
|
15
|
+
export declare function pipeJsonToSchema<Schema extends RequiredSchema>(schema: Schema): JsonToSchemaPipe<Schema>;
|
|
16
|
+
export declare function pipeQueryToSchema<Schema extends RequiredSchema>(schema: Schema): QueryToSchemaPipe<Schema>;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { RGB } from '@vbotma/types';
|
|
2
|
+
import { either as E } from 'fp-ts';
|
|
3
|
+
/**
|
|
4
|
+
* @returns True if the value has the #RGB format.
|
|
5
|
+
*/
|
|
6
|
+
export declare const isRGBShort: (value: string) => value is RGB;
|
|
7
|
+
/**
|
|
8
|
+
* @returns True if the value has the #RGBA format.
|
|
9
|
+
*/
|
|
10
|
+
export declare const isRGBAShort: (value: string) => value is RGB;
|
|
11
|
+
/**
|
|
12
|
+
* @returns True if the value has the #RRGGBB format.
|
|
13
|
+
*/
|
|
14
|
+
export declare const isRGB: (value: string) => value is RGB;
|
|
15
|
+
/**
|
|
16
|
+
* @returns True if the value has the #RRGGBBAA format.
|
|
17
|
+
*/
|
|
18
|
+
export declare const isRGBA: (value: string) => value is RGB;
|
|
19
|
+
/**
|
|
20
|
+
* @returns True if the value has any known RGB format.
|
|
21
|
+
* @param value - value to check.
|
|
22
|
+
*/
|
|
23
|
+
export declare function isAnyRGB(value: string): value is RGB;
|
|
24
|
+
/**
|
|
25
|
+
* Converts passed value to #RRGGBBAA format. Accepts the following color formats:
|
|
26
|
+
* - `#RGB`
|
|
27
|
+
* - `#RGBA`
|
|
28
|
+
* - `#RRGGBB`
|
|
29
|
+
* - `#RRGGBBAA`
|
|
30
|
+
* - `rgb(1,2,3)`
|
|
31
|
+
* - `rgba(1,2,3,4)`
|
|
32
|
+
* @param value - a value to convert.
|
|
33
|
+
* @returns A value in the #RRGGBBAA format.
|
|
34
|
+
*/
|
|
35
|
+
export declare function toRGBFullFp(value: string): E.Either<Error, RGB>;
|
|
36
|
+
/**
|
|
37
|
+
* Converts passed value to #RRGGBB format. Accepts the following color formats:
|
|
38
|
+
* - `#RGB`
|
|
39
|
+
* - `#RGBA`
|
|
40
|
+
* - `#RRGGBB`
|
|
41
|
+
* - `#RRGGBBAA`
|
|
42
|
+
* - `rgb(1,2,3)`
|
|
43
|
+
* - `rgba(1,2,3,4)`
|
|
44
|
+
* @param value - a value to convert.
|
|
45
|
+
* @returns A value in the #RRGGBB format.
|
|
46
|
+
* @deprecated This function cuts the RGB's alpha channel. Use the `toRGBFullFp` function instead.
|
|
47
|
+
*/
|
|
48
|
+
export declare function toRGBFp(value: string): E.Either<Error, RGB>;
|
|
49
|
+
/**
|
|
50
|
+
* @see toRGBFp
|
|
51
|
+
* @deprecated This function cuts the RGB's alpha channel. Use the `toRGBFull` function instead.
|
|
52
|
+
*/
|
|
53
|
+
export declare const toRGB: ((value: string) => `#${string}`) & {};
|
|
54
|
+
/**
|
|
55
|
+
* @see toRGBFullFp
|
|
56
|
+
*/
|
|
57
|
+
export declare const toRGBFull: ((value: string) => `#${string}`) & {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { InitData, LaunchParams } from '@vbotma/types';
|
|
2
|
+
import { InferOutput } from 'valibot';
|
|
3
|
+
import { initData, launchParams } from './structures.js';
|
|
4
|
+
export type InitDataLike = Partial<InferOutput<ReturnType<typeof initData>> | InitData>;
|
|
5
|
+
export type LaunchParamsLike = Partial<InferOutput<ReturnType<typeof launchParams>> | LaunchParams>;
|
|
6
|
+
/**
|
|
7
|
+
* Serializes the InitDataQuery shape.
|
|
8
|
+
* @param value - value to serialize.
|
|
9
|
+
*/
|
|
10
|
+
export declare function serializeInitDataQuery(value: InitDataLike): string;
|
|
11
|
+
/**
|
|
12
|
+
* Serializes the LaunchParamsQuery shape.
|
|
13
|
+
* @param value - value to serialize.
|
|
14
|
+
*/
|
|
15
|
+
export declare function serializeLaunchParamsQuery(value: LaunchParamsLike): string;
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { KnownThemeParamsKey, RGB } from '@vbotma/types';
|
|
2
|
+
import { CheckAction, InferOutput, NumberSchema, RecordSchema, SchemaWithPipe, StringSchema, TransformAction, UnionSchema } from 'valibot';
|
|
3
|
+
export type InitDataGenSchema = ReturnType<typeof initData>;
|
|
4
|
+
export type InitDataGenType = InferOutput<InitDataGenSchema>;
|
|
5
|
+
export type LaunchParamsGenSchema = ReturnType<typeof launchParams>;
|
|
6
|
+
export type LaunchParamsGenType = InferOutput<LaunchParamsGenSchema>;
|
|
7
|
+
export type MiniAppsMessageGenSchema = ReturnType<typeof miniAppsMessage>;
|
|
8
|
+
export type MiniAppsMessageGenType = InferOutput<MiniAppsMessageGenSchema>;
|
|
9
|
+
export declare function initDataChat(): import('valibot').LooseObjectSchema<{
|
|
10
|
+
id: NumberSchema<undefined>;
|
|
11
|
+
photo_url: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
12
|
+
type: StringSchema<undefined>;
|
|
13
|
+
title: StringSchema<undefined>;
|
|
14
|
+
username: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
15
|
+
}, undefined>;
|
|
16
|
+
export declare function initDataUser(): import('valibot').LooseObjectSchema<{
|
|
17
|
+
added_to_attachment_menu: import('valibot').OptionalSchema<import('valibot').BooleanSchema<undefined>, undefined>;
|
|
18
|
+
allows_write_to_pm: import('valibot').OptionalSchema<import('valibot').BooleanSchema<undefined>, undefined>;
|
|
19
|
+
first_name: StringSchema<undefined>;
|
|
20
|
+
id: NumberSchema<undefined>;
|
|
21
|
+
is_bot: import('valibot').OptionalSchema<import('valibot').BooleanSchema<undefined>, undefined>;
|
|
22
|
+
is_premium: import('valibot').OptionalSchema<import('valibot').BooleanSchema<undefined>, undefined>;
|
|
23
|
+
last_name: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
24
|
+
language_code: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
25
|
+
photo_url: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
26
|
+
username: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
27
|
+
}, undefined>;
|
|
28
|
+
export declare function initDataAuth(): import('valibot').LooseObjectSchema<{
|
|
29
|
+
projectCode: StringSchema<undefined>;
|
|
30
|
+
uid: StringSchema<undefined>;
|
|
31
|
+
sessionId: StringSchema<undefined>;
|
|
32
|
+
rootToken: StringSchema<undefined>;
|
|
33
|
+
}, undefined>;
|
|
34
|
+
export declare function initData(): import('valibot').LooseObjectSchema<{
|
|
35
|
+
auth_date: SchemaWithPipe<readonly [StringSchema<undefined>, TransformAction<string, Date>, import('valibot').DateSchema<undefined>]>;
|
|
36
|
+
can_send_after: import('valibot').OptionalSchema<SchemaWithPipe<readonly [StringSchema<undefined>, TransformAction<any, number>, import('valibot').IntegerAction<number, undefined>]>, undefined>;
|
|
37
|
+
chat: import('valibot').OptionalSchema<import('./pipes.js').JsonToSchemaPipe<import('valibot').LooseObjectSchema<{
|
|
38
|
+
id: NumberSchema<undefined>;
|
|
39
|
+
photo_url: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
40
|
+
type: StringSchema<undefined>;
|
|
41
|
+
title: StringSchema<undefined>;
|
|
42
|
+
username: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
43
|
+
}, undefined>>, undefined>;
|
|
44
|
+
chat_type: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
45
|
+
chat_instance: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
46
|
+
hash: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
47
|
+
query_id: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
48
|
+
receiver: import('valibot').OptionalSchema<import('./pipes.js').JsonToSchemaPipe<import('valibot').LooseObjectSchema<{
|
|
49
|
+
added_to_attachment_menu: import('valibot').OptionalSchema<import('valibot').BooleanSchema<undefined>, undefined>;
|
|
50
|
+
allows_write_to_pm: import('valibot').OptionalSchema<import('valibot').BooleanSchema<undefined>, undefined>;
|
|
51
|
+
first_name: StringSchema<undefined>;
|
|
52
|
+
id: NumberSchema<undefined>;
|
|
53
|
+
is_bot: import('valibot').OptionalSchema<import('valibot').BooleanSchema<undefined>, undefined>;
|
|
54
|
+
is_premium: import('valibot').OptionalSchema<import('valibot').BooleanSchema<undefined>, undefined>;
|
|
55
|
+
last_name: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
56
|
+
language_code: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
57
|
+
photo_url: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
58
|
+
username: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
59
|
+
}, undefined>>, undefined>;
|
|
60
|
+
start_param: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
61
|
+
signature: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
62
|
+
user: import('valibot').OptionalSchema<import('./pipes.js').JsonToSchemaPipe<import('valibot').LooseObjectSchema<{
|
|
63
|
+
added_to_attachment_menu: import('valibot').OptionalSchema<import('valibot').BooleanSchema<undefined>, undefined>;
|
|
64
|
+
allows_write_to_pm: import('valibot').OptionalSchema<import('valibot').BooleanSchema<undefined>, undefined>;
|
|
65
|
+
first_name: StringSchema<undefined>;
|
|
66
|
+
id: NumberSchema<undefined>;
|
|
67
|
+
is_bot: import('valibot').OptionalSchema<import('valibot').BooleanSchema<undefined>, undefined>;
|
|
68
|
+
is_premium: import('valibot').OptionalSchema<import('valibot').BooleanSchema<undefined>, undefined>;
|
|
69
|
+
last_name: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
70
|
+
language_code: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
71
|
+
photo_url: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
72
|
+
username: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
73
|
+
}, undefined>>, undefined>;
|
|
74
|
+
auth: import('valibot').OptionalSchema<import('./pipes.js').JsonToSchemaPipe<import('valibot').LooseObjectSchema<{
|
|
75
|
+
projectCode: StringSchema<undefined>;
|
|
76
|
+
uid: StringSchema<undefined>;
|
|
77
|
+
sessionId: StringSchema<undefined>;
|
|
78
|
+
rootToken: StringSchema<undefined>;
|
|
79
|
+
}, undefined>>, undefined>;
|
|
80
|
+
}, undefined>;
|
|
81
|
+
export declare function initDataQuery(): import('./pipes.js').QueryToSchemaPipe<import('valibot').LooseObjectSchema<{
|
|
82
|
+
auth_date: SchemaWithPipe<readonly [StringSchema<undefined>, TransformAction<string, Date>, import('valibot').DateSchema<undefined>]>;
|
|
83
|
+
can_send_after: import('valibot').OptionalSchema<SchemaWithPipe<readonly [StringSchema<undefined>, TransformAction<any, number>, import('valibot').IntegerAction<number, undefined>]>, undefined>;
|
|
84
|
+
chat: import('valibot').OptionalSchema<import('./pipes.js').JsonToSchemaPipe<import('valibot').LooseObjectSchema<{
|
|
85
|
+
id: NumberSchema<undefined>;
|
|
86
|
+
photo_url: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
87
|
+
type: StringSchema<undefined>;
|
|
88
|
+
title: StringSchema<undefined>;
|
|
89
|
+
username: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
90
|
+
}, undefined>>, undefined>;
|
|
91
|
+
chat_type: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
92
|
+
chat_instance: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
93
|
+
hash: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
94
|
+
query_id: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
95
|
+
receiver: import('valibot').OptionalSchema<import('./pipes.js').JsonToSchemaPipe<import('valibot').LooseObjectSchema<{
|
|
96
|
+
added_to_attachment_menu: import('valibot').OptionalSchema<import('valibot').BooleanSchema<undefined>, undefined>;
|
|
97
|
+
allows_write_to_pm: import('valibot').OptionalSchema<import('valibot').BooleanSchema<undefined>, undefined>;
|
|
98
|
+
first_name: StringSchema<undefined>;
|
|
99
|
+
id: NumberSchema<undefined>;
|
|
100
|
+
is_bot: import('valibot').OptionalSchema<import('valibot').BooleanSchema<undefined>, undefined>;
|
|
101
|
+
is_premium: import('valibot').OptionalSchema<import('valibot').BooleanSchema<undefined>, undefined>;
|
|
102
|
+
last_name: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
103
|
+
language_code: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
104
|
+
photo_url: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
105
|
+
username: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
106
|
+
}, undefined>>, undefined>;
|
|
107
|
+
start_param: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
108
|
+
signature: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
109
|
+
user: import('valibot').OptionalSchema<import('./pipes.js').JsonToSchemaPipe<import('valibot').LooseObjectSchema<{
|
|
110
|
+
added_to_attachment_menu: import('valibot').OptionalSchema<import('valibot').BooleanSchema<undefined>, undefined>;
|
|
111
|
+
allows_write_to_pm: import('valibot').OptionalSchema<import('valibot').BooleanSchema<undefined>, undefined>;
|
|
112
|
+
first_name: StringSchema<undefined>;
|
|
113
|
+
id: NumberSchema<undefined>;
|
|
114
|
+
is_bot: import('valibot').OptionalSchema<import('valibot').BooleanSchema<undefined>, undefined>;
|
|
115
|
+
is_premium: import('valibot').OptionalSchema<import('valibot').BooleanSchema<undefined>, undefined>;
|
|
116
|
+
last_name: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
117
|
+
language_code: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
118
|
+
photo_url: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
119
|
+
username: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
120
|
+
}, undefined>>, undefined>;
|
|
121
|
+
auth: import('valibot').OptionalSchema<import('./pipes.js').JsonToSchemaPipe<import('valibot').LooseObjectSchema<{
|
|
122
|
+
projectCode: StringSchema<undefined>;
|
|
123
|
+
uid: StringSchema<undefined>;
|
|
124
|
+
sessionId: StringSchema<undefined>;
|
|
125
|
+
rootToken: StringSchema<undefined>;
|
|
126
|
+
}, undefined>>, undefined>;
|
|
127
|
+
}, undefined>>;
|
|
128
|
+
export declare function themeParams(): RecordSchema<SchemaWithPipe<[StringSchema<undefined>, TransformAction<string, KnownThemeParamsKey>]>, SchemaWithPipe<[UnionSchema<[StringSchema<undefined>, NumberSchema<undefined>], any>, TransformAction<string | number, string>, CheckAction<RGB, undefined>]>, undefined>;
|
|
129
|
+
export declare function launchParams(): import('valibot').LooseObjectSchema<{
|
|
130
|
+
vbWebAppBotInline: import('valibot').OptionalSchema<SchemaWithPipe<readonly [StringSchema<undefined>, TransformAction<string, boolean>]>, undefined>;
|
|
131
|
+
vbWebAppData: import('valibot').OptionalSchema<import('./pipes.js').QueryToSchemaPipe<import('valibot').LooseObjectSchema<{
|
|
132
|
+
auth_date: SchemaWithPipe<readonly [StringSchema<undefined>, TransformAction<string, Date>, import('valibot').DateSchema<undefined>]>;
|
|
133
|
+
can_send_after: import('valibot').OptionalSchema<SchemaWithPipe<readonly [StringSchema<undefined>, TransformAction<any, number>, import('valibot').IntegerAction<number, undefined>]>, undefined>;
|
|
134
|
+
chat: import('valibot').OptionalSchema<import('./pipes.js').JsonToSchemaPipe<import('valibot').LooseObjectSchema<{
|
|
135
|
+
id: NumberSchema<undefined>;
|
|
136
|
+
photo_url: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
137
|
+
type: StringSchema<undefined>;
|
|
138
|
+
title: StringSchema<undefined>;
|
|
139
|
+
username: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
140
|
+
}, undefined>>, undefined>;
|
|
141
|
+
chat_type: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
142
|
+
chat_instance: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
143
|
+
hash: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
144
|
+
query_id: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
145
|
+
receiver: import('valibot').OptionalSchema<import('./pipes.js').JsonToSchemaPipe<import('valibot').LooseObjectSchema<{
|
|
146
|
+
added_to_attachment_menu: import('valibot').OptionalSchema<import('valibot').BooleanSchema<undefined>, undefined>;
|
|
147
|
+
allows_write_to_pm: import('valibot').OptionalSchema<import('valibot').BooleanSchema<undefined>, undefined>;
|
|
148
|
+
first_name: StringSchema<undefined>;
|
|
149
|
+
id: NumberSchema<undefined>;
|
|
150
|
+
is_bot: import('valibot').OptionalSchema<import('valibot').BooleanSchema<undefined>, undefined>;
|
|
151
|
+
is_premium: import('valibot').OptionalSchema<import('valibot').BooleanSchema<undefined>, undefined>;
|
|
152
|
+
last_name: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
153
|
+
language_code: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
154
|
+
photo_url: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
155
|
+
username: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
156
|
+
}, undefined>>, undefined>;
|
|
157
|
+
start_param: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
158
|
+
signature: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
159
|
+
user: import('valibot').OptionalSchema<import('./pipes.js').JsonToSchemaPipe<import('valibot').LooseObjectSchema<{
|
|
160
|
+
added_to_attachment_menu: import('valibot').OptionalSchema<import('valibot').BooleanSchema<undefined>, undefined>;
|
|
161
|
+
allows_write_to_pm: import('valibot').OptionalSchema<import('valibot').BooleanSchema<undefined>, undefined>;
|
|
162
|
+
first_name: StringSchema<undefined>;
|
|
163
|
+
id: NumberSchema<undefined>;
|
|
164
|
+
is_bot: import('valibot').OptionalSchema<import('valibot').BooleanSchema<undefined>, undefined>;
|
|
165
|
+
is_premium: import('valibot').OptionalSchema<import('valibot').BooleanSchema<undefined>, undefined>;
|
|
166
|
+
last_name: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
167
|
+
language_code: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
168
|
+
photo_url: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
169
|
+
username: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
170
|
+
}, undefined>>, undefined>;
|
|
171
|
+
auth: import('valibot').OptionalSchema<import('./pipes.js').JsonToSchemaPipe<import('valibot').LooseObjectSchema<{
|
|
172
|
+
projectCode: StringSchema<undefined>;
|
|
173
|
+
uid: StringSchema<undefined>;
|
|
174
|
+
sessionId: StringSchema<undefined>;
|
|
175
|
+
rootToken: StringSchema<undefined>;
|
|
176
|
+
}, undefined>>, undefined>;
|
|
177
|
+
}, undefined>>, undefined>;
|
|
178
|
+
vbWebAppDefaultColors: import('valibot').OptionalSchema<import('./pipes.js').JsonToSchemaPipe<RecordSchema<SchemaWithPipe<[StringSchema<undefined>, TransformAction<string, KnownThemeParamsKey>]>, SchemaWithPipe<[UnionSchema<[StringSchema<undefined>, NumberSchema<undefined>], any>, TransformAction<string | number, string>, CheckAction<`#${string}`, undefined>]>, undefined>>, undefined>;
|
|
179
|
+
vbWebAppFullscreen: import('valibot').OptionalSchema<SchemaWithPipe<readonly [StringSchema<undefined>, TransformAction<string, boolean>]>, undefined>;
|
|
180
|
+
vbWebAppPlatform: StringSchema<undefined>;
|
|
181
|
+
vbWebAppShowSettings: import('valibot').OptionalSchema<SchemaWithPipe<readonly [StringSchema<undefined>, TransformAction<string, boolean>]>, undefined>;
|
|
182
|
+
vbWebAppStartParam: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
183
|
+
vbWebAppThemeParams: import('./pipes.js').JsonToSchemaPipe<RecordSchema<SchemaWithPipe<[StringSchema<undefined>, TransformAction<string, KnownThemeParamsKey>]>, SchemaWithPipe<[UnionSchema<[StringSchema<undefined>, NumberSchema<undefined>], any>, TransformAction<string | number, string>, CheckAction<`#${string}`, undefined>]>, undefined>>;
|
|
184
|
+
vbWebAppVersion: StringSchema<undefined>;
|
|
185
|
+
}, undefined>;
|
|
186
|
+
export declare function launchParamsQuery(): import('./pipes.js').QueryToSchemaPipe<import('valibot').LooseObjectSchema<{
|
|
187
|
+
vbWebAppBotInline: import('valibot').OptionalSchema<SchemaWithPipe<readonly [StringSchema<undefined>, TransformAction<string, boolean>]>, undefined>;
|
|
188
|
+
vbWebAppData: import('valibot').OptionalSchema<import('./pipes.js').QueryToSchemaPipe<import('valibot').LooseObjectSchema<{
|
|
189
|
+
auth_date: SchemaWithPipe<readonly [StringSchema<undefined>, TransformAction<string, Date>, import('valibot').DateSchema<undefined>]>;
|
|
190
|
+
can_send_after: import('valibot').OptionalSchema<SchemaWithPipe<readonly [StringSchema<undefined>, TransformAction<any, number>, import('valibot').IntegerAction<number, undefined>]>, undefined>;
|
|
191
|
+
chat: import('valibot').OptionalSchema<import('./pipes.js').JsonToSchemaPipe<import('valibot').LooseObjectSchema<{
|
|
192
|
+
id: NumberSchema<undefined>;
|
|
193
|
+
photo_url: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
194
|
+
type: StringSchema<undefined>;
|
|
195
|
+
title: StringSchema<undefined>;
|
|
196
|
+
username: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
197
|
+
}, undefined>>, undefined>;
|
|
198
|
+
chat_type: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
199
|
+
chat_instance: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
200
|
+
hash: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
201
|
+
query_id: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
202
|
+
receiver: import('valibot').OptionalSchema<import('./pipes.js').JsonToSchemaPipe<import('valibot').LooseObjectSchema<{
|
|
203
|
+
added_to_attachment_menu: import('valibot').OptionalSchema<import('valibot').BooleanSchema<undefined>, undefined>;
|
|
204
|
+
allows_write_to_pm: import('valibot').OptionalSchema<import('valibot').BooleanSchema<undefined>, undefined>;
|
|
205
|
+
first_name: StringSchema<undefined>;
|
|
206
|
+
id: NumberSchema<undefined>;
|
|
207
|
+
is_bot: import('valibot').OptionalSchema<import('valibot').BooleanSchema<undefined>, undefined>;
|
|
208
|
+
is_premium: import('valibot').OptionalSchema<import('valibot').BooleanSchema<undefined>, undefined>;
|
|
209
|
+
last_name: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
210
|
+
language_code: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
211
|
+
photo_url: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
212
|
+
username: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
213
|
+
}, undefined>>, undefined>;
|
|
214
|
+
start_param: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
215
|
+
signature: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
216
|
+
user: import('valibot').OptionalSchema<import('./pipes.js').JsonToSchemaPipe<import('valibot').LooseObjectSchema<{
|
|
217
|
+
added_to_attachment_menu: import('valibot').OptionalSchema<import('valibot').BooleanSchema<undefined>, undefined>;
|
|
218
|
+
allows_write_to_pm: import('valibot').OptionalSchema<import('valibot').BooleanSchema<undefined>, undefined>;
|
|
219
|
+
first_name: StringSchema<undefined>;
|
|
220
|
+
id: NumberSchema<undefined>;
|
|
221
|
+
is_bot: import('valibot').OptionalSchema<import('valibot').BooleanSchema<undefined>, undefined>;
|
|
222
|
+
is_premium: import('valibot').OptionalSchema<import('valibot').BooleanSchema<undefined>, undefined>;
|
|
223
|
+
last_name: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
224
|
+
language_code: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
225
|
+
photo_url: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
226
|
+
username: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
227
|
+
}, undefined>>, undefined>;
|
|
228
|
+
auth: import('valibot').OptionalSchema<import('./pipes.js').JsonToSchemaPipe<import('valibot').LooseObjectSchema<{
|
|
229
|
+
projectCode: StringSchema<undefined>;
|
|
230
|
+
uid: StringSchema<undefined>;
|
|
231
|
+
sessionId: StringSchema<undefined>;
|
|
232
|
+
rootToken: StringSchema<undefined>;
|
|
233
|
+
}, undefined>>, undefined>;
|
|
234
|
+
}, undefined>>, undefined>;
|
|
235
|
+
vbWebAppDefaultColors: import('valibot').OptionalSchema<import('./pipes.js').JsonToSchemaPipe<RecordSchema<SchemaWithPipe<[StringSchema<undefined>, TransformAction<string, KnownThemeParamsKey>]>, SchemaWithPipe<[UnionSchema<[StringSchema<undefined>, NumberSchema<undefined>], any>, TransformAction<string | number, string>, CheckAction<`#${string}`, undefined>]>, undefined>>, undefined>;
|
|
236
|
+
vbWebAppFullscreen: import('valibot').OptionalSchema<SchemaWithPipe<readonly [StringSchema<undefined>, TransformAction<string, boolean>]>, undefined>;
|
|
237
|
+
vbWebAppPlatform: StringSchema<undefined>;
|
|
238
|
+
vbWebAppShowSettings: import('valibot').OptionalSchema<SchemaWithPipe<readonly [StringSchema<undefined>, TransformAction<string, boolean>]>, undefined>;
|
|
239
|
+
vbWebAppStartParam: import('valibot').OptionalSchema<StringSchema<undefined>, undefined>;
|
|
240
|
+
vbWebAppThemeParams: import('./pipes.js').JsonToSchemaPipe<RecordSchema<SchemaWithPipe<[StringSchema<undefined>, TransformAction<string, KnownThemeParamsKey>]>, SchemaWithPipe<[UnionSchema<[StringSchema<undefined>, NumberSchema<undefined>], any>, TransformAction<string | number, string>, CheckAction<`#${string}`, undefined>]>, undefined>>;
|
|
241
|
+
vbWebAppVersion: StringSchema<undefined>;
|
|
242
|
+
}, undefined>>;
|
|
243
|
+
/**
|
|
244
|
+
* @returns True if the passed value contains valid launch parameters query.
|
|
245
|
+
*/
|
|
246
|
+
export declare function isLaunchParamsQuery(value: string | URLSearchParams): boolean;
|
|
247
|
+
export declare function miniAppsMessage(): import('valibot').LooseObjectSchema<{
|
|
248
|
+
readonly eventType: StringSchema<undefined>;
|
|
249
|
+
readonly eventData: import('valibot').OptionalSchema<import('valibot').UnknownSchema, undefined>;
|
|
250
|
+
}, undefined>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { BaseIssue, BaseSchema, CheckAction, InferOutput, InstanceSchema, SchemaWithPipe, StringSchema, TransformAction, UnionSchema } from 'valibot';
|
|
2
|
+
type RequiredSchema = BaseSchema<any, any, BaseIssue<any>>;
|
|
3
|
+
export type TransformJsonToSchemaAction<Schema extends RequiredSchema> = SchemaWithPipe<readonly [
|
|
4
|
+
StringSchema<any>,
|
|
5
|
+
CheckAction<string, string>,
|
|
6
|
+
TransformAction<string, unknown>,
|
|
7
|
+
Schema
|
|
8
|
+
]>;
|
|
9
|
+
export type TransformQueryToSchemaAction<Schema extends RequiredSchema> = SchemaWithPipe<readonly [
|
|
10
|
+
UnionSchema<[
|
|
11
|
+
StringSchema<undefined>,
|
|
12
|
+
InstanceSchema<typeof URLSearchParams, undefined>
|
|
13
|
+
], undefined>,
|
|
14
|
+
CheckAction<string | URLSearchParams, string>,
|
|
15
|
+
TransformAction<string | URLSearchParams, InferOutput<Schema>>
|
|
16
|
+
]>;
|
|
17
|
+
export declare function transformQueryToSchema<Schema extends RequiredSchema>(schema: Schema): TransformQueryToSchemaAction<Schema>;
|
|
18
|
+
/**
|
|
19
|
+
* @returns A transformer applying `JSON.parse` to the input.
|
|
20
|
+
*/
|
|
21
|
+
export declare function transformJsonToSchema<Schema extends RequiredSchema>(schema: Schema): TransformJsonToSchemaAction<Schema>;
|
|
22
|
+
export {};
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@vbotma/toolkit"),o=require("fp-ts"),t=require("valibot");function $(r){const n=e=>{const a={};return new URLSearchParams(e).forEach((i,u)=>{const p=a[u];Array.isArray(p)?p.push(i):p===void 0?a[u]=i:a[u]=[p,i]}),t.parse(r,a)};return t.pipe(t.union([t.string(),t.instance(URLSearchParams)]),t.check(e=>{try{return n(e),!0}catch{return!1}},"The value doesn't match required schema"),t.transform(n))}function C(r){return t.pipe(t.string(),t.check(n=>{try{return JSON.parse(n),!0}catch{return!1}},"Input is not a valid JSON value"),t.transform(JSON.parse),r)}function s(r){return t.pipe(t.string(),C(r))}function m(r){return t.pipe(t.union([t.string(),t.instance(URLSearchParams)]),$(r))}function f(r){return n=>r.test(n)}const S=f(/^#[\da-f]{3}$/i),A=f(/^#[\da-f]{4}$/i),R=f(/^#[\da-f]{6}$/i),B=f(/^#[\da-f]{8}$/i);function D(r){return[R,B,S,A].some(n=>n(r))}function b(r){let n="#";for(let e=0;e<r.length-1;e+=1)n+=r[1+e].repeat(2);return n}function g(r){const n=r.replace(/\s/g,"").toLowerCase();if(/^#[\da-f]{3}$/i.test(n))return o.either.right(b(n.toLowerCase()+"f"));if(/^#[\da-f]{4}$/i.test(n))return o.either.right(b(n.toLowerCase()));if(/^#[\da-f]{6}$/i.test(n))return o.either.right(n.toLowerCase()+"ff");if(/^#[\da-f]{8}$/i.test(n))return o.either.right(n.toLowerCase());const e=n.match(/^rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)$/)||n.match(/^rgba\((\d{1,3}),(\d{1,3}),(\d{1,3}),(\d{1,3})\)$/);return e?o.either.right(e.slice(1).reduce((a,i)=>a+parseInt(i,10).toString(16).padStart(2,"0"),"#").padEnd(9,"f")):o.either.left(new Error(`Value "${r}" does not satisfy any of known RGB formats.`))}function P(r){return o.function.pipe(g(r),o.either.map(n=>n.slice(0,7)))}const I=c.throwifyFpFn(P),W=c.throwifyFpFn(g);function Q(){return t.looseObject({id:t.number(),photo_url:t.optional(t.string()),type:t.string(),title:t.string(),username:t.optional(t.string())})}function h(){return t.looseObject({added_to_attachment_menu:t.optional(t.boolean()),allows_write_to_pm:t.optional(t.boolean()),first_name:t.string(),id:t.number(),is_bot:t.optional(t.boolean()),is_premium:t.optional(t.boolean()),last_name:t.optional(t.string()),language_code:t.optional(t.string()),photo_url:t.optional(t.string()),username:t.optional(t.string())})}function F(){return t.looseObject({projectCode:t.string(),uid:t.string(),sessionId:t.string(),rootToken:t.string()})}function _(){return t.looseObject({auth_date:t.pipe(t.string(),t.transform(r=>new Date(Number(r)*1e3)),t.date()),can_send_after:t.optional(t.pipe(t.string(),t.transform(Number),t.integer())),chat:t.optional(s(Q())),chat_type:t.optional(t.string()),chat_instance:t.optional(t.string()),hash:t.optional(t.string()),query_id:t.optional(t.string()),receiver:t.optional(s(h())),start_param:t.optional(t.string()),signature:t.optional(t.string()),user:t.optional(s(h())),auth:t.optional(s(F()))})}function y(){return m(_())}function l(){return t.record(t.string(),t.pipe(t.union([t.string(),t.number()]),t.transform(r=>typeof r=="number"?`#${(r&16777215).toString(16).padStart(6,"0")}`:r),t.check(D)))}function G(){const r=t.optional(t.pipe(t.string(),t.transform(n=>n==="1")));return t.looseObject({vbWebAppBotInline:r,vbWebAppData:t.optional(y()),vbWebAppDefaultColors:t.optional(s(l())),vbWebAppFullscreen:r,vbWebAppPlatform:t.string(),vbWebAppShowSettings:r,vbWebAppStartParam:t.optional(t.string()),vbWebAppThemeParams:s(l()),vbWebAppVersion:t.string()})}function d(){return m(G())}function j(r){try{return t.is(d(),r)}catch{return!1}}function J(){return t.looseObject({eventType:t.string(),eventData:t.optional(t.unknown())})}function w(r){return o.either.tryCatch(()=>t.parse(y(),r),n=>n)}function L(r){return o.either.tryCatch(()=>t.parse(d(),r),n=>n)}const N=c.throwifyFpFn(w),U=c.throwifyFpFn(L);function T(r,n){return n||(n=(e,a)=>JSON.stringify(a)),new URLSearchParams(Object.entries(r).reduce((e,[a,i])=>(Array.isArray(i)?e.push(...i.map(u=>[a,String(u)])):i!=null&&e.push([a,i instanceof Date?(i.getTime()/1e3|0).toString():typeof i=="string"||typeof i=="number"?String(i):typeof i=="boolean"?i?"1":"0":n(a,i)]),e),[])).toString()}function O(r){return T(r)}function q(r){return T(r,(n,e)=>n==="vbWebAppData"?O(e):JSON.stringify(e))}exports.initData=_;exports.initDataAuth=F;exports.initDataChat=Q;exports.initDataQuery=y;exports.initDataUser=h;exports.isAnyRGB=D;exports.isLaunchParamsQuery=j;exports.isRGB=R;exports.isRGBA=B;exports.isRGBAShort=A;exports.isRGBShort=S;exports.launchParams=G;exports.launchParamsQuery=d;exports.miniAppsMessage=J;exports.parseInitDataQuery=N;exports.parseInitDataQueryFp=w;exports.parseLaunchParamsQuery=U;exports.parseLaunchParamsQueryFp=L;exports.pipeJsonToSchema=s;exports.pipeQueryToSchema=m;exports.serializeInitDataQuery=O;exports.serializeLaunchParamsQuery=q;exports.themeParams=l;exports.toRGB=I;exports.toRGBFp=P;exports.toRGBFull=W;exports.toRGBFullFp=g;
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/transformers.ts","../src/pipes.ts","../src/rgb.ts","../src/structures.ts","../src/parsers.ts","../src/serializers.ts"],"sourcesContent":["import {\n type BaseIssue,\n type BaseSchema,\n check,\n type CheckAction,\n type InferOutput,\n instance,\n type InstanceSchema,\n parse,\n pipe,\n type SchemaWithPipe,\n string,\n type StringSchema,\n transform,\n type TransformAction,\n union,\n type UnionSchema,\n} from 'valibot';\n\ntype RequiredSchema = BaseSchema<any, any, BaseIssue<any>>;\n\nexport type TransformJsonToSchemaAction<Schema extends RequiredSchema> = SchemaWithPipe<readonly [\n StringSchema<any>,\n CheckAction<string, string>,\n TransformAction<string, unknown>,\n Schema,\n]>;\n\nexport type TransformQueryToSchemaAction<Schema extends RequiredSchema> = SchemaWithPipe<readonly [\n UnionSchema<[\n StringSchema<undefined>,\n InstanceSchema<typeof URLSearchParams, undefined>,\n ], undefined>,\n CheckAction<string | URLSearchParams, string>,\n TransformAction<string | URLSearchParams, InferOutput<Schema>>,\n]>;\n\nexport function transformQueryToSchema<Schema extends RequiredSchema>(\n schema: Schema,\n): TransformQueryToSchemaAction<Schema> {\n const transformer = (input: string | URLSearchParams) => {\n const result: Record<string, string | string[]> = {};\n\n new URLSearchParams(input).forEach((value, key) => {\n const accValue = result[key];\n if (Array.isArray(accValue)) {\n accValue.push(value);\n } else if (accValue === undefined) {\n result[key] = value;\n } else {\n result[key] = [accValue, value];\n }\n });\n\n return parse(schema, result);\n };\n\n return pipe(\n union([string(), instance(URLSearchParams)]),\n check(input => {\n try {\n transformer(input);\n return true;\n } catch {\n return false;\n }\n }, 'The value doesn\\'t match required schema'),\n transform(transformer),\n );\n}\n\n/**\n * @returns A transformer applying `JSON.parse` to the input.\n */\nexport function transformJsonToSchema<Schema extends RequiredSchema>(\n schema: Schema,\n): TransformJsonToSchemaAction<Schema> {\n return pipe(\n string(),\n check(input => {\n try {\n JSON.parse(input);\n return true;\n } catch {\n return false;\n }\n }, 'Input is not a valid JSON value'),\n transform(JSON.parse),\n schema,\n );\n}\n","import {\n type BaseIssue,\n type BaseSchema,\n instance,\n type InstanceSchema,\n pipe,\n type SchemaWithPipe,\n string,\n type StringSchema,\n union,\n type UnionSchema,\n} from 'valibot';\n\nimport {\n transformJsonToSchema,\n type TransformJsonToSchemaAction,\n transformQueryToSchema,\n type TransformQueryToSchemaAction,\n} from './transformers.js';\n\ntype RequiredSchema = BaseSchema<any, any, BaseIssue<any>>;\n\nexport type JsonToSchemaPipe<Schema extends RequiredSchema> = SchemaWithPipe<readonly [\n StringSchema<undefined>,\n TransformJsonToSchemaAction<Schema>,\n]>;\n\nexport type QueryToSchemaPipe<Schema extends RequiredSchema> = SchemaWithPipe<readonly [\n UnionSchema<[\n StringSchema<undefined>,\n InstanceSchema<typeof URLSearchParams, undefined>,\n ], undefined>,\n TransformQueryToSchemaAction<Schema>,\n]>;\n\nexport function pipeJsonToSchema<Schema extends RequiredSchema>(\n schema: Schema,\n): JsonToSchemaPipe<Schema> {\n return pipe(string(), transformJsonToSchema(schema));\n}\n\nexport function pipeQueryToSchema<Schema extends RequiredSchema>(\n schema: Schema,\n): QueryToSchemaPipe<Schema> {\n return pipe(\n union([string(), instance(URLSearchParams)]),\n transformQueryToSchema(schema),\n );\n}\n","import { throwifyFpFn } from '@vbotma/toolkit';\nimport type { RGB } from '@vbotma/types';\nimport { either as E, function as fn } from 'fp-ts';\n\nfunction guardBasedOn(re: RegExp) {\n return (value: string): value is RGB => re.test(value);\n}\n\n/**\n * @returns True if the value has the #RGB format.\n */\nexport const isRGBShort = guardBasedOn(/^#[\\da-f]{3}$/i);\n\n/**\n * @returns True if the value has the #RGBA format.\n */\nexport const isRGBAShort = guardBasedOn(/^#[\\da-f]{4}$/i);\n\n/**\n * @returns True if the value has the #RRGGBB format.\n */\nexport const isRGB = guardBasedOn(/^#[\\da-f]{6}$/i);\n\n/**\n * @returns True if the value has the #RRGGBBAA format.\n */\nexport const isRGBA = guardBasedOn(/^#[\\da-f]{8}$/i);\n\n/**\n * @returns True if the value has any known RGB format.\n * @param value - value to check.\n */\nexport function isAnyRGB(value: string): value is RGB {\n return [isRGB, isRGBA, isRGBShort, isRGBAShort].some(fn => fn(value));\n}\n\n/**\n * Converts a short version of RGB (#RGB) to a complete one (#RRGGBB).\n * @param value\n */\nfunction expandRgb(value: RGB): RGB {\n let color: RGB = '#';\n for (let i = 0; i < value.length - 1; i += 1) {\n color += value[1 + i].repeat(2);\n }\n return color;\n}\n\n/**\n * Converts passed value to #RRGGBBAA format. Accepts the following color formats:\n * - `#RGB`\n * - `#RGBA`\n * - `#RRGGBB`\n * - `#RRGGBBAA`\n * - `rgb(1,2,3)`\n * - `rgba(1,2,3,4)`\n * @param value - a value to convert.\n * @returns A value in the #RRGGBBAA format.\n */\nexport function toRGBFullFp(value: string): E.Either<Error, RGB> {\n const clean = value.replace(/\\s/g, '').toLowerCase();\n if (/^#[\\da-f]{3}$/i.test(clean)) {\n return E.right(expandRgb(clean.toLowerCase() + 'f' as RGB));\n }\n\n if (/^#[\\da-f]{4}$/i.test(clean)) {\n return E.right(expandRgb(clean.toLowerCase() as RGB));\n }\n\n if (/^#[\\da-f]{6}$/i.test(clean)) {\n return E.right(clean.toLowerCase() + 'ff' as RGB);\n }\n\n if (/^#[\\da-f]{8}$/i.test(clean)) {\n return E.right(clean.toLowerCase() as RGB);\n }\n\n // Example valid values: rgb(0,3,10) rgba(32,114,8,0)\n const match = clean.match(/^rgb\\((\\d{1,3}),(\\d{1,3}),(\\d{1,3})\\)$/)\n || clean.match(/^rgba\\((\\d{1,3}),(\\d{1,3}),(\\d{1,3}),(\\d{1,3})\\)$/);\n\n // If this didn't work as well, we can't extract RGB color from passed text.\n if (!match) {\n return E.left(new Error(`Value \"${value}\" does not satisfy any of known RGB formats.`));\n }\n\n // Otherwise, take R, G and B components, convert to hex and create #RRGGBB string.\n return E.right(\n match\n .slice(1)\n .reduce(\n (acc, component) => {\n return acc + parseInt(component, 10)\n .toString(16)\n .padStart(2, '0');\n }, '#',\n )\n // We are adding f-s here to match the pattern: #RRGGBBAA\n .padEnd(9, 'f') as RGB,\n );\n}\n\n/**\n * Converts passed value to #RRGGBB format. Accepts the following color formats:\n * - `#RGB`\n * - `#RGBA`\n * - `#RRGGBB`\n * - `#RRGGBBAA`\n * - `rgb(1,2,3)`\n * - `rgba(1,2,3,4)`\n * @param value - a value to convert.\n * @returns A value in the #RRGGBB format.\n * @deprecated This function cuts the RGB's alpha channel. Use the `toRGBFullFp` function instead.\n */\nexport function toRGBFp(value: string): E.Either<Error, RGB> {\n return fn.pipe(\n toRGBFullFp(value),\n E.map(rgb => rgb.slice(0, 7) as RGB),\n );\n}\n\n/**\n * @see toRGBFp\n * @deprecated This function cuts the RGB's alpha channel. Use the `toRGBFull` function instead.\n */\nexport const toRGB = throwifyFpFn(toRGBFp);\n\n/**\n * @see toRGBFullFp\n */\nexport const toRGBFull = throwifyFpFn(toRGBFullFp);\n","import type {\n Chat,\n InitData,\n KnownThemeParamsKey,\n LaunchParams,\n RGB,\n User,\n Auth\n} from '@vbotma/types';\nimport {\n type BaseSchema,\n boolean,\n check,\n type CheckAction,\n date,\n type InferOutput,\n integer,\n is,\n looseObject,\n number,\n type NumberSchema,\n optional,\n pipe,\n record,\n type RecordSchema,\n type SchemaWithPipe,\n string,\n type StringSchema,\n transform,\n type TransformAction,\n union,\n type UnionSchema,\n unknown,\n} from 'valibot';\n\nimport { pipeJsonToSchema, pipeQueryToSchema } from './pipes.js';\nimport { isAnyRGB } from './rgb.js';\n\nexport type InitDataGenSchema = ReturnType<typeof initData>;\nexport type InitDataGenType = InferOutput<InitDataGenSchema>;\n\nexport type LaunchParamsGenSchema = ReturnType<typeof launchParams>;\nexport type LaunchParamsGenType = InferOutput<LaunchParamsGenSchema>;\n\nexport type MiniAppsMessageGenSchema = ReturnType<typeof miniAppsMessage>;\nexport type MiniAppsMessageGenType = InferOutput<MiniAppsMessageGenSchema>;\n\nexport function initDataChat() {\n return looseObject({\n id: number(),\n photo_url: optional(string()),\n type: string(),\n title: string(),\n username: optional(string()),\n } satisfies { [K in keyof Chat]-?: BaseSchema<unknown, Chat[K], any> });\n}\n\nexport function initDataUser() {\n return looseObject({\n added_to_attachment_menu: optional(boolean()),\n allows_write_to_pm: optional(boolean()),\n first_name: string(),\n id: number(),\n is_bot: optional(boolean()),\n is_premium: optional(boolean()),\n last_name: optional(string()),\n language_code: optional(string()),\n photo_url: optional(string()),\n username: optional(string()),\n } satisfies { [K in keyof User]-?: BaseSchema<unknown, User[K], any> });\n}\n\nexport function initDataAuth() {\n return looseObject({\n projectCode: string(),\n uid: string(),\n sessionId: string(),\n rootToken: string(),\n } satisfies { [K in keyof Auth]-?: BaseSchema<unknown, Auth[K], any> });\n}\n\nexport function initData() {\n return looseObject({\n auth_date: pipe(\n string(),\n transform(input => new Date(Number(input) * 1000)),\n date(),\n ),\n can_send_after: optional(pipe(string(), transform(Number), integer())),\n chat: optional(pipeJsonToSchema(initDataChat())),\n chat_type: optional(string()),\n chat_instance: optional(string()),\n hash: optional(string()),\n query_id: optional(string()),\n receiver: optional(pipeJsonToSchema(initDataUser())),\n start_param: optional(string()),\n signature: optional(string()),\n user: optional(pipeJsonToSchema(initDataUser())),\n auth: optional(pipeJsonToSchema(initDataAuth())),\n } satisfies { [K in keyof InitData]-?: unknown });\n}\n\nexport function initDataQuery() {\n return pipeQueryToSchema(initData());\n}\n\nexport function themeParams() {\n return record(\n string(),\n pipe(\n union([string(), number()]),\n transform(value => {\n return typeof value === 'number'\n ? `#${(value & 0x00FFFFFF).toString(16).padStart(6, '0')}`\n : value;\n }),\n check(isAnyRGB),\n ),\n ) as RecordSchema<\n SchemaWithPipe<[\n StringSchema<undefined>,\n TransformAction<string, KnownThemeParamsKey>,\n ]>,\n SchemaWithPipe<[\n UnionSchema<[StringSchema<undefined>, NumberSchema<undefined>], any>,\n TransformAction<string | number, string>,\n CheckAction<RGB, undefined>,\n ]>,\n undefined\n >;\n}\n\nexport function launchParams() {\n const optBool = optional(pipe(string(), transform(v => v === '1')));\n\n return looseObject({\n vbWebAppBotInline: optBool,\n vbWebAppData: optional(initDataQuery()),\n vbWebAppDefaultColors: optional(pipeJsonToSchema(themeParams())),\n vbWebAppFullscreen: optBool,\n vbWebAppPlatform: string(),\n vbWebAppShowSettings: optBool,\n vbWebAppStartParam: optional(string()),\n vbWebAppThemeParams: pipeJsonToSchema(themeParams()),\n vbWebAppVersion: string(),\n } satisfies { [K in keyof LaunchParams]-?: BaseSchema<any, LaunchParams[K], any> });\n}\n\nexport function launchParamsQuery() {\n return pipeQueryToSchema(launchParams());\n}\n\n/**\n * @returns True if the passed value contains valid launch parameters query.\n */\nexport function isLaunchParamsQuery(value: string | URLSearchParams): boolean {\n try {\n return is(launchParamsQuery(), value);\n } catch {\n return false;\n }\n}\n\nexport function miniAppsMessage() {\n return looseObject({\n eventType: string(),\n eventData: optional(unknown()),\n });\n}\n","import { throwifyFpFn } from '@vbotma/toolkit';\nimport { either as E } from 'fp-ts';\nimport { parse, type ValiError } from 'valibot';\n\nimport {\n type InitDataGenSchema,\n type InitDataGenType,\n initDataQuery,\n type LaunchParamsGenSchema,\n type LaunchParamsGenType,\n launchParamsQuery,\n} from './structures.js';\n\nexport type ParseInitDataQueryError = ValiError<InitDataGenSchema>;\nexport type ParseLaunchParamsQueryError = ValiError<LaunchParamsGenSchema>;\n\nexport function parseInitDataQueryFp(value: string | URLSearchParams): E.Either<\n ParseInitDataQueryError,\n InitDataGenType\n> {\n return E.tryCatch(\n () => parse(initDataQuery(), value),\n e => e as ValiError<InitDataGenSchema>,\n );\n}\n\nexport function parseLaunchParamsQueryFp(value: string | URLSearchParams): E.Either<\n ParseLaunchParamsQueryError,\n LaunchParamsGenType\n> {\n return E.tryCatch(\n () => parse(launchParamsQuery(), value),\n e => e as ValiError<LaunchParamsGenSchema>,\n );\n}\n\nexport const parseInitDataQuery = throwifyFpFn(parseInitDataQueryFp);\nexport const parseLaunchParamsQuery = throwifyFpFn(parseLaunchParamsQueryFp);\n","import type { InitData, LaunchParams } from '@vbotma/types';\nimport type { InferOutput } from 'valibot';\n\nimport type { initData, launchParams } from './structures.js';\n\nexport type InitDataLike = Partial<InferOutput<ReturnType<typeof initData>> | InitData>;\nexport type LaunchParamsLike = Partial<InferOutput<ReturnType<typeof launchParams>> | LaunchParams>;\n\n/**\n * Converts the passed object to query parameters.\n * @param value - value to serialize.\n * @param onObject - function returning serialized object value.\n */\nfunction serializeToQuery(\n value: object,\n onObject?: (key: string, value: object) => string,\n): string {\n onObject ||= (_, value) => JSON.stringify(value);\n\n return new URLSearchParams(\n Object\n .entries(value)\n .reduce<[string, string][]>((acc, [key, value]) => {\n if (Array.isArray(value)) {\n acc.push(...value.map(v => [key, String(v)] as [string, string]));\n } else {\n if (value !== null && value !== undefined) {\n acc.push([\n key,\n value instanceof Date\n ? (value.getTime() / 1000 | 0).toString()\n : typeof value === 'string' || typeof value === 'number'\n ? String(value)\n : typeof value === 'boolean'\n ? value ? '1' : '0'\n : onObject(key, value),\n ]);\n }\n }\n return acc;\n }, []),\n ).toString();\n}\n\n/**\n * Serializes the InitDataQuery shape.\n * @param value - value to serialize.\n */\nexport function serializeInitDataQuery(value: InitDataLike): string {\n return serializeToQuery(value);\n}\n\n/**\n * Serializes the LaunchParamsQuery shape.\n * @param value - value to serialize.\n */\nexport function serializeLaunchParamsQuery(value: LaunchParamsLike): string {\n return serializeToQuery(value, (k, v) => {\n return k === 'vbWebAppData' ? serializeInitDataQuery(v as any) : JSON.stringify(v);\n });\n}\n"],"names":["transformQueryToSchema","schema","transformer","input","result","value","key","accValue","parse","pipe","union","string","instance","check","transform","transformJsonToSchema","pipeJsonToSchema","pipeQueryToSchema","guardBasedOn","re","isRGBShort","isRGBAShort","isRGB","isRGBA","isAnyRGB","fn","expandRgb","color","i","toRGBFullFp","clean","E","match","acc","component","toRGBFp","rgb","toRGB","throwifyFpFn","toRGBFull","initDataChat","looseObject","number","optional","initDataUser","boolean","initDataAuth","initData","date","integer","initDataQuery","themeParams","record","launchParams","optBool","v","launchParamsQuery","isLaunchParamsQuery","is","miniAppsMessage","unknown","parseInitDataQueryFp","e","parseLaunchParamsQueryFp","parseInitDataQuery","parseLaunchParamsQuery","serializeToQuery","onObject","_","serializeInitDataQuery","serializeLaunchParamsQuery","k"],"mappings":"2JAqCO,SAASA,EACdC,EACsC,CACtC,MAAMC,EAAeC,GAAoC,CACvD,MAAMC,EAA4C,CAAA,EAElD,WAAI,gBAAgBD,CAAK,EAAE,QAAQ,CAACE,EAAOC,IAAQ,CACjD,MAAMC,EAAWH,EAAOE,CAAG,EACvB,MAAM,QAAQC,CAAQ,EACxBA,EAAS,KAAKF,CAAK,EACVE,IAAa,OACtBH,EAAOE,CAAG,EAAID,EAEdD,EAAOE,CAAG,EAAI,CAACC,EAAUF,CAAK,CAElC,CAAC,EAEMG,EAAAA,MAAMP,EAAQG,CAAM,CAC7B,EAEA,OAAOK,EAAAA,KACLC,EAAAA,MAAM,CAACC,EAAAA,OAAA,EAAUC,EAAAA,SAAS,eAAe,CAAC,CAAC,EAC3CC,EAAAA,MAAMV,GAAS,CACb,GAAI,CACF,OAAAD,EAAYC,CAAK,EACV,EACT,MAAQ,CACN,MAAO,EACT,CACF,EAAG,yCAA0C,EAC7CW,EAAAA,UAAUZ,CAAW,CAAA,CAEzB,CAKO,SAASa,EACdd,EACqC,CACrC,OAAOQ,EAAAA,KACLE,SAAA,EACAE,EAAAA,MAAMV,GAAS,CACb,GAAI,CACF,YAAK,MAAMA,CAAK,EACT,EACT,MAAQ,CACN,MAAO,EACT,CACF,EAAG,iCAAiC,EACpCW,EAAAA,UAAU,KAAK,KAAK,EACpBb,CAAA,CAEJ,CCvDO,SAASe,EACdf,EAC0B,CAC1B,OAAOQ,EAAAA,KAAKE,EAAAA,OAAA,EAAUI,EAAsBd,CAAM,CAAC,CACrD,CAEO,SAASgB,EACdhB,EAC2B,CAC3B,OAAOQ,EAAAA,KACLC,EAAAA,MAAM,CAACC,EAAAA,OAAA,EAAUC,EAAAA,SAAS,eAAe,CAAC,CAAC,EAC3CZ,EAAuBC,CAAM,CAAA,CAEjC,CC5CA,SAASiB,EAAaC,EAAY,CACh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K,CACP3B,EACAD,aAAiB,MACZA,EAAM,QAAA,EAAY,IAAO,GAAG,SAAA,EAC7B,OAAOA,GAAU,UAAY,OAAOA,GAAU,SAC5C,OAAOA,CAAK,EACZ,OAAOA,GAAU,UACfA,EAAQ,IAAM,IACd8D,EAAS7D,EAAKD,CAAK,CAAA,CAC5B,EAGE4B,GACN,CAAA,CAAE,CAAA,EACP,SAAA,CACJ,CAMO,SAASoC,EAAuBhE,EAA6B,CAClE,OAAO6D,EAAiB7D,CAAK,CAC/B,CAMO,SAASiE,EAA2BjE,EAAiC,CAC1E,OAAO6D,EAAiB7D,EAAO,CAACkE,EAAGhB,IAC1BgB,IAAM,eAAiBF,EAAuBd,CAAQ,EAAI,KAAK,UAAUA,CAAC,CAClF,CACH"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { throwifyFpFn as l } from "@vbotma/toolkit";
|
|
2
|
+
import { function as C, either as s } from "fp-ts";
|
|
3
|
+
import { pipe as u, string as e, check as y, transform as f, union as g, instance as D, parse as S, looseObject as p, optional as n, integer as G, date as T, number as _, boolean as d, is as W, unknown as F, record as I } from "valibot";
|
|
4
|
+
function J(t) {
|
|
5
|
+
const r = (a) => {
|
|
6
|
+
const i = {};
|
|
7
|
+
return new URLSearchParams(a).forEach((o, m) => {
|
|
8
|
+
const h = i[m];
|
|
9
|
+
Array.isArray(h) ? h.push(o) : h === void 0 ? i[m] = o : i[m] = [h, o];
|
|
10
|
+
}), S(t, i);
|
|
11
|
+
};
|
|
12
|
+
return u(
|
|
13
|
+
g([e(), D(URLSearchParams)]),
|
|
14
|
+
y((a) => {
|
|
15
|
+
try {
|
|
16
|
+
return r(a), !0;
|
|
17
|
+
} catch {
|
|
18
|
+
return !1;
|
|
19
|
+
}
|
|
20
|
+
}, "The value doesn't match required schema"),
|
|
21
|
+
f(r)
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
function N(t) {
|
|
25
|
+
return u(
|
|
26
|
+
e(),
|
|
27
|
+
y((r) => {
|
|
28
|
+
try {
|
|
29
|
+
return JSON.parse(r), !0;
|
|
30
|
+
} catch {
|
|
31
|
+
return !1;
|
|
32
|
+
}
|
|
33
|
+
}, "Input is not a valid JSON value"),
|
|
34
|
+
f(JSON.parse),
|
|
35
|
+
t
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
function c(t) {
|
|
39
|
+
return u(e(), N(t));
|
|
40
|
+
}
|
|
41
|
+
function P(t) {
|
|
42
|
+
return u(
|
|
43
|
+
g([e(), D(URLSearchParams)]),
|
|
44
|
+
J(t)
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
function b(t) {
|
|
48
|
+
return (r) => t.test(r);
|
|
49
|
+
}
|
|
50
|
+
const O = b(/^#[\da-f]{3}$/i), U = b(/^#[\da-f]{4}$/i), z = b(/^#[\da-f]{6}$/i), E = b(/^#[\da-f]{8}$/i);
|
|
51
|
+
function V(t) {
|
|
52
|
+
return [z, E, O, U].some((r) => r(t));
|
|
53
|
+
}
|
|
54
|
+
function A(t) {
|
|
55
|
+
let r = "#";
|
|
56
|
+
for (let a = 0; a < t.length - 1; a += 1)
|
|
57
|
+
r += t[1 + a].repeat(2);
|
|
58
|
+
return r;
|
|
59
|
+
}
|
|
60
|
+
function B(t) {
|
|
61
|
+
const r = t.replace(/\s/g, "").toLowerCase();
|
|
62
|
+
if (/^#[\da-f]{3}$/i.test(r))
|
|
63
|
+
return s.right(A(r.toLowerCase() + "f"));
|
|
64
|
+
if (/^#[\da-f]{4}$/i.test(r))
|
|
65
|
+
return s.right(A(r.toLowerCase()));
|
|
66
|
+
if (/^#[\da-f]{6}$/i.test(r))
|
|
67
|
+
return s.right(r.toLowerCase() + "ff");
|
|
68
|
+
if (/^#[\da-f]{8}$/i.test(r))
|
|
69
|
+
return s.right(r.toLowerCase());
|
|
70
|
+
const a = r.match(/^rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)$/) || r.match(/^rgba\((\d{1,3}),(\d{1,3}),(\d{1,3}),(\d{1,3})\)$/);
|
|
71
|
+
return a ? s.right(
|
|
72
|
+
a.slice(1).reduce(
|
|
73
|
+
(i, o) => i + parseInt(o, 10).toString(16).padStart(2, "0"),
|
|
74
|
+
"#"
|
|
75
|
+
).padEnd(9, "f")
|
|
76
|
+
) : s.left(new Error(`Value "${t}" does not satisfy any of known RGB formats.`));
|
|
77
|
+
}
|
|
78
|
+
function j(t) {
|
|
79
|
+
return C.pipe(
|
|
80
|
+
B(t),
|
|
81
|
+
s.map((r) => r.slice(0, 7))
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
const tt = l(j), rt = l(B);
|
|
85
|
+
function q() {
|
|
86
|
+
return p({
|
|
87
|
+
id: _(),
|
|
88
|
+
photo_url: n(e()),
|
|
89
|
+
type: e(),
|
|
90
|
+
title: e(),
|
|
91
|
+
username: n(e())
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
function w() {
|
|
95
|
+
return p({
|
|
96
|
+
added_to_attachment_menu: n(d()),
|
|
97
|
+
allows_write_to_pm: n(d()),
|
|
98
|
+
first_name: e(),
|
|
99
|
+
id: _(),
|
|
100
|
+
is_bot: n(d()),
|
|
101
|
+
is_premium: n(d()),
|
|
102
|
+
last_name: n(e()),
|
|
103
|
+
language_code: n(e()),
|
|
104
|
+
photo_url: n(e()),
|
|
105
|
+
username: n(e())
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
function x() {
|
|
109
|
+
return p({
|
|
110
|
+
projectCode: e(),
|
|
111
|
+
uid: e(),
|
|
112
|
+
sessionId: e(),
|
|
113
|
+
rootToken: e()
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
function M() {
|
|
117
|
+
return p({
|
|
118
|
+
auth_date: u(
|
|
119
|
+
e(),
|
|
120
|
+
f((t) => new Date(Number(t) * 1e3)),
|
|
121
|
+
T()
|
|
122
|
+
),
|
|
123
|
+
can_send_after: n(u(e(), f(Number), G())),
|
|
124
|
+
chat: n(c(q())),
|
|
125
|
+
chat_type: n(e()),
|
|
126
|
+
chat_instance: n(e()),
|
|
127
|
+
hash: n(e()),
|
|
128
|
+
query_id: n(e()),
|
|
129
|
+
receiver: n(c(w())),
|
|
130
|
+
start_param: n(e()),
|
|
131
|
+
signature: n(e()),
|
|
132
|
+
user: n(c(w())),
|
|
133
|
+
auth: n(c(x()))
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
function L() {
|
|
137
|
+
return P(M());
|
|
138
|
+
}
|
|
139
|
+
function R() {
|
|
140
|
+
return I(
|
|
141
|
+
e(),
|
|
142
|
+
u(
|
|
143
|
+
g([e(), _()]),
|
|
144
|
+
f((t) => typeof t == "number" ? `#${(t & 16777215).toString(16).padStart(6, "0")}` : t),
|
|
145
|
+
y(V)
|
|
146
|
+
)
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
function k() {
|
|
150
|
+
const t = n(u(e(), f((r) => r === "1")));
|
|
151
|
+
return p({
|
|
152
|
+
vbWebAppBotInline: t,
|
|
153
|
+
vbWebAppData: n(L()),
|
|
154
|
+
vbWebAppDefaultColors: n(c(R())),
|
|
155
|
+
vbWebAppFullscreen: t,
|
|
156
|
+
vbWebAppPlatform: e(),
|
|
157
|
+
vbWebAppShowSettings: t,
|
|
158
|
+
vbWebAppStartParam: n(e()),
|
|
159
|
+
vbWebAppThemeParams: c(R()),
|
|
160
|
+
vbWebAppVersion: e()
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
function Q() {
|
|
164
|
+
return P(k());
|
|
165
|
+
}
|
|
166
|
+
function et(t) {
|
|
167
|
+
try {
|
|
168
|
+
return W(Q(), t);
|
|
169
|
+
} catch {
|
|
170
|
+
return !1;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
function nt() {
|
|
174
|
+
return p({
|
|
175
|
+
eventType: e(),
|
|
176
|
+
eventData: n(F())
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
function v(t) {
|
|
180
|
+
return s.tryCatch(
|
|
181
|
+
() => S(L(), t),
|
|
182
|
+
(r) => r
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
function H(t) {
|
|
186
|
+
return s.tryCatch(
|
|
187
|
+
() => S(Q(), t),
|
|
188
|
+
(r) => r
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
const at = l(v), ot = l(H);
|
|
192
|
+
function $(t, r) {
|
|
193
|
+
return r || (r = (a, i) => JSON.stringify(i)), new URLSearchParams(
|
|
194
|
+
Object.entries(t).reduce((a, [i, o]) => (Array.isArray(o) ? a.push(...o.map((m) => [i, String(m)])) : o != null && a.push([
|
|
195
|
+
i,
|
|
196
|
+
o instanceof Date ? (o.getTime() / 1e3 | 0).toString() : typeof o == "string" || typeof o == "number" ? String(o) : typeof o == "boolean" ? o ? "1" : "0" : r(i, o)
|
|
197
|
+
]), a), [])
|
|
198
|
+
).toString();
|
|
199
|
+
}
|
|
200
|
+
function K(t) {
|
|
201
|
+
return $(t);
|
|
202
|
+
}
|
|
203
|
+
function it(t) {
|
|
204
|
+
return $(t, (r, a) => r === "vbWebAppData" ? K(a) : JSON.stringify(a));
|
|
205
|
+
}
|
|
206
|
+
export {
|
|
207
|
+
M as initData,
|
|
208
|
+
x as initDataAuth,
|
|
209
|
+
q as initDataChat,
|
|
210
|
+
L as initDataQuery,
|
|
211
|
+
w as initDataUser,
|
|
212
|
+
V as isAnyRGB,
|
|
213
|
+
et as isLaunchParamsQuery,
|
|
214
|
+
z as isRGB,
|
|
215
|
+
E as isRGBA,
|
|
216
|
+
U as isRGBAShort,
|
|
217
|
+
O as isRGBShort,
|
|
218
|
+
k as launchParams,
|
|
219
|
+
Q as launchParamsQuery,
|
|
220
|
+
nt as miniAppsMessage,
|
|
221
|
+
at as parseInitDataQuery,
|
|
222
|
+
v as parseInitDataQueryFp,
|
|
223
|
+
ot as parseLaunchParamsQuery,
|
|
224
|
+
H as parseLaunchParamsQueryFp,
|
|
225
|
+
c as pipeJsonToSchema,
|
|
226
|
+
P as pipeQueryToSchema,
|
|
227
|
+
K as serializeInitDataQuery,
|
|
228
|
+
it as serializeLaunchParamsQuery,
|
|
229
|
+
R as themeParams,
|
|
230
|
+
tt as toRGB,
|
|
231
|
+
j as toRGBFp,
|
|
232
|
+
rt as toRGBFull,
|
|
233
|
+
B as toRGBFullFp
|
|
234
|
+
};
|
|
235
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/transformers.ts","../src/pipes.ts","../src/rgb.ts","../src/structures.ts","../src/parsers.ts","../src/serializers.ts"],"sourcesContent":["import {\n type BaseIssue,\n type BaseSchema,\n check,\n type CheckAction,\n type InferOutput,\n instance,\n type InstanceSchema,\n parse,\n pipe,\n type SchemaWithPipe,\n string,\n type StringSchema,\n transform,\n type TransformAction,\n union,\n type UnionSchema,\n} from 'valibot';\n\ntype RequiredSchema = BaseSchema<any, any, BaseIssue<any>>;\n\nexport type TransformJsonToSchemaAction<Schema extends RequiredSchema> = SchemaWithPipe<readonly [\n StringSchema<any>,\n CheckAction<string, string>,\n TransformAction<string, unknown>,\n Schema,\n]>;\n\nexport type TransformQueryToSchemaAction<Schema extends RequiredSchema> = SchemaWithPipe<readonly [\n UnionSchema<[\n StringSchema<undefined>,\n InstanceSchema<typeof URLSearchParams, undefined>,\n ], undefined>,\n CheckAction<string | URLSearchParams, string>,\n TransformAction<string | URLSearchParams, InferOutput<Schema>>,\n]>;\n\nexport function transformQueryToSchema<Schema extends RequiredSchema>(\n schema: Schema,\n): TransformQueryToSchemaAction<Schema> {\n const transformer = (input: string | URLSearchParams) => {\n const result: Record<string, string | string[]> = {};\n\n new URLSearchParams(input).forEach((value, key) => {\n const accValue = result[key];\n if (Array.isArray(accValue)) {\n accValue.push(value);\n } else if (accValue === undefined) {\n result[key] = value;\n } else {\n result[key] = [accValue, value];\n }\n });\n\n return parse(schema, result);\n };\n\n return pipe(\n union([string(), instance(URLSearchParams)]),\n check(input => {\n try {\n transformer(input);\n return true;\n } catch {\n return false;\n }\n }, 'The value doesn\\'t match required schema'),\n transform(transformer),\n );\n}\n\n/**\n * @returns A transformer applying `JSON.parse` to the input.\n */\nexport function transformJsonToSchema<Schema extends RequiredSchema>(\n schema: Schema,\n): TransformJsonToSchemaAction<Schema> {\n return pipe(\n string(),\n check(input => {\n try {\n JSON.parse(input);\n return true;\n } catch {\n return false;\n }\n }, 'Input is not a valid JSON value'),\n transform(JSON.parse),\n schema,\n );\n}\n","import {\n type BaseIssue,\n type BaseSchema,\n instance,\n type InstanceSchema,\n pipe,\n type SchemaWithPipe,\n string,\n type StringSchema,\n union,\n type UnionSchema,\n} from 'valibot';\n\nimport {\n transformJsonToSchema,\n type TransformJsonToSchemaAction,\n transformQueryToSchema,\n type TransformQueryToSchemaAction,\n} from './transformers.js';\n\ntype RequiredSchema = BaseSchema<any, any, BaseIssue<any>>;\n\nexport type JsonToSchemaPipe<Schema extends RequiredSchema> = SchemaWithPipe<readonly [\n StringSchema<undefined>,\n TransformJsonToSchemaAction<Schema>,\n]>;\n\nexport type QueryToSchemaPipe<Schema extends RequiredSchema> = SchemaWithPipe<readonly [\n UnionSchema<[\n StringSchema<undefined>,\n InstanceSchema<typeof URLSearchParams, undefined>,\n ], undefined>,\n TransformQueryToSchemaAction<Schema>,\n]>;\n\nexport function pipeJsonToSchema<Schema extends RequiredSchema>(\n schema: Schema,\n): JsonToSchemaPipe<Schema> {\n return pipe(string(), transformJsonToSchema(schema));\n}\n\nexport function pipeQueryToSchema<Schema extends RequiredSchema>(\n schema: Schema,\n): QueryToSchemaPipe<Schema> {\n return pipe(\n union([string(), instance(URLSearchParams)]),\n transformQueryToSchema(schema),\n );\n}\n","import { throwifyFpFn } from '@vbotma/toolkit';\nimport type { RGB } from '@vbotma/types';\nimport { either as E, function as fn } from 'fp-ts';\n\nfunction guardBasedOn(re: RegExp) {\n return (value: string): value is RGB => re.test(value);\n}\n\n/**\n * @returns True if the value has the #RGB format.\n */\nexport const isRGBShort = guardBasedOn(/^#[\\da-f]{3}$/i);\n\n/**\n * @returns True if the value has the #RGBA format.\n */\nexport const isRGBAShort = guardBasedOn(/^#[\\da-f]{4}$/i);\n\n/**\n * @returns True if the value has the #RRGGBB format.\n */\nexport const isRGB = guardBasedOn(/^#[\\da-f]{6}$/i);\n\n/**\n * @returns True if the value has the #RRGGBBAA format.\n */\nexport const isRGBA = guardBasedOn(/^#[\\da-f]{8}$/i);\n\n/**\n * @returns True if the value has any known RGB format.\n * @param value - value to check.\n */\nexport function isAnyRGB(value: string): value is RGB {\n return [isRGB, isRGBA, isRGBShort, isRGBAShort].some(fn => fn(value));\n}\n\n/**\n * Converts a short version of RGB (#RGB) to a complete one (#RRGGBB).\n * @param value\n */\nfunction expandRgb(value: RGB): RGB {\n let color: RGB = '#';\n for (let i = 0; i < value.length - 1; i += 1) {\n color += value[1 + i].repeat(2);\n }\n return color;\n}\n\n/**\n * Converts passed value to #RRGGBBAA format. Accepts the following color formats:\n * - `#RGB`\n * - `#RGBA`\n * - `#RRGGBB`\n * - `#RRGGBBAA`\n * - `rgb(1,2,3)`\n * - `rgba(1,2,3,4)`\n * @param value - a value to convert.\n * @returns A value in the #RRGGBBAA format.\n */\nexport function toRGBFullFp(value: string): E.Either<Error, RGB> {\n const clean = value.replace(/\\s/g, '').toLowerCase();\n if (/^#[\\da-f]{3}$/i.test(clean)) {\n return E.right(expandRgb(clean.toLowerCase() + 'f' as RGB));\n }\n\n if (/^#[\\da-f]{4}$/i.test(clean)) {\n return E.right(expandRgb(clean.toLowerCase() as RGB));\n }\n\n if (/^#[\\da-f]{6}$/i.test(clean)) {\n return E.right(clean.toLowerCase() + 'ff' as RGB);\n }\n\n if (/^#[\\da-f]{8}$/i.test(clean)) {\n return E.right(clean.toLowerCase() as RGB);\n }\n\n // Example valid values: rgb(0,3,10) rgba(32,114,8,0)\n const match = clean.match(/^rgb\\((\\d{1,3}),(\\d{1,3}),(\\d{1,3})\\)$/)\n || clean.match(/^rgba\\((\\d{1,3}),(\\d{1,3}),(\\d{1,3}),(\\d{1,3})\\)$/);\n\n // If this didn't work as well, we can't extract RGB color from passed text.\n if (!match) {\n return E.left(new Error(`Value \"${value}\" does not satisfy any of known RGB formats.`));\n }\n\n // Otherwise, take R, G and B components, convert to hex and create #RRGGBB string.\n return E.right(\n match\n .slice(1)\n .reduce(\n (acc, component) => {\n return acc + parseInt(component, 10)\n .toString(16)\n .padStart(2, '0');\n }, '#',\n )\n // We are adding f-s here to match the pattern: #RRGGBBAA\n .padEnd(9, 'f') as RGB,\n );\n}\n\n/**\n * Converts passed value to #RRGGBB format. Accepts the following color formats:\n * - `#RGB`\n * - `#RGBA`\n * - `#RRGGBB`\n * - `#RRGGBBAA`\n * - `rgb(1,2,3)`\n * - `rgba(1,2,3,4)`\n * @param value - a value to convert.\n * @returns A value in the #RRGGBB format.\n * @deprecated This function cuts the RGB's alpha channel. Use the `toRGBFullFp` function instead.\n */\nexport function toRGBFp(value: string): E.Either<Error, RGB> {\n return fn.pipe(\n toRGBFullFp(value),\n E.map(rgb => rgb.slice(0, 7) as RGB),\n );\n}\n\n/**\n * @see toRGBFp\n * @deprecated This function cuts the RGB's alpha channel. Use the `toRGBFull` function instead.\n */\nexport const toRGB = throwifyFpFn(toRGBFp);\n\n/**\n * @see toRGBFullFp\n */\nexport const toRGBFull = throwifyFpFn(toRGBFullFp);\n","import type {\n Chat,\n InitData,\n KnownThemeParamsKey,\n LaunchParams,\n RGB,\n User,\n Auth\n} from '@vbotma/types';\nimport {\n type BaseSchema,\n boolean,\n check,\n type CheckAction,\n date,\n type InferOutput,\n integer,\n is,\n looseObject,\n number,\n type NumberSchema,\n optional,\n pipe,\n record,\n type RecordSchema,\n type SchemaWithPipe,\n string,\n type StringSchema,\n transform,\n type TransformAction,\n union,\n type UnionSchema,\n unknown,\n} from 'valibot';\n\nimport { pipeJsonToSchema, pipeQueryToSchema } from './pipes.js';\nimport { isAnyRGB } from './rgb.js';\n\nexport type InitDataGenSchema = ReturnType<typeof initData>;\nexport type InitDataGenType = InferOutput<InitDataGenSchema>;\n\nexport type LaunchParamsGenSchema = ReturnType<typeof launchParams>;\nexport type LaunchParamsGenType = InferOutput<LaunchParamsGenSchema>;\n\nexport type MiniAppsMessageGenSchema = ReturnType<typeof miniAppsMessage>;\nexport type MiniAppsMessageGenType = InferOutput<MiniAppsMessageGenSchema>;\n\nexport function initDataChat() {\n return looseObject({\n id: number(),\n photo_url: optional(string()),\n type: string(),\n title: string(),\n username: optional(string()),\n } satisfies { [K in keyof Chat]-?: BaseSchema<unknown, Chat[K], any> });\n}\n\nexport function initDataUser() {\n return looseObject({\n added_to_attachment_menu: optional(boolean()),\n allows_write_to_pm: optional(boolean()),\n first_name: string(),\n id: number(),\n is_bot: optional(boolean()),\n is_premium: optional(boolean()),\n last_name: optional(string()),\n language_code: optional(string()),\n photo_url: optional(string()),\n username: optional(string()),\n } satisfies { [K in keyof User]-?: BaseSchema<unknown, User[K], any> });\n}\n\nexport function initDataAuth() {\n return looseObject({\n projectCode: string(),\n uid: string(),\n sessionId: string(),\n rootToken: string(),\n } satisfies { [K in keyof Auth]-?: BaseSchema<unknown, Auth[K], any> });\n}\n\nexport function initData() {\n return looseObject({\n auth_date: pipe(\n string(),\n transform(input => new Date(Number(input) * 1000)),\n date(),\n ),\n can_send_after: optional(pipe(string(), transform(Number), integer())),\n chat: optional(pipeJsonToSchema(initDataChat())),\n chat_type: optional(string()),\n chat_instance: optional(string()),\n hash: optional(string()),\n query_id: optional(string()),\n receiver: optional(pipeJsonToSchema(initDataUser())),\n start_param: optional(string()),\n signature: optional(string()),\n user: optional(pipeJsonToSchema(initDataUser())),\n auth: optional(pipeJsonToSchema(initDataAuth())),\n } satisfies { [K in keyof InitData]-?: unknown });\n}\n\nexport function initDataQuery() {\n return pipeQueryToSchema(initData());\n}\n\nexport function themeParams() {\n return record(\n string(),\n pipe(\n union([string(), number()]),\n transform(value => {\n return typeof value === 'number'\n ? `#${(value & 0x00FFFFFF).toString(16).padStart(6, '0')}`\n : value;\n }),\n check(isAnyRGB),\n ),\n ) as RecordSchema<\n SchemaWithPipe<[\n StringSchema<undefined>,\n TransformAction<string, KnownThemeParamsKey>,\n ]>,\n SchemaWithPipe<[\n UnionSchema<[StringSchema<undefined>, NumberSchema<undefined>], any>,\n TransformAction<string | number, string>,\n CheckAction<RGB, undefined>,\n ]>,\n undefined\n >;\n}\n\nexport function launchParams() {\n const optBool = optional(pipe(string(), transform(v => v === '1')));\n\n return looseObject({\n vbWebAppBotInline: optBool,\n vbWebAppData: optional(initDataQuery()),\n vbWebAppDefaultColors: optional(pipeJsonToSchema(themeParams())),\n vbWebAppFullscreen: optBool,\n vbWebAppPlatform: string(),\n vbWebAppShowSettings: optBool,\n vbWebAppStartParam: optional(string()),\n vbWebAppThemeParams: pipeJsonToSchema(themeParams()),\n vbWebAppVersion: string(),\n } satisfies { [K in keyof LaunchParams]-?: BaseSchema<any, LaunchParams[K], any> });\n}\n\nexport function launchParamsQuery() {\n return pipeQueryToSchema(launchParams());\n}\n\n/**\n * @returns True if the passed value contains valid launch parameters query.\n */\nexport function isLaunchParamsQuery(value: string | URLSearchParams): boolean {\n try {\n return is(launchParamsQuery(), value);\n } catch {\n return false;\n }\n}\n\nexport function miniAppsMessage() {\n return looseObject({\n eventType: string(),\n eventData: optional(unknown()),\n });\n}\n","import { throwifyFpFn } from '@vbotma/toolkit';\nimport { either as E } from 'fp-ts';\nimport { parse, type ValiError } from 'valibot';\n\nimport {\n type InitDataGenSchema,\n type InitDataGenType,\n initDataQuery,\n type LaunchParamsGenSchema,\n type LaunchParamsGenType,\n launchParamsQuery,\n} from './structures.js';\n\nexport type ParseInitDataQueryError = ValiError<InitDataGenSchema>;\nexport type ParseLaunchParamsQueryError = ValiError<LaunchParamsGenSchema>;\n\nexport function parseInitDataQueryFp(value: string | URLSearchParams): E.Either<\n ParseInitDataQueryError,\n InitDataGenType\n> {\n return E.tryCatch(\n () => parse(initDataQuery(), value),\n e => e as ValiError<InitDataGenSchema>,\n );\n}\n\nexport function parseLaunchParamsQueryFp(value: string | URLSearchParams): E.Either<\n ParseLaunchParamsQueryError,\n LaunchParamsGenType\n> {\n return E.tryCatch(\n () => parse(launchParamsQuery(), value),\n e => e as ValiError<LaunchParamsGenSchema>,\n );\n}\n\nexport const parseInitDataQuery = throwifyFpFn(parseInitDataQueryFp);\nexport const parseLaunchParamsQuery = throwifyFpFn(parseLaunchParamsQueryFp);\n","import type { InitData, LaunchParams } from '@vbotma/types';\nimport type { InferOutput } from 'valibot';\n\nimport type { initData, launchParams } from './structures.js';\n\nexport type InitDataLike = Partial<InferOutput<ReturnType<typeof initData>> | InitData>;\nexport type LaunchParamsLike = Partial<InferOutput<ReturnType<typeof launchParams>> | LaunchParams>;\n\n/**\n * Converts the passed object to query parameters.\n * @param value - value to serialize.\n * @param onObject - function returning serialized object value.\n */\nfunction serializeToQuery(\n value: object,\n onObject?: (key: string, value: object) => string,\n): string {\n onObject ||= (_, value) => JSON.stringify(value);\n\n return new URLSearchParams(\n Object\n .entries(value)\n .reduce<[string, string][]>((acc, [key, value]) => {\n if (Array.isArray(value)) {\n acc.push(...value.map(v => [key, String(v)] as [string, string]));\n } else {\n if (value !== null && value !== undefined) {\n acc.push([\n key,\n value instanceof Date\n ? (value.getTime() / 1000 | 0).toString()\n : typeof value === 'string' || typeof value === 'number'\n ? String(value)\n : typeof value === 'boolean'\n ? value ? '1' : '0'\n : onObject(key, value),\n ]);\n }\n }\n return acc;\n }, []),\n ).toString();\n}\n\n/**\n * Serializes the InitDataQuery shape.\n * @param value - value to serialize.\n */\nexport function serializeInitDataQuery(value: InitDataLike): string {\n return serializeToQuery(value);\n}\n\n/**\n * Serializes the LaunchParamsQuery shape.\n * @param value - value to serialize.\n */\nexport function serializeLaunchParamsQuery(value: LaunchParamsLike): string {\n return serializeToQuery(value, (k, v) => {\n return k === 'vbWebAppData' ? serializeInitDataQuery(v as any) : JSON.stringify(v);\n });\n}\n"],"names":["transformQueryToSchema","schema","transformer","input","result","value","key","accValue","parse","pipe","union","string","instance","check","transform","transformJsonToSchema","pipeJsonToSchema","pipeQueryToSchema","guardBasedOn","re","isRGBShort","isRGBAShort","isRGB","isRGBA","isAnyRGB","fn","expandRgb","color","i","toRGBFullFp","clean","E","match","acc","component","toRGBFp","rgb","toRGB","throwifyFpFn","toRGBFull","initDataChat","looseObject","number","optional","initDataUser","boolean","initDataAuth","initData","date","integer","initDataQuery","themeParams","record","launchParams","optBool","v","launchParamsQuery","isLaunchParamsQuery","is","miniAppsMessage","unknown","parseInitDataQueryFp","e","parseLaunchParamsQueryFp","parseInitDataQuery","parseLaunchParamsQuery","serializeToQuery","onObject","_","serializeInitDataQuery","serializeLaunchParamsQuery","k"],"mappings":";;;AAqCO,SAASA,EACdC,GACsC;AACtC,QAAMC,IAAc,CAACC,MAAoC;AACvD,UAAMC,IAA4C,CAAA;AAElD,eAAI,gBAAgBD,CAAK,EAAE,QAAQ,CAACE,GAAOC,MAAQ;AACjD,YAAMC,IAAWH,EAAOE,CAAG;AAC3B,MAAI,MAAM,QAAQC,CAAQ,IACxBA,EAAS,KAAKF,CAAK,IACVE,MAAa,SACtBH,EAAOE,CAAG,IAAID,IAEdD,EAAOE,CAAG,IAAI,CAACC,GAAUF,CAAK;AAAA,IAElC,CAAC,GAEMG,EAAMP,GAAQG,CAAM;AAAA,EAC7B;AAEA,SAAOK;AAAA,IACLC,EAAM,CAACC,EAAA,GAAUC,EAAS,eAAe,CAAC,CAAC;AAAA,IAC3CC,EAAM,CAAAV,MAAS;AACb,UAAI;AACF,eAAAD,EAAYC,CAAK,GACV;AAAA,MACT,QAAQ;AACN,eAAO;AAAA,MACT;AAAA,IACF,GAAG,yCAA0C;AAAA,IAC7CW,EAAUZ,CAAW;AAAA,EAAA;AAEzB;AAKO,SAASa,EACdd,GACqC;AACrC,SAAOQ;AAAA,IACLE,EAAA;AAAA,IACAE,EAAM,CAAAV,MAAS;AACb,UAAI;AACF,oBAAK,MAAM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7D,GACA8D,GACQ;AACR,SAAAA,UAAa,CAACC,GAAG/D,MAAU,KAAK,UAAUA,CAAK,IAExC,IAAI;AAAA,IACT,OACG,QAAQA,CAAK,EACb,OAA2B,CAAC4B,GAAK,CAAC3B,GAAKD,CAAK,OACvC,MAAM,QAAQA,CAAK,IACrB4B,EAAI,KAAK,GAAG5B,EAAM,IAAI,CAAAkD,MAAK,CAACjD,GAAK,OAAOiD,CAAC,CAAC,CAAqB,CAAC,IAE5DlD,KAAU,QACZ4B,EAAI,KAAK;AAAA,MACP3B;AAAA,MACAD,aAAiB,QACZA,EAAM,QAAA,IAAY,MAAO,GAAG,SAAA,IAC7B,OAAOA,KAAU,YAAY,OAAOA,KAAU,WAC5C,OAAOA,CAAK,IACZ,OAAOA,KAAU,YACfA,IAAQ,MAAM,MACd8D,EAAS7D,GAAKD,CAAK;AAAA,IAAA,CAC5B,GAGE4B,IACN,CAAA,CAAE;AAAA,EAAA,EACP,SAAA;AACJ;AAMO,SAASoC,EAAuBhE,GAA6B;AAClE,SAAO6D,EAAiB7D,CAAK;AAC/B;AAMO,SAASiE,GAA2BjE,GAAiC;AAC1E,SAAO6D,EAAiB7D,GAAO,CAACkE,GAAGhB,MAC1BgB,MAAM,iBAAiBF,EAAuBd,CAAQ,IAAI,KAAK,UAAUA,CAAC,CAClF;AACH;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vbotma/transformers",
|
|
3
|
+
"version": "1.1.3",
|
|
4
|
+
"description": "Transformation utilities we use in the @vbot packages.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"vbot-mini-apps",
|
|
7
|
+
"typescript"
|
|
8
|
+
],
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"type": "module",
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"files": [
|
|
13
|
+
"dist"
|
|
14
|
+
],
|
|
15
|
+
"main": "./dist/index.cjs",
|
|
16
|
+
"module": "./dist/index.js",
|
|
17
|
+
"types": "./dist/dts/index.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/dts/index.d.ts",
|
|
21
|
+
"import": "./dist/index.js",
|
|
22
|
+
"require": "./dist/index.cjs",
|
|
23
|
+
"default": "./dist/index.cjs"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"fp-ts": "^2.16.11",
|
|
28
|
+
"valibot": "^1.1.0",
|
|
29
|
+
"@vbotma/toolkit": "^1.0.4",
|
|
30
|
+
"@vbotma/types": "^1.0.2"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"test-utils": "0.0.1",
|
|
34
|
+
"tsconfig": "0.0.2"
|
|
35
|
+
},
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"test": "vitest --run",
|
|
41
|
+
"lint": "eslint src",
|
|
42
|
+
"lint:fix": "pnpm run lint --fix",
|
|
43
|
+
"typecheck": "tsc --noEmit -p tsconfig.build.json",
|
|
44
|
+
"build": "vite build -c vite.config.ts"
|
|
45
|
+
}
|
|
46
|
+
}
|