bm-webapp-sdk 0.1.1 → 0.1.2

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.d.ts CHANGED
@@ -1,8 +1,63 @@
1
- import WebAppHandler from './WebAppHandler';
2
- import { TelegramWebApps } from 'telegram-webapps-types';
1
+ interface HandlerOptions {
2
+ sessionHash?: string;
3
+ scenarioCode?: string;
4
+ initVariables?: TData;
5
+ botTokenParamName?: string;
6
+ userApiToken?: string;
7
+ retryDelayOnTimeout?: number;
8
+ requestTimeout?: number;
9
+ responseVar?: string;
10
+ apiEndpoint?: string;
11
+ }
12
+ type TData = {
13
+ [key: string]: any;
14
+ };
15
+ interface INodeEventsDecl {
16
+ inbox: boolean;
17
+ outbox: boolean;
18
+ anyInbox: boolean;
19
+ dialogClosed: boolean;
20
+ invoicePaid: boolean;
21
+ externalRequest: boolean;
22
+ buttons: boolean;
23
+ customEvents: boolean;
24
+ }
25
+ interface INode {
26
+ id: number;
27
+ title: string;
28
+ typeName: "basic" | "event" | "eventListener" | "condition" | "conditionBranch";
29
+ waitingForEvents?: INodeEventsDecl;
30
+ }
31
+ type TScenarioSessionStatus = "active" | "stopped" | "ended" | "unknownError" | "tunnelDisabled" | "expired" | "userDisabled" | "stepDeleted" | "transitionsLimit" | "parentStopped";
32
+ interface ScenarioSession {
33
+ id: number;
34
+ hash: string;
35
+ statusName: TScenarioSessionStatus;
36
+ ref: string | null;
37
+ variables: TData;
38
+ isTransitioning: boolean;
39
+ currentNode: INode | null;
40
+ }
41
+ export default class WebAppHandler {
42
+ readonly options: HandlerOptions;
43
+ data?: ScenarioSession;
44
+ private currentRequest?;
45
+ constructor(options: HandlerOptions);
46
+ isActive(): boolean;
47
+ init(): Promise<WebAppHandler>;
48
+ refreshData(): Promise<WebAppHandler>;
49
+ request(code: string, params?: TData, async?: boolean): Promise<WebAppHandler>;
50
+ abort(): void;
51
+ isTelegramInitAvailable(): boolean;
52
+ protected initNewSession(): Promise<WebAppHandler>;
53
+ protected makeRequest(method: string, path: string, json?: TData, signal?: AbortSignal): Promise<any>;
54
+ private waitUntilSessionFinishesTransition;
55
+ }
56
+
3
57
  export { WebAppHandler };
4
58
  declare global {
5
59
  interface Window {
6
- Telegram: TelegramWebApps.SDK | undefined;
60
+ Telegram: any;
7
61
  }
8
62
  }
63
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bm-webapp-sdk",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "",
5
5
  "main": "dist/bundle.js",
6
6
  "types": "dist/index.d.ts",
@@ -22,5 +22,8 @@
22
22
  "typescript": "^5.3.3",
23
23
  "webpack-cli": "^5.1.4",
24
24
  "webpack-dev-server": "^5.0.2"
25
+ },
26
+ "dependencies": {
27
+ "typescript-declaration-webpack-plugin": "^0.3.0"
25
28
  }
26
29
  }
@@ -1,56 +0,0 @@
1
- interface HandlerOptions {
2
- sessionHash?: string;
3
- scenarioCode?: string;
4
- initVariables?: TData;
5
- botTokenParamName?: string;
6
- userApiToken?: string;
7
- retryDelayOnTimeout?: number;
8
- requestTimeout?: number;
9
- responseVar?: string;
10
- apiEndpoint?: string;
11
- }
12
- type TData = {
13
- [key: string]: any;
14
- };
15
- interface INodeEventsDecl {
16
- inbox: boolean;
17
- outbox: boolean;
18
- anyInbox: boolean;
19
- dialogClosed: boolean;
20
- invoicePaid: boolean;
21
- externalRequest: boolean;
22
- buttons: boolean;
23
- customEvents: boolean;
24
- }
25
- interface INode {
26
- id: number;
27
- title: string;
28
- typeName: "basic" | "event" | "eventListener" | "condition" | "conditionBranch";
29
- waitingForEvents?: INodeEventsDecl;
30
- }
31
- type TScenarioSessionStatus = "active" | "stopped" | "ended" | "unknownError" | "tunnelDisabled" | "expired" | "userDisabled" | "stepDeleted" | "transitionsLimit" | "parentStopped";
32
- interface ScenarioSession {
33
- id: number;
34
- hash: string;
35
- statusName: TScenarioSessionStatus;
36
- ref: string | null;
37
- variables: TData;
38
- isTransitioning: boolean;
39
- currentNode: INode | null;
40
- }
41
- export default class WebAppHandler {
42
- readonly options: HandlerOptions;
43
- data?: ScenarioSession;
44
- private currentRequest?;
45
- constructor(options: HandlerOptions);
46
- isActive(): boolean;
47
- init(): Promise<WebAppHandler>;
48
- refreshData(): Promise<WebAppHandler>;
49
- request(code: string, params?: TData, async?: boolean): Promise<WebAppHandler>;
50
- abort(): void;
51
- isTelegramInitAvailable(): boolean;
52
- protected initNewSession(): Promise<WebAppHandler>;
53
- protected makeRequest(method: string, path: string, json?: TData, signal?: AbortSignal): Promise<any>;
54
- private waitUntilSessionFinishesTransition;
55
- }
56
- export {};