@telegram-apps/transformers
Advanced tools
Comparing version 2.1.0 to 2.2.0
@@ -44,3 +44,3 @@ export declare const launchParamsQuery: import('../camel-casing/createQueryCamelCaseGen.js').CamelCaseQueryTransformer<import('valibot').LooseObjectSchema<{ | ||
}, undefined>, false>, undefined>; | ||
tgWebAppDefaultColors: import('valibot').OptionalSchema<import('../index.js').CamelCaseJsonTransformerPipe<import('../index.js').CamelCaseTransformerPipe<import('valibot').RecordSchema<import('valibot').SchemaWithPipe<[import('valibot').StringSchema<undefined>, import('valibot').TransformAction<string, import('@telegram-apps/types').KnownThemeParamsKey>]>, import('valibot').SchemaWithPipe<[import('valibot').StringSchema<undefined>, import('valibot').CheckAction<string, undefined>, import('valibot').TransformAction<string, `#${string}`>]>, undefined>, false>, false>, undefined>; | ||
tgWebAppDefaultColors: import('valibot').OptionalSchema<import('../index.js').CamelCaseJsonTransformerPipe<import('../index.js').CamelCaseTransformerPipe<import('valibot').RecordSchema<import('valibot').SchemaWithPipe<[import('valibot').StringSchema<undefined>, import('valibot').TransformAction<string, import('@telegram-apps/types').KnownThemeParamsKey>]>, import('valibot').SchemaWithPipe<[import('valibot').UnionSchema<[import('valibot').StringSchema<undefined>, import('valibot').NumberSchema<undefined>], any>, import('valibot').TransformAction<string | number, string>, import('valibot').CheckAction<`#${string}`, undefined>]>, undefined>, false>, false>, undefined>; | ||
tgWebAppFullscreen: import('valibot').OptionalSchema<import('valibot').SchemaWithPipe<[import('valibot').StringSchema<undefined>, import('valibot').TransformAction<string, boolean>]>, undefined>; | ||
@@ -50,4 +50,4 @@ tgWebAppPlatform: import('valibot').StringSchema<undefined>; | ||
tgWebAppStartParam: import('valibot').OptionalSchema<import('valibot').StringSchema<undefined>, undefined>; | ||
tgWebAppThemeParams: import('../index.js').CamelCaseJsonTransformerPipe<import('../index.js').CamelCaseTransformerPipe<import('valibot').RecordSchema<import('valibot').SchemaWithPipe<[import('valibot').StringSchema<undefined>, import('valibot').TransformAction<string, import('@telegram-apps/types').KnownThemeParamsKey>]>, import('valibot').SchemaWithPipe<[import('valibot').StringSchema<undefined>, import('valibot').CheckAction<string, undefined>, import('valibot').TransformAction<string, `#${string}`>]>, undefined>, false>, false>; | ||
tgWebAppThemeParams: import('../index.js').CamelCaseJsonTransformerPipe<import('../index.js').CamelCaseTransformerPipe<import('valibot').RecordSchema<import('valibot').SchemaWithPipe<[import('valibot').StringSchema<undefined>, import('valibot').TransformAction<string, import('@telegram-apps/types').KnownThemeParamsKey>]>, import('valibot').SchemaWithPipe<[import('valibot').UnionSchema<[import('valibot').StringSchema<undefined>, import('valibot').NumberSchema<undefined>], any>, import('valibot').TransformAction<string | number, string>, import('valibot').CheckAction<`#${string}`, undefined>]>, undefined>, false>, false>; | ||
tgWebAppVersion: import('valibot').StringSchema<undefined>; | ||
}, undefined>>; |
@@ -1,4 +0,4 @@ | ||
import { CheckAction, RecordSchema, SchemaWithPipe, StringSchema, TransformAction } from 'valibot'; | ||
import { CheckAction, NumberSchema, RecordSchema, SchemaWithPipe, StringSchema, TransformAction, UnionSchema } from 'valibot'; | ||
import { RGB, KnownThemeParamsKey } from '@telegram-apps/types'; | ||
import { CamelCaseTransformer } from '../camel-casing/createCamelCaseGen.js'; | ||
export declare const themeParams: CamelCaseTransformer<RecordSchema<SchemaWithPipe<[StringSchema<undefined>, TransformAction<string, KnownThemeParamsKey>]>, SchemaWithPipe<[StringSchema<undefined>, CheckAction<string, undefined>, TransformAction<string, RGB>]>, undefined>>; | ||
export declare const themeParams: CamelCaseTransformer<RecordSchema<SchemaWithPipe<[StringSchema<undefined>, TransformAction<string, KnownThemeParamsKey>]>, SchemaWithPipe<[UnionSchema<[StringSchema<undefined>, NumberSchema<undefined>], any>, TransformAction<string | number, string>, CheckAction<RGB, undefined>]>, undefined>>; |
@@ -44,3 +44,3 @@ export declare const LaunchParamsSchema: import('valibot').LooseObjectSchema<{ | ||
}, undefined>, false>, undefined>; | ||
tgWebAppDefaultColors: import('valibot').OptionalSchema<import('../camel-casing/createJsonCamelCaseGen.js').CamelCaseJsonTransformerPipe<import('../index.js').CamelCaseTransformerPipe<import('valibot').RecordSchema<import('valibot').SchemaWithPipe<[import('valibot').StringSchema<undefined>, import('valibot').TransformAction<string, import('@telegram-apps/types').KnownThemeParamsKey>]>, import('valibot').SchemaWithPipe<[import('valibot').StringSchema<undefined>, import('valibot').CheckAction<string, undefined>, import('valibot').TransformAction<string, `#${string}`>]>, undefined>, false>, false>, undefined>; | ||
tgWebAppDefaultColors: import('valibot').OptionalSchema<import('../camel-casing/createJsonCamelCaseGen.js').CamelCaseJsonTransformerPipe<import('../index.js').CamelCaseTransformerPipe<import('valibot').RecordSchema<import('valibot').SchemaWithPipe<[import('valibot').StringSchema<undefined>, import('valibot').TransformAction<string, import('@telegram-apps/types').KnownThemeParamsKey>]>, import('valibot').SchemaWithPipe<[import('valibot').UnionSchema<[import('valibot').StringSchema<undefined>, import('valibot').NumberSchema<undefined>], any>, import('valibot').TransformAction<string | number, string>, import('valibot').CheckAction<`#${string}`, undefined>]>, undefined>, false>, false>, undefined>; | ||
tgWebAppFullscreen: import('valibot').OptionalSchema<import('valibot').SchemaWithPipe<[import('valibot').StringSchema<undefined>, import('valibot').TransformAction<string, boolean>]>, undefined>; | ||
@@ -50,4 +50,4 @@ tgWebAppPlatform: import('valibot').StringSchema<undefined>; | ||
tgWebAppStartParam: import('valibot').OptionalSchema<import('valibot').StringSchema<undefined>, undefined>; | ||
tgWebAppThemeParams: import('../camel-casing/createJsonCamelCaseGen.js').CamelCaseJsonTransformerPipe<import('../index.js').CamelCaseTransformerPipe<import('valibot').RecordSchema<import('valibot').SchemaWithPipe<[import('valibot').StringSchema<undefined>, import('valibot').TransformAction<string, import('@telegram-apps/types').KnownThemeParamsKey>]>, import('valibot').SchemaWithPipe<[import('valibot').StringSchema<undefined>, import('valibot').CheckAction<string, undefined>, import('valibot').TransformAction<string, `#${string}`>]>, undefined>, false>, false>; | ||
tgWebAppThemeParams: import('../camel-casing/createJsonCamelCaseGen.js').CamelCaseJsonTransformerPipe<import('../index.js').CamelCaseTransformerPipe<import('valibot').RecordSchema<import('valibot').SchemaWithPipe<[import('valibot').StringSchema<undefined>, import('valibot').TransformAction<string, import('@telegram-apps/types').KnownThemeParamsKey>]>, import('valibot').SchemaWithPipe<[import('valibot').UnionSchema<[import('valibot').StringSchema<undefined>, import('valibot').NumberSchema<undefined>], any>, import('valibot').TransformAction<string | number, string>, import('valibot').CheckAction<`#${string}`, undefined>]>, undefined>, false>, false>; | ||
tgWebAppVersion: import('valibot').StringSchema<undefined>; | ||
}, undefined>; |
var b; | ||
// @__NO_SIDE_EFFECTS__ | ||
function G(e) { | ||
function N(e) { | ||
return { | ||
@@ -11,17 +11,17 @@ lang: (e == null ? void 0 : e.lang) ?? (b == null ? void 0 : b.lang), | ||
} | ||
var E; | ||
var D; | ||
// @__NO_SIDE_EFFECTS__ | ||
function Z(e) { | ||
return E == null ? void 0 : E.get(e); | ||
return D == null ? void 0 : D.get(e); | ||
} | ||
var D; | ||
var P; | ||
// @__NO_SIDE_EFFECTS__ | ||
function ee(e) { | ||
return D == null ? void 0 : D.get(e); | ||
return P == null ? void 0 : P.get(e); | ||
} | ||
var P; | ||
var j; | ||
// @__NO_SIDE_EFFECTS__ | ||
function ne(e, n) { | ||
var r; | ||
return (r = P == null ? void 0 : P.get(e)) == null ? void 0 : r.get(n); | ||
return (r = j == null ? void 0 : j.get(e)) == null ? void 0 : r.get(n); | ||
} | ||
@@ -60,3 +60,3 @@ // @__NO_SIDE_EFFECTS__ | ||
validate(n) { | ||
return e["~run"]({ value: n }, /* @__PURE__ */ G()); | ||
return e["~run"]({ value: n }, /* @__PURE__ */ N()); | ||
} | ||
@@ -66,3 +66,3 @@ }; | ||
// @__NO_SIDE_EFFECTS__ | ||
function N(e, n) { | ||
function W(e, n) { | ||
return Object.hasOwn(e, n) && n !== "__proto__" && n !== "prototype" && n !== "constructor"; | ||
@@ -86,7 +86,7 @@ } | ||
// @__NO_SIDE_EFFECTS__ | ||
function W(e, n) { | ||
function L(e, n) { | ||
return { | ||
kind: "validation", | ||
type: "check", | ||
reference: W, | ||
reference: L, | ||
async: !1, | ||
@@ -102,7 +102,7 @@ expects: null, | ||
// @__NO_SIDE_EFFECTS__ | ||
function L(e) { | ||
function R(e) { | ||
return { | ||
kind: "validation", | ||
type: "integer", | ||
reference: L, | ||
reference: R, | ||
async: !1, | ||
@@ -118,7 +118,7 @@ expects: null, | ||
// @__NO_SIDE_EFFECTS__ | ||
function v(e) { | ||
function d(e) { | ||
return { | ||
kind: "transformation", | ||
type: "transform", | ||
reference: v, | ||
reference: d, | ||
async: !1, | ||
@@ -132,3 +132,3 @@ operation: e, | ||
// @__NO_SIDE_EFFECTS__ | ||
function R(e, n, r) { | ||
function U(e, n, r) { | ||
return typeof e.default == "function" ? ( | ||
@@ -164,7 +164,7 @@ // @ts-expect-error | ||
// @__NO_SIDE_EFFECTS__ | ||
function U(e) { | ||
function z(e) { | ||
return { | ||
kind: "schema", | ||
type: "date", | ||
reference: U, | ||
reference: z, | ||
expects: "Date", | ||
@@ -184,7 +184,7 @@ async: !1, | ||
// @__NO_SIDE_EFFECTS__ | ||
function z(e, n) { | ||
function J(e, n) { | ||
return { | ||
kind: "schema", | ||
type: "instance", | ||
reference: z, | ||
reference: J, | ||
expects: e.name, | ||
@@ -203,7 +203,7 @@ async: !1, | ||
// @__NO_SIDE_EFFECTS__ | ||
function w(e) { | ||
function A(e) { | ||
return { | ||
kind: "schema", | ||
type: "lazy", | ||
reference: w, | ||
reference: A, | ||
expects: "unknown", | ||
@@ -245,3 +245,3 @@ async: !1, | ||
s[i] | ||
) : /* @__PURE__ */ R(l), y = l["~run"]({ value: o }, t); | ||
) : /* @__PURE__ */ U(l), y = l["~run"]({ value: o }, t); | ||
if (y.issues) { | ||
@@ -281,3 +281,3 @@ const p = { | ||
for (const i in s) | ||
/* @__PURE__ */ N(s, i) && !(i in this.entries) && (r.value[i] = s[i]); | ||
/* @__PURE__ */ W(s, i) && !(i in this.entries) && (r.value[i] = s[i]); | ||
} else | ||
@@ -290,7 +290,7 @@ f(this, "type", r, t); | ||
// @__NO_SIDE_EFFECTS__ | ||
function A(e) { | ||
function E(e) { | ||
return { | ||
kind: "schema", | ||
type: "number", | ||
reference: A, | ||
reference: E, | ||
expects: "number", | ||
@@ -321,3 +321,3 @@ async: !1, | ||
"~run"(r, t) { | ||
return r.value === void 0 && (this.default !== void 0 && (r.value = /* @__PURE__ */ R(this, r, t)), r.value === void 0) ? (r.typed = !0, r) : this.wrapped["~run"](r, t); | ||
return r.value === void 0 && (this.default !== void 0 && (r.value = /* @__PURE__ */ U(this, r, t)), r.value === void 0) ? (r.typed = !0, r) : this.wrapped["~run"](r, t); | ||
} | ||
@@ -327,7 +327,7 @@ }; | ||
// @__NO_SIDE_EFFECTS__ | ||
function J(e, n, r) { | ||
function V(e, n, r) { | ||
return { | ||
kind: "schema", | ||
type: "record", | ||
reference: J, | ||
reference: V, | ||
expects: "Object", | ||
@@ -347,3 +347,3 @@ async: !1, | ||
for (const o in u) | ||
if (/* @__PURE__ */ N(u, o)) { | ||
if (/* @__PURE__ */ W(u, o)) { | ||
const y = u[o], p = this.key["~run"]({ value: o }, s); | ||
@@ -410,3 +410,3 @@ if (p.issues) { | ||
// @__NO_SIDE_EFFECTS__ | ||
function C(e) { | ||
function O(e) { | ||
let n; | ||
@@ -419,7 +419,7 @@ if (e) | ||
// @__NO_SIDE_EFFECTS__ | ||
function V(e, n) { | ||
function $(e, n) { | ||
return { | ||
kind: "schema", | ||
type: "union", | ||
reference: V, | ||
reference: $, | ||
expects: /* @__PURE__ */ te( | ||
@@ -455,3 +455,3 @@ e.map((r) => r.expects), | ||
f(this, "type", r, t, { | ||
issues: /* @__PURE__ */ C(u) | ||
issues: /* @__PURE__ */ O(u) | ||
}), r.typed = !0; | ||
@@ -462,3 +462,3 @@ } else { | ||
f(this, "type", r, t, { | ||
issues: /* @__PURE__ */ C(i) | ||
issues: /* @__PURE__ */ O(i) | ||
}); | ||
@@ -487,3 +487,3 @@ } | ||
function B(e, n, r) { | ||
const t = e["~run"]({ value: n }, /* @__PURE__ */ G(r)); | ||
const t = e["~run"]({ value: n }, /* @__PURE__ */ N(r)); | ||
if (t.issues) | ||
@@ -494,3 +494,3 @@ throw new se(t.issues); | ||
// @__NO_SIDE_EFFECTS__ | ||
function d(...e) { | ||
function v(...e) { | ||
return { | ||
@@ -521,7 +521,7 @@ ...e[0], | ||
} | ||
function x(e) { | ||
function w(e) { | ||
const n = ae(e); | ||
for (const r in n) { | ||
const t = n[r]; | ||
t && typeof t == "object" && !(t instanceof Date) && (n[r] = Array.isArray(t) ? t.map(x) : x(t)); | ||
t && typeof t == "object" && !(t instanceof Date) && (n[r] = Array.isArray(t) ? t.map(w) : w(t)); | ||
} | ||
@@ -531,6 +531,6 @@ return n; | ||
function I(e) { | ||
return /* @__PURE__ */ v((n) => e ? x(n) : n); | ||
return /* @__PURE__ */ d((n) => e ? w(n) : n); | ||
} | ||
function M(e) { | ||
return (n) => /* @__PURE__ */ d( | ||
return (n) => /* @__PURE__ */ v( | ||
e, | ||
@@ -542,3 +542,3 @@ I(n) | ||
return (n, r) => B( | ||
/* @__PURE__ */ d(e, I(r)), | ||
/* @__PURE__ */ v(e, I(r)), | ||
n | ||
@@ -548,7 +548,7 @@ ); | ||
function oe() { | ||
return /* @__PURE__ */ v(JSON.parse); | ||
return /* @__PURE__ */ d(JSON.parse); | ||
} | ||
function $(e) { | ||
function C(e) { | ||
const n = M(e); | ||
return (r) => /* @__PURE__ */ d( | ||
return (r) => /* @__PURE__ */ v( | ||
/* @__PURE__ */ a(), | ||
@@ -560,3 +560,3 @@ oe(), | ||
function ce(e) { | ||
return /* @__PURE__ */ v((n) => { | ||
return /* @__PURE__ */ d((n) => { | ||
const r = {}; | ||
@@ -570,4 +570,4 @@ return new URLSearchParams(n).forEach((t, s) => { | ||
function K(e) { | ||
return (n) => /* @__PURE__ */ d( | ||
/* @__PURE__ */ V([/* @__PURE__ */ a(), /* @__PURE__ */ z(URLSearchParams)]), | ||
return (n) => /* @__PURE__ */ v( | ||
/* @__PURE__ */ $([/* @__PURE__ */ a(), /* @__PURE__ */ J(URLSearchParams)]), | ||
ce(e), | ||
@@ -577,4 +577,4 @@ I(n) | ||
} | ||
const O = /* @__PURE__ */ c(/* @__PURE__ */ w(() => he())), le = /* @__PURE__ */ k({ | ||
id: /* @__PURE__ */ A(), | ||
const Q = /* @__PURE__ */ c(/* @__PURE__ */ A(() => he())), le = /* @__PURE__ */ k({ | ||
id: /* @__PURE__ */ E(), | ||
photo_url: /* @__PURE__ */ c(/* @__PURE__ */ a()), | ||
@@ -588,3 +588,3 @@ type: /* @__PURE__ */ a(), | ||
first_name: /* @__PURE__ */ a(), | ||
id: /* @__PURE__ */ A(), | ||
id: /* @__PURE__ */ E(), | ||
is_bot: /* @__PURE__ */ c(/* @__PURE__ */ _()), | ||
@@ -597,9 +597,9 @@ is_premium: /* @__PURE__ */ c(/* @__PURE__ */ _()), | ||
}), fe = /* @__PURE__ */ k({ | ||
auth_date: /* @__PURE__ */ d( | ||
auth_date: /* @__PURE__ */ v( | ||
/* @__PURE__ */ a(), | ||
/* @__PURE__ */ v((e) => new Date(Number(e) * 1e3)), | ||
/* @__PURE__ */ U() | ||
/* @__PURE__ */ d((e) => new Date(Number(e) * 1e3)), | ||
/* @__PURE__ */ z() | ||
), | ||
can_send_after: /* @__PURE__ */ c(/* @__PURE__ */ d(/* @__PURE__ */ a(), /* @__PURE__ */ v(Number), /* @__PURE__ */ L())), | ||
chat: /* @__PURE__ */ c(/* @__PURE__ */ w(() => ye())), | ||
can_send_after: /* @__PURE__ */ c(/* @__PURE__ */ v(/* @__PURE__ */ a(), /* @__PURE__ */ d(Number), /* @__PURE__ */ R())), | ||
chat: /* @__PURE__ */ c(/* @__PURE__ */ A(() => ye())), | ||
chat_type: /* @__PURE__ */ c(/* @__PURE__ */ a()), | ||
@@ -609,7 +609,7 @@ chat_instance: /* @__PURE__ */ c(/* @__PURE__ */ a()), | ||
query_id: /* @__PURE__ */ c(/* @__PURE__ */ a()), | ||
receiver: O, | ||
receiver: Q, | ||
start_param: /* @__PURE__ */ c(/* @__PURE__ */ a()), | ||
signature: /* @__PURE__ */ a(), | ||
user: O | ||
}), ye = $(le), he = $(pe), F = K(fe); | ||
user: Q | ||
}), ye = C(le), he = C(pe), F = K(fe); | ||
function H(e) { | ||
@@ -637,19 +637,23 @@ return /^#[\da-f]{6}$/i.test(e); | ||
const be = M( | ||
/* @__PURE__ */ J( | ||
/* @__PURE__ */ V( | ||
/* @__PURE__ */ a(), | ||
/* @__PURE__ */ d(/* @__PURE__ */ a(), /* @__PURE__ */ W(H), /* @__PURE__ */ v((e) => e)) | ||
/* @__PURE__ */ v( | ||
/* @__PURE__ */ $([/* @__PURE__ */ a(), /* @__PURE__ */ E()]), | ||
/* @__PURE__ */ d((e) => typeof e == "number" ? `#${(e & 16777215).toString(16).padStart(6, "0")}` : e), | ||
/* @__PURE__ */ L(H) | ||
) | ||
) | ||
), j = /* @__PURE__ */ c( | ||
/* @__PURE__ */ d(/* @__PURE__ */ a(), /* @__PURE__ */ v((e) => e === "1")) | ||
), Q = $(be()), ve = /* @__PURE__ */ k({ | ||
tgWebAppBotInline: j, | ||
), x = /* @__PURE__ */ c( | ||
/* @__PURE__ */ v(/* @__PURE__ */ a(), /* @__PURE__ */ d((e) => e === "1")) | ||
), G = C(be()), de = /* @__PURE__ */ k({ | ||
tgWebAppBotInline: x, | ||
tgWebAppData: /* @__PURE__ */ c(F()), | ||
tgWebAppDefaultColors: /* @__PURE__ */ c(Q()), | ||
tgWebAppFullscreen: j, | ||
tgWebAppDefaultColors: /* @__PURE__ */ c(G()), | ||
tgWebAppFullscreen: x, | ||
tgWebAppPlatform: /* @__PURE__ */ a(), | ||
tgWebAppShowSettings: j, | ||
tgWebAppShowSettings: x, | ||
tgWebAppStartParam: /* @__PURE__ */ c(/* @__PURE__ */ a()), | ||
tgWebAppThemeParams: Q(), | ||
tgWebAppThemeParams: G(), | ||
tgWebAppVersion: /* @__PURE__ */ a() | ||
}), X = K(ve), ke = T(F()), _e = T(X()), Se = /* @__PURE__ */ k({ | ||
}), X = K(de), ke = T(F()), _e = T(X()), Se = /* @__PURE__ */ k({ | ||
eventType: /* @__PURE__ */ a(), | ||
@@ -666,7 +670,7 @@ eventData: /* @__PURE__ */ c(/* @__PURE__ */ q()) | ||
} | ||
function de(e) { | ||
function ve(e) { | ||
return Y(e); | ||
} | ||
function Ee(e) { | ||
return Y(e, (n, r) => n === "tgWebAppData" ? de(r) : JSON.stringify(r)); | ||
return Y(e, (n, r) => n === "tgWebAppData" ? ve(r) : JSON.stringify(r)); | ||
} | ||
@@ -684,3 +688,3 @@ function De(e) { | ||
pe as InitDataUserSchema, | ||
ve as LaunchParamsSchema, | ||
de as LaunchParamsSchema, | ||
Se as MiniAppsMessageSchema, | ||
@@ -690,3 +694,3 @@ I as conditionalSnakeKeys, | ||
T as createCamelCaseSchemaParserGen, | ||
$ as createJsonCamelCaseGen, | ||
C as createJsonCamelCaseGen, | ||
K as createQueryCamelCaseGen, | ||
@@ -703,3 +707,3 @@ ye as initDataChatJson, | ||
_e as parseLaunchParamsQuery, | ||
de as serializeInitDataQuery, | ||
ve as serializeInitDataQuery, | ||
Ee as serializeLaunchParamsQuery, | ||
@@ -706,0 +710,0 @@ Y as serializeToQuery, |
{ | ||
"name": "@telegram-apps/transformers", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"description": "Transformation utilities we use in the @telegram-apps packages.", | ||
@@ -5,0 +5,0 @@ "author": "Vladislav Kibenko <wolfram.deus@gmail.com>", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
532159
1257