@tma.js/init-data 0.2.14 → 0.2.15

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/dist/index.js ADDED
@@ -0,0 +1,36 @@
1
+ import { json as i, string as o, number as r, boolean as a, searchParams as s, date as e } from "@tma.js/parsing";
2
+ function t(l, p) {
3
+ return {
4
+ from: p,
5
+ type: l
6
+ };
7
+ }
8
+ const n = i({
9
+ firstName: t(o(), "first_name"),
10
+ id: r(),
11
+ isBot: t(a().optional(), "is_bot"),
12
+ isPremium: t(a().optional(), "is_premium"),
13
+ lastName: t(o().optional(), "last_name"),
14
+ languageCode: t(o().optional(), "language_code"),
15
+ photoUrl: t(o().optional(), "photo_url"),
16
+ username: o().optional()
17
+ }), m = s({
18
+ authDate: t(e(), "auth_date"),
19
+ hash: o(),
20
+ user: n.optional(),
21
+ receiver: n.optional(),
22
+ chat: i({
23
+ id: r(),
24
+ type: o(),
25
+ title: o(),
26
+ photoUrl: t(o().optional(), "photo_url"),
27
+ username: o().optional()
28
+ }).optional(),
29
+ canSendAfter: t(e().optional(), "can_send_after"),
30
+ queryId: t(o().optional(), "query_id"),
31
+ startParam: t(o().optional(), "start_param")
32
+ });
33
+ export {
34
+ m as initData
35
+ };
36
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../src/parsing.ts"],"sourcesContent":["import {\n searchParams,\n json,\n string,\n number,\n boolean,\n date,\n type AnyParser,\n} from '@tma.js/parsing';\n\nimport type { InitData, User } from './types.js';\n\nfunction field<P extends AnyParser<any>>(parser: P, from?: string) {\n return {\n from,\n type: parser,\n };\n}\n\nconst user = json<User>({\n firstName: field(string(), 'first_name'),\n id: number(),\n isBot: field(boolean().optional(), 'is_bot'),\n isPremium: field(boolean().optional(), 'is_premium'),\n lastName: field(string().optional(), 'last_name'),\n languageCode: field(string().optional(), 'language_code'),\n photoUrl: field(string().optional(), 'photo_url'),\n username: string().optional(),\n});\n\n/**\n * Parser used to parse init data, presented as search params.\n */\nexport const initData = searchParams<InitData>({\n authDate: field(date(), 'auth_date'),\n hash: string(),\n user: user.optional(),\n receiver: user.optional(),\n chat: json<InitData['chat']>({\n id: number(),\n type: string(),\n title: string(),\n photoUrl: field(string().optional(), 'photo_url'),\n username: string().optional(),\n }).optional(),\n canSendAfter: field(date().optional(), 'can_send_after'),\n queryId: field(string().optional(), 'query_id'),\n startParam: field(string().optional(), 'start_param'),\n});\n"],"names":["field","parser","from","user","json","string","number","boolean","initData","searchParams","date"],"mappings":";AAYA,SAASA,EAAgCC,GAAWC,GAAe;AAC1D,SAAA;AAAA,IACL,MAAAA;AAAA,IACA,MAAMD;AAAA,EAAA;AAEV;AAEA,MAAME,IAAOC,EAAW;AAAA,EACtB,WAAWJ,EAAMK,EAAO,GAAG,YAAY;AAAA,EACvC,IAAIC,EAAO;AAAA,EACX,OAAON,EAAMO,EAAU,EAAA,SAAA,GAAY,QAAQ;AAAA,EAC3C,WAAWP,EAAMO,EAAU,EAAA,SAAA,GAAY,YAAY;AAAA,EACnD,UAAUP,EAAMK,EAAS,EAAA,SAAA,GAAY,WAAW;AAAA,EAChD,cAAcL,EAAMK,EAAS,EAAA,SAAA,GAAY,eAAe;AAAA,EACxD,UAAUL,EAAMK,EAAS,EAAA,SAAA,GAAY,WAAW;AAAA,EAChD,UAAUA,EAAO,EAAE,SAAS;AAC9B,CAAC,GAKYG,IAAWC,EAAuB;AAAA,EAC7C,UAAUT,EAAMU,EAAK,GAAG,WAAW;AAAA,EACnC,MAAML,EAAO;AAAA,EACb,MAAMF,EAAK,SAAS;AAAA,EACpB,UAAUA,EAAK,SAAS;AAAA,EACxB,MAAMC,EAAuB;AAAA,IAC3B,IAAIE,EAAO;AAAA,IACX,MAAMD,EAAO;AAAA,IACb,OAAOA,EAAO;AAAA,IACd,UAAUL,EAAMK,EAAS,EAAA,SAAA,GAAY,WAAW;AAAA,IAChD,UAAUA,EAAO,EAAE,SAAS;AAAA,EAC7B,CAAA,EAAE,SAAS;AAAA,EACZ,cAAcL,EAAMU,EAAO,EAAA,SAAA,GAAY,gBAAgB;AAAA,EACvD,SAASV,EAAMK,EAAS,EAAA,SAAA,GAAY,UAAU;AAAA,EAC9C,YAAYL,EAAMK,EAAS,EAAA,SAAA,GAAY,aAAa;AACtD,CAAC;"}
@@ -0,0 +1,2 @@
1
+ (function(o,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("@tma.js/parsing")):typeof define=="function"&&define.amd?define(["exports","@tma.js/parsing"],t):(o=typeof globalThis<"u"?globalThis:o||self,t((o["@tma"]=o["@tma"]||{},o["@tma"]["js/init-data"]={}),o["@tma"]["js/parsing"]))})(this,function(o,t){"use strict";function e(a,r){return{from:r,type:a}}const n=t.json({firstName:e(t.string(),"first_name"),id:t.number(),isBot:e(t.boolean().optional(),"is_bot"),isPremium:e(t.boolean().optional(),"is_premium"),lastName:e(t.string().optional(),"last_name"),languageCode:e(t.string().optional(),"language_code"),photoUrl:e(t.string().optional(),"photo_url"),username:t.string().optional()}),i=t.searchParams({authDate:e(t.date(),"auth_date"),hash:t.string(),user:n.optional(),receiver:n.optional(),chat:t.json({id:t.number(),type:t.string(),title:t.string(),photoUrl:e(t.string().optional(),"photo_url"),username:t.string().optional()}).optional(),canSendAfter:e(t.date().optional(),"can_send_after"),queryId:e(t.string().optional(),"query_id"),startParam:e(t.string().optional(),"start_param")});o.initData=i,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
2
+ //# sourceMappingURL=index.umd.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.umd.cjs","sources":["../src/parsing.ts"],"sourcesContent":["import {\n searchParams,\n json,\n string,\n number,\n boolean,\n date,\n type AnyParser,\n} from '@tma.js/parsing';\n\nimport type { InitData, User } from './types.js';\n\nfunction field<P extends AnyParser<any>>(parser: P, from?: string) {\n return {\n from,\n type: parser,\n };\n}\n\nconst user = json<User>({\n firstName: field(string(), 'first_name'),\n id: number(),\n isBot: field(boolean().optional(), 'is_bot'),\n isPremium: field(boolean().optional(), 'is_premium'),\n lastName: field(string().optional(), 'last_name'),\n languageCode: field(string().optional(), 'language_code'),\n photoUrl: field(string().optional(), 'photo_url'),\n username: string().optional(),\n});\n\n/**\n * Parser used to parse init data, presented as search params.\n */\nexport const initData = searchParams<InitData>({\n authDate: field(date(), 'auth_date'),\n hash: string(),\n user: user.optional(),\n receiver: user.optional(),\n chat: json<InitData['chat']>({\n id: number(),\n type: string(),\n title: string(),\n photoUrl: field(string().optional(), 'photo_url'),\n username: string().optional(),\n }).optional(),\n canSendAfter: field(date().optional(), 'can_send_after'),\n queryId: field(string().optional(), 'query_id'),\n startParam: field(string().optional(), 'start_param'),\n});\n"],"names":["field","parser","from","user","json","string","number","boolean","initData","searchParams","date"],"mappings":"gVAYA,SAASA,EAAgCC,EAAWC,EAAe,CAC1D,MAAA,CACL,KAAAA,EACA,KAAMD,CAAA,CAEV,CAEA,MAAME,EAAOC,EAAAA,KAAW,CACtB,UAAWJ,EAAMK,SAAO,EAAG,YAAY,EACvC,GAAIC,EAAAA,OAAO,EACX,MAAON,EAAMO,EAAAA,QAAU,EAAA,SAAA,EAAY,QAAQ,EAC3C,UAAWP,EAAMO,EAAAA,QAAU,EAAA,SAAA,EAAY,YAAY,EACnD,SAAUP,EAAMK,EAAAA,OAAS,EAAA,SAAA,EAAY,WAAW,EAChD,aAAcL,EAAMK,EAAAA,OAAS,EAAA,SAAA,EAAY,eAAe,EACxD,SAAUL,EAAMK,EAAAA,OAAS,EAAA,SAAA,EAAY,WAAW,EAChD,SAAUA,EAAAA,OAAO,EAAE,SAAS,CAC9B,CAAC,EAKYG,EAAWC,EAAAA,aAAuB,CAC7C,SAAUT,EAAMU,OAAK,EAAG,WAAW,EACnC,KAAML,EAAAA,OAAO,EACb,KAAMF,EAAK,SAAS,EACpB,SAAUA,EAAK,SAAS,EACxB,KAAMC,EAAAA,KAAuB,CAC3B,GAAIE,EAAAA,OAAO,EACX,KAAMD,EAAAA,OAAO,EACb,MAAOA,EAAAA,OAAO,EACd,SAAUL,EAAMK,EAAAA,OAAS,EAAA,SAAA,EAAY,WAAW,EAChD,SAAUA,EAAAA,OAAO,EAAE,SAAS,CAC7B,CAAA,EAAE,SAAS,EACZ,aAAcL,EAAMU,EAAAA,KAAO,EAAA,SAAA,EAAY,gBAAgB,EACvD,QAASV,EAAMK,EAAAA,OAAS,EAAA,SAAA,EAAY,UAAU,EAC9C,WAAYL,EAAMK,EAAAA,OAAS,EAAA,SAAA,EAAY,aAAa,CACtD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tma.js/init-data",
3
- "version": "0.2.14",
3
+ "version": "0.2.15",
4
4
  "description": "Frontend TypeScript library to make work with Web Apps init data easier.",
5
5
  "author": "Vladislav Kibenko <wolfram.deus@gmail.com>",
6
6
  "homepage": "https://github.com/Telegram-Mini-Apps/tma.js#readme",
@@ -24,31 +24,26 @@
24
24
  "dist",
25
25
  "src"
26
26
  ],
27
- "main": "dist/lib/index.cjs",
28
- "browser": "dist/lib/browser.js",
29
- "module": "dist/lib/index.mjs",
30
- "types": "dist/types/index.d.ts",
27
+ "main": "./dist/index.umd.cjs",
28
+ "browser": "./dist/index.umd.cjs",
29
+ "module": "./dist/index.js",
30
+ "types": "./dist/dts/index.d.ts",
31
31
  "exports": {
32
32
  ".": {
33
- "types": "./dist/types/index.d.ts",
34
- "import": "./dist/lib/index.mjs",
35
- "require": "./dist/lib/index.cjs",
36
- "default": "./dist/lib/index.cjs"
37
- },
38
- "./*": {
39
- "types": "./dist/types/*.d.ts",
40
- "import": "./dist/lib/*.mjs",
41
- "require": "./dist/lib/*.cjs",
42
- "default": "./dist/lib/*.cjs"
33
+ "types": "./dist/dts/index.d.ts",
34
+ "import": "./dist/index.js",
35
+ "require": "./dist/index.umd.cjs",
36
+ "default": "./dist/index.umd.cjs"
43
37
  }
44
38
  },
45
39
  "dependencies": {
46
- "@tma.js/parsing": "0.0.2"
40
+ "@tma.js/parsing": "0.0.3"
47
41
  },
48
42
  "devDependencies": {
49
43
  "tsconfig": "0.0.2",
50
44
  "eslint-config-custom": "0.1.0",
51
- "jest-config-custom": "0.1.0"
45
+ "jest-config-custom": "0.1.0",
46
+ "build-utils": "0.0.0"
52
47
  },
53
48
  "publishConfig": {
54
49
  "access": "public"
@@ -56,6 +51,6 @@
56
51
  "scripts": {
57
52
  "test": "jest",
58
53
  "lint": "eslint -c .eslintrc.cjs src/**/* __tests__/**/*",
59
- "build": "rimraf dist && rollup --config rollup.config.js"
54
+ "build": "vite build"
60
55
  }
61
56
  }
@@ -1,2 +0,0 @@
1
- this["@tma"]=this["@tma"]||{},this["@tma"]["js/init-data"]=function(t){"use strict";class e{parser;isOptional;getDefault;isEmpty;static create(t){return new e(t,!1,void 0)}constructor(t,e,r,n=(t=>void 0===t)){this.parser=t,this.isOptional=e,this.getDefault=r,this.isEmpty=n}parse(t){return this.isOptional&&this.isEmpty(t)?this.getDefault?this.getDefault():void 0:this.parser(t)}optional(t){return this.isOptional=!0,t&&(this.isEmpty=t),this}default(t){return this.getDefault=t,this}}function r(t){return()=>e.create(t)}function n(t){return r((e=>{if(typeof e!==t)throw new TypeError(`Unable to parse value ${JSON.stringify(e)} as ${t}.`);return e}))}function o(t,e){const r={};for(const n in t){const o=t[n];if(!o)continue;let i,a,s,p;if("type"in o){const{from:t=n,type:e}=o;i=t,a="function"==typeof e?e:e.parse.bind(e),s="required"in o&&o.required}else i=n,s=!1,a="function"==typeof o?o:o.parse.bind(o);try{p=a(e(i))}catch(t){throw new Error(`Unable to parse field "${i}"`,{cause:t})}(void 0!==p||s)&&(r[n]=p)}return r}const i=n("string"),a=n("number"),s=n("boolean"),p=r((t=>{const e=i().parse(t);if(e){const t=Number(e),r=new Date(t.toString()===e?1e3*t:e);if("Invalid Date"!==r.toString())return r}throw new TypeError(`Unable to parse value "${t}" as Date.`)}));function u(t){return e.create((e=>{let r=e;if("string"==typeof r)try{r=JSON.parse(r)}catch(t){throw new TypeError("Value is not JSON object converted to string.")}if("object"!=typeof r||null===r||Array.isArray(r))throw new TypeError("Value is not JSON object.");return o(t,(t=>r[t]))}))}function l(t,e){return{from:e,type:t}}const c=u({firstName:l(i(),"first_name"),id:a(),isBot:l(s().optional(),"is_bot"),isPremium:l(s().optional(),"is_premium"),lastName:l(i().optional(),"last_name"),languageCode:l(i().optional(),"language_code"),photoUrl:l(i().optional(),"photo_url"),username:i().optional()}),f=(h={authDate:l(p(),"auth_date"),hash:i(),user:c.optional(),receiver:c.optional(),chat:u({id:a(),type:i(),title:i(),photoUrl:l(i().optional(),"photo_url"),username:i().optional()}).optional(),canSendAfter:l(p().optional(),"can_send_after"),queryId:l(i().optional(),"query_id"),startParam:l(i().optional(),"start_param")},e.create((t=>{if("string"!=typeof t&&!(t instanceof URLSearchParams))throw new TypeError("Value has not processable type.");const e="string"==typeof t?new URLSearchParams(t):t;return o(h,(t=>{const r=e.get(t);return null===r?void 0:r}))})));var h;return t.initData=f,t}({});
2
- //# sourceMappingURL=browser.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"browser.js","sources":["../../../parsing/dist/lib/index.mjs","../../src/parsing.ts"],"sourcesContent":["import{toRGB as t}from\"@tma.js/colors\";class r{parser;isOptional;getDefault;isEmpty;static create(t){return new r(t,!1,void 0)}constructor(t,r,e,n=(t=>void 0===t)){this.parser=t,this.isOptional=r,this.getDefault=e,this.isEmpty=n}parse(t){return this.isOptional&&this.isEmpty(t)?this.getDefault?this.getDefault():void 0:this.parser(t)}optional(t){return this.isOptional=!0,t&&(this.isEmpty=t),this}default(t){return this.getDefault=t,this}}function e(t){const r=\"function\"==typeof t?t:t.parse.bind(t);return t=>function(t){if(Array.isArray(t))return t;if(\"string\"==typeof t)try{const r=JSON.parse(t);if(Array.isArray(r))return r}catch(t){}throw new Error(`Passed value does not satisfy any of known formats: ${JSON.stringify(t)}`)}(t).map(r)}class n extends r{constructor(t,r,n,o=(t=>void 0===t)){super(e(t),r,n,o)}of(t){return this.parser=e(t),this}}function o(t){return()=>r.create(t)}function s(t){return o((r=>{if(typeof r!==t)throw new TypeError(`Unable to parse value ${JSON.stringify(r)} as ${t}.`);return r}))}function i(t,r){const e={};for(const n in t){const o=t[n];if(!o)continue;let s,i,a,u;if(\"type\"in o){const{from:t=n,type:r}=o;s=t,i=\"function\"==typeof r?r:r.parse.bind(r),a=\"required\"in o&&o.required}else s=n,a=!1,i=\"function\"==typeof o?o:o.parse.bind(o);try{u=i(r(s))}catch(t){throw new Error(`Unable to parse field \"${s}\"`,{cause:t})}(void 0!==u||a)&&(e[n]=u)}return e}const a=s(\"string\"),u=s(\"number\"),c=s(\"boolean\"),f=o((t=>{const r=a().parse(t);if(r){const t=Number(r),e=new Date(t.toString()===r?1e3*t:r);if(\"Invalid Date\"!==e.toString())return e}throw new TypeError(`Unable to parse value \"${t}\" as Date.`)})),p=o((r=>{const e=a().parse(r);try{return t(e)}catch(t){throw new TypeError(`Unable to parse value \"${e}\" as RGB.`,{cause:t})}}));function l(t){return r.create((r=>{let e=r;if(\"string\"==typeof e)try{e=JSON.parse(e)}catch(t){throw new TypeError(\"Value is not JSON object converted to string.\")}if(\"object\"!=typeof e||null===e||Array.isArray(e))throw new TypeError(\"Value is not JSON object.\");return i(t,(t=>e[t]))}))}function y(t){return r.create((r=>{if(\"string\"!=typeof r&&!(r instanceof URLSearchParams))throw new TypeError(\"Value has not processable type.\");const e=\"string\"==typeof r?new URLSearchParams(r):r;return i(t,(t=>{const r=e.get(t);return null===r?void 0:r}))}))}function h(){return new n((t=>t),!1,void 0)}export{n as ArrayValueParser,r as ValueParser,h as array,c as boolean,o as createParserGenerator,f as date,l as json,u as number,p as rgb,y as searchParams,a as string};\n//# sourceMappingURL=index.mjs.map\n","import {\n searchParams,\n json,\n string,\n number,\n boolean,\n date,\n type AnyParser,\n} from '@tma.js/parsing';\n\nimport type { InitData, User } from './types.js';\n\nfunction field<P extends AnyParser<any>>(parser: P, from?: string) {\n return {\n from,\n type: parser,\n };\n}\n\nconst user = json<User>({\n firstName: field(string(), 'first_name'),\n id: number(),\n isBot: field(boolean().optional(), 'is_bot'),\n isPremium: field(boolean().optional(), 'is_premium'),\n lastName: field(string().optional(), 'last_name'),\n languageCode: field(string().optional(), 'language_code'),\n photoUrl: field(string().optional(), 'photo_url'),\n username: string().optional(),\n});\n\n/**\n * Parser used to parse init data, presented as search params.\n */\nexport const initData = searchParams<InitData>({\n authDate: field(date(), 'auth_date'),\n hash: string(),\n user: user.optional(),\n receiver: user.optional(),\n chat: json<InitData['chat']>({\n id: number(),\n type: string(),\n title: string(),\n photoUrl: field(string().optional(), 'photo_url'),\n username: string().optional(),\n }).optional(),\n canSendAfter: field(date().optional(), 'can_send_after'),\n queryId: field(string().optional(), 'query_id'),\n startParam: field(string().optional(), 'start_param'),\n});\n"],"names":["r","parser","isOptional","getDefault","isEmpty","static","t","constructor","e","n","this","parse","optional","default","o","create","s","TypeError","JSON","stringify","i","a","u","from","type","bind","required","Error","cause","c","f","Number","Date","toString","l","Array","isArray","field","user","json","firstName","string","id","number","isBot","boolean","isPremium","lastName","languageCode","photoUrl","username","initData","authDate","date","hash","receiver","chat","title","canSendAfter","queryId","startParam","URLSearchParams","get"],"mappings":"oFAAuC,MAAMA,EAAEC,OAAOC,WAAWC,WAAWC,QAAQC,cAAcC,GAAG,OAAO,IAAIN,EAAEM,GAAE,OAAG,EAAO,CAACC,YAAYD,EAAEN,EAAEQ,EAAEC,EAAG,CAAAH,QAAG,IAASA,IAAII,KAAKT,OAAOK,EAAEI,KAAKR,WAAWF,EAAEU,KAAKP,WAAWK,EAAEE,KAAKN,QAAQK,CAAC,CAACE,MAAML,GAAG,OAAOI,KAAKR,YAAYQ,KAAKN,QAAQE,GAAGI,KAAKP,WAAWO,KAAKP,kBAAa,EAAOO,KAAKT,OAAOK,EAAE,CAACM,SAASN,GAAG,OAAOI,KAAKR,YAAW,EAAGI,IAAII,KAAKN,QAAQE,GAAGI,IAAI,CAACG,QAAQP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MAAMN,EAAEQ,EAAEsD,IAAIxD,GAAG,OAAO,OAAON,OAAE,EAAOA,CAAE,GAAG,KAAlQ,IAAWM"}
@@ -1,2 +0,0 @@
1
- "use strict";var t=require("@tma.js/parsing");function a(t,a){return{from:a,type:t}}const o=t.json({firstName:a(t.string(),"first_name"),id:t.number(),isBot:a(t.boolean().optional(),"is_bot"),isPremium:a(t.boolean().optional(),"is_premium"),lastName:a(t.string().optional(),"last_name"),languageCode:a(t.string().optional(),"language_code"),photoUrl:a(t.string().optional(),"photo_url"),username:t.string().optional()}),n=t.searchParams({authDate:a(t.date(),"auth_date"),hash:t.string(),user:o.optional(),receiver:o.optional(),chat:t.json({id:t.number(),type:t.string(),title:t.string(),photoUrl:a(t.string().optional(),"photo_url"),username:t.string().optional()}).optional(),canSendAfter:a(t.date().optional(),"can_send_after"),queryId:a(t.string().optional(),"query_id"),startParam:a(t.string().optional(),"start_param")});exports.initData=n;
2
- //# sourceMappingURL=index.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs","sources":["../../src/parsing.ts"],"sourcesContent":["import {\n searchParams,\n json,\n string,\n number,\n boolean,\n date,\n type AnyParser,\n} from '@tma.js/parsing';\n\nimport type { InitData, User } from './types.js';\n\nfunction field<P extends AnyParser<any>>(parser: P, from?: string) {\n return {\n from,\n type: parser,\n };\n}\n\nconst user = json<User>({\n firstName: field(string(), 'first_name'),\n id: number(),\n isBot: field(boolean().optional(), 'is_bot'),\n isPremium: field(boolean().optional(), 'is_premium'),\n lastName: field(string().optional(), 'last_name'),\n languageCode: field(string().optional(), 'language_code'),\n photoUrl: field(string().optional(), 'photo_url'),\n username: string().optional(),\n});\n\n/**\n * Parser used to parse init data, presented as search params.\n */\nexport const initData = searchParams<InitData>({\n authDate: field(date(), 'auth_date'),\n hash: string(),\n user: user.optional(),\n receiver: user.optional(),\n chat: json<InitData['chat']>({\n id: number(),\n type: string(),\n title: string(),\n photoUrl: field(string().optional(), 'photo_url'),\n username: string().optional(),\n }).optional(),\n canSendAfter: field(date().optional(), 'can_send_after'),\n queryId: field(string().optional(), 'query_id'),\n startParam: field(string().optional(), 'start_param'),\n});\n"],"names":["field","parser","from","type","user","json","firstName","string","id","number","isBot","boolean","optional","isPremium","lastName","languageCode","photoUrl","username","initData","searchParams","authDate","date","hash","receiver","chat","title","canSendAfter","queryId","startParam"],"mappings":"8CAYA,SAASA,EAAgCC,EAAWC,GAClD,MAAO,CACLA,OACAC,KAAMF,EAEV,CAEA,MAAMG,EAAOC,EAAAA,KAAW,CACtBC,UAAWN,EAAMO,WAAU,cAC3BC,GAAIC,EAAAA,SACJC,MAAOV,EAAMW,EAAAA,UAAUC,WAAY,UACnCC,UAAWb,EAAMW,EAAAA,UAAUC,WAAY,cACvCE,SAAUd,EAAMO,EAAAA,SAASK,WAAY,aACrCG,aAAcf,EAAMO,EAAAA,SAASK,WAAY,iBACzCI,SAAUhB,EAAMO,EAAAA,SAASK,WAAY,aACrCK,SAAUV,EAAAA,SAASK,aAMRM,EAAWC,EAAAA,aAAuB,CAC7CC,SAAUpB,EAAMqB,SAAQ,aACxBC,KAAMf,EAAAA,SACNH,KAAMA,EAAKQ,WACXW,SAAUnB,EAAKQ,WACfY,KAAMnB,EAAAA,KAAuB,CAC3BG,GAAIC,EAAAA,SACJN,KAAMI,EAAAA,SACNkB,MAAOlB,EAAAA,SACPS,SAAUhB,EAAMO,EAAAA,SAASK,WAAY,aACrCK,SAAUV,EAAAA,SAASK,aAClBA,WACHc,aAAc1B,EAAMqB,EAAAA,OAAOT,WAAY,kBACvCe,QAAS3B,EAAMO,EAAAA,SAASK,WAAY,YACpCgB,WAAY5B,EAAMO,EAAAA,SAASK,WAAY"}
@@ -1,2 +0,0 @@
1
- import{json as o,string as t,number as a,boolean as e,searchParams as i,date as n}from"@tma.js/parsing";function r(o,t){return{from:t,type:o}}const p=o({firstName:r(t(),"first_name"),id:a(),isBot:r(e().optional(),"is_bot"),isPremium:r(e().optional(),"is_premium"),lastName:r(t().optional(),"last_name"),languageCode:r(t().optional(),"language_code"),photoUrl:r(t().optional(),"photo_url"),username:t().optional()}),l=i({authDate:r(n(),"auth_date"),hash:t(),user:p.optional(),receiver:p.optional(),chat:o({id:a(),type:t(),title:t(),photoUrl:r(t().optional(),"photo_url"),username:t().optional()}).optional(),canSendAfter:r(n().optional(),"can_send_after"),queryId:r(t().optional(),"query_id"),startParam:r(t().optional(),"start_param")});export{l as initData};
2
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.mjs","sources":["../../src/parsing.ts"],"sourcesContent":["import {\n searchParams,\n json,\n string,\n number,\n boolean,\n date,\n type AnyParser,\n} from '@tma.js/parsing';\n\nimport type { InitData, User } from './types.js';\n\nfunction field<P extends AnyParser<any>>(parser: P, from?: string) {\n return {\n from,\n type: parser,\n };\n}\n\nconst user = json<User>({\n firstName: field(string(), 'first_name'),\n id: number(),\n isBot: field(boolean().optional(), 'is_bot'),\n isPremium: field(boolean().optional(), 'is_premium'),\n lastName: field(string().optional(), 'last_name'),\n languageCode: field(string().optional(), 'language_code'),\n photoUrl: field(string().optional(), 'photo_url'),\n username: string().optional(),\n});\n\n/**\n * Parser used to parse init data, presented as search params.\n */\nexport const initData = searchParams<InitData>({\n authDate: field(date(), 'auth_date'),\n hash: string(),\n user: user.optional(),\n receiver: user.optional(),\n chat: json<InitData['chat']>({\n id: number(),\n type: string(),\n title: string(),\n photoUrl: field(string().optional(), 'photo_url'),\n username: string().optional(),\n }).optional(),\n canSendAfter: field(date().optional(), 'can_send_after'),\n queryId: field(string().optional(), 'query_id'),\n startParam: field(string().optional(), 'start_param'),\n});\n"],"names":["field","parser","from","type","user","json","firstName","string","id","number","isBot","boolean","optional","isPremium","lastName","languageCode","photoUrl","username","initData","searchParams","authDate","date","hash","receiver","chat","title","canSendAfter","queryId","startParam"],"mappings":"wGAYA,SAASA,EAAgCC,EAAWC,GAClD,MAAO,CACLA,OACAC,KAAMF,EAEV,CAEA,MAAMG,EAAOC,EAAW,CACtBC,UAAWN,EAAMO,IAAU,cAC3BC,GAAIC,IACJC,MAAOV,EAAMW,IAAUC,WAAY,UACnCC,UAAWb,EAAMW,IAAUC,WAAY,cACvCE,SAAUd,EAAMO,IAASK,WAAY,aACrCG,aAAcf,EAAMO,IAASK,WAAY,iBACzCI,SAAUhB,EAAMO,IAASK,WAAY,aACrCK,SAAUV,IAASK,aAMRM,EAAWC,EAAuB,CAC7CC,SAAUpB,EAAMqB,IAAQ,aACxBC,KAAMf,IACNH,KAAMA,EAAKQ,WACXW,SAAUnB,EAAKQ,WACfY,KAAMnB,EAAuB,CAC3BG,GAAIC,IACJN,KAAMI,IACNkB,MAAOlB,IACPS,SAAUhB,EAAMO,IAASK,WAAY,aACrCK,SAAUV,IAASK,aAClBA,WACHc,aAAc1B,EAAMqB,IAAOT,WAAY,kBACvCe,QAAS3B,EAAMO,IAASK,WAAY,YACpCgB,WAAY5B,EAAMO,IAASK,WAAY"}
File without changes
File without changes
File without changes