@mtcute/dispatcher 0.1.0 → 0.1.1
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/cjs/state/storage.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../../../src/state/storage.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../../../src/state/storage.ts"],"names":[],"mappings":";;;AAsFA,SAAgB,mBAAmB,CAAC,OAAgB;IAChD,OAAO,CACH,OAAO,OAAO,KAAK,QAAQ;QAC3B,OAAO,KAAK,IAAI;QAChB,UAAU,IAAI,OAAO;QACrB,UAAU,IAAI,OAAO;QACrB,aAAa,IAAI,OAAO;QACxB,iBAAiB,IAAI,OAAO;QAC5B,iBAAiB,IAAI,OAAO;QAC5B,oBAAoB,IAAI,OAAO;QAC/B,cAAc,IAAI,OAAO;QACzB,gBAAgB,IAAI,OAAO,CAC9B,CAAA;AACL,CAAC;AAbD,kDAaC","sourcesContent":["import { MaybeAsync } from '@mtcute/client'\n\n// ⚠️ Important: when modifying the below interface, also update it\n// in packages/core/src/storage/storage.test-utils.ts\n\n/**\n * Interface for FSM storage for the dispatcher.\n *\n * All of the officially supported storages already implement\n * this interface, so you can just re-use it.\n *\n * Current scene is a special case of a `string` state,\n * Most of the time you can just store it the same way\n * as normal state, prefixing with something like `$current_state_`\n * (scene name can't start with `$`).\n * Alternatively, you can store them as simple strings\n */\nexport interface IStateStorage {\n /**\n * Retrieve state from the storage\n *\n * @param key Key of the state, as defined by {@link StateKeyDelegate}\n */\n getState(key: string): MaybeAsync<unknown>\n\n /**\n * Save state to the storage\n *\n * @param key Key of the state, as defined by {@link StateKeyDelegate}\n * @param state Object representing the state\n * @param ttl TTL for the state, in seconds\n */\n setState(key: string, state: unknown, ttl?: number): MaybeAsync<void>\n\n /**\n * Delete state from the storage\n *\n * @param key Key of the state, as defined by {@link StateKeyDelegate}\n */\n deleteState(key: string): MaybeAsync<void>\n\n /**\n * Retrieve the current scene UID from the storage\n *\n * @param key Key of the state, as defined by {@link StateKeyDelegate}\n */\n getCurrentScene(key: string): MaybeAsync<string | null>\n\n /**\n * Change current scene's UID from the storage\n *\n * @param key Key of the state, as defined by {@link StateKeyDelegate}\n * @param scene New scene\n * @param ttl TTL for the scene, in seconds\n */\n setCurrentScene(key: string, scene: string, ttl?: number): MaybeAsync<void>\n\n /**\n * Delete current scene from the storage, effectively \"exiting\" to root.\n *\n * @param key Key of the state, as defined by {@link StateKeyDelegate}\n */\n deleteCurrentScene(key: string): MaybeAsync<void>\n\n /**\n * Get information about a rate limit.\n *\n * It is recommended that you use sliding window or leaky bucket\n * to implement rate limiting ([learn more](https://konghq.com/blog/how-to-design-a-scalable-rate-limiting-algorithm/)),\n *\n * @param key Key of the rate limit\n * @param limit Maximum number of requests in `window`\n * @param window Window size in seconds\n * @returns Tuple containing the number of remaining and\n * unix time in ms when the user can try again\n */\n getRateLimit(key: string, limit: number, window: number): MaybeAsync<[number, number]>\n\n /**\n * Reset a rate limit.\n *\n * @param key Key of the rate limit\n */\n resetRateLimit(key: string): MaybeAsync<void>\n}\n\nexport function isCompatibleStorage(storage: unknown): storage is IStateStorage {\n return (\n typeof storage === 'object' &&\n storage !== null &&\n 'getState' in storage &&\n 'setState' in storage &&\n 'deleteState' in storage &&\n 'getCurrentScene' in storage &&\n 'setCurrentScene' in storage &&\n 'deleteCurrentScene' in storage &&\n 'getRateLimit' in storage &&\n 'resetRateLimit' in storage\n )\n}\n"]}
|
package/esm/state/storage.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../../../src/state/storage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../../../src/state/storage.ts"],"names":[],"mappings":"AAsFA,MAAM,UAAU,mBAAmB,CAAC,OAAgB;IAChD,OAAO,CACH,OAAO,OAAO,KAAK,QAAQ;QAC3B,OAAO,KAAK,IAAI;QAChB,UAAU,IAAI,OAAO;QACrB,UAAU,IAAI,OAAO;QACrB,aAAa,IAAI,OAAO;QACxB,iBAAiB,IAAI,OAAO;QAC5B,iBAAiB,IAAI,OAAO;QAC5B,oBAAoB,IAAI,OAAO;QAC/B,cAAc,IAAI,OAAO;QACzB,gBAAgB,IAAI,OAAO,CAC9B,CAAA;AACL,CAAC","sourcesContent":["import { MaybeAsync } from '@mtcute/client'\n\n// ⚠️ Important: when modifying the below interface, also update it\n// in packages/core/src/storage/storage.test-utils.ts\n\n/**\n * Interface for FSM storage for the dispatcher.\n *\n * All of the officially supported storages already implement\n * this interface, so you can just re-use it.\n *\n * Current scene is a special case of a `string` state,\n * Most of the time you can just store it the same way\n * as normal state, prefixing with something like `$current_state_`\n * (scene name can't start with `$`).\n * Alternatively, you can store them as simple strings\n */\nexport interface IStateStorage {\n /**\n * Retrieve state from the storage\n *\n * @param key Key of the state, as defined by {@link StateKeyDelegate}\n */\n getState(key: string): MaybeAsync<unknown>\n\n /**\n * Save state to the storage\n *\n * @param key Key of the state, as defined by {@link StateKeyDelegate}\n * @param state Object representing the state\n * @param ttl TTL for the state, in seconds\n */\n setState(key: string, state: unknown, ttl?: number): MaybeAsync<void>\n\n /**\n * Delete state from the storage\n *\n * @param key Key of the state, as defined by {@link StateKeyDelegate}\n */\n deleteState(key: string): MaybeAsync<void>\n\n /**\n * Retrieve the current scene UID from the storage\n *\n * @param key Key of the state, as defined by {@link StateKeyDelegate}\n */\n getCurrentScene(key: string): MaybeAsync<string | null>\n\n /**\n * Change current scene's UID from the storage\n *\n * @param key Key of the state, as defined by {@link StateKeyDelegate}\n * @param scene New scene\n * @param ttl TTL for the scene, in seconds\n */\n setCurrentScene(key: string, scene: string, ttl?: number): MaybeAsync<void>\n\n /**\n * Delete current scene from the storage, effectively \"exiting\" to root.\n *\n * @param key Key of the state, as defined by {@link StateKeyDelegate}\n */\n deleteCurrentScene(key: string): MaybeAsync<void>\n\n /**\n * Get information about a rate limit.\n *\n * It is recommended that you use sliding window or leaky bucket\n * to implement rate limiting ([learn more](https://konghq.com/blog/how-to-design-a-scalable-rate-limiting-algorithm/)),\n *\n * @param key Key of the rate limit\n * @param limit Maximum number of requests in `window`\n * @param window Window size in seconds\n * @returns Tuple containing the number of remaining and\n * unix time in ms when the user can try again\n */\n getRateLimit(key: string, limit: number, window: number): MaybeAsync<[number, number]>\n\n /**\n * Reset a rate limit.\n *\n * @param key Key of the rate limit\n */\n resetRateLimit(key: string): MaybeAsync<void>\n}\n\nexport function isCompatibleStorage(storage: unknown): storage is IStateStorage {\n return (\n typeof storage === 'object' &&\n storage !== null &&\n 'getState' in storage &&\n 'setState' in storage &&\n 'deleteState' in storage &&\n 'getCurrentScene' in storage &&\n 'setCurrentScene' in storage &&\n 'deleteCurrentScene' in storage &&\n 'getRateLimit' in storage &&\n 'resetRateLimit' in storage\n )\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mtcute/dispatcher",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Updates dispatcher and bot framework for @mtcute/client",
|
|
5
5
|
"author": "Alina Sireneva <alina@tei.su>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"type": "module",
|
|
9
9
|
"scripts": {},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@mtcute/client": "^0.1.
|
|
11
|
+
"@mtcute/client": "^0.1.1",
|
|
12
12
|
"events": "3.2.0"
|
|
13
13
|
},
|
|
14
14
|
"module": "esm/index.js",
|