@kapaai/support-form-deflector 0.9.7 → 0.9.9

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.
@@ -1 +1 @@
1
- {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/state.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAqB/B,MAAM,MAAM,cAAc,GACtB,SAAS,GACT,gBAAgB,GAChB,OAAO,GACP,eAAe,GACf,WAAW,GACX,SAAS,GACT,SAAS,CAAC;AACd,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,cAAc,CAAC;IACtB,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,MAAM,CAAC,EAAE;QACP,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;CACH,CAAC;AAQF,KAAK,YAAY,GAAG;IAClB,IAAI,EACA,SAAS,GACT,gBAAgB,GAChB,SAAS,GACT,OAAO,GACP,WAAW,GACX,SAAS,CAAC;IACd,IAAI,EAAE,GAAG,CAAC;CACX,CAAC;AAkEF,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC;IACvC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CA2mBA,CAAC;AAEF,eAAO,MAAM,YAAY;WAxnBZ,WAAW;cACR,MAAM,QAAQ,CAAC,YAAY,CAAC;CA6nB3C,CAAC"}
1
+ {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/state.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAkB/B,MAAM,MAAM,cAAc,GACtB,SAAS,GACT,gBAAgB,GAChB,OAAO,GACP,eAAe,GACf,WAAW,GACX,SAAS,GACT,SAAS,CAAC;AACd,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,cAAc,CAAC;IACtB,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,MAAM,CAAC,EAAE;QACP,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;CACH,CAAC;AAQF,KAAK,YAAY,GAAG;IAClB,IAAI,EACA,SAAS,GACT,gBAAgB,GAChB,SAAS,GACT,OAAO,GACP,WAAW,GACX,SAAS,CAAC;IACd,IAAI,EAAE,GAAG,CAAC;CACX,CAAC;AAkEF,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC;IACvC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CA2mBA,CAAC;AAEF,eAAO,MAAM,YAAY;WAxnBZ,WAAW;cACR,MAAM,QAAQ,CAAC,YAAY,CAAC;CA6nB3C,CAAC"}
@@ -1,38 +1,33 @@
1
1
  import { Logger } from "./logger";
2
- export declare const LOCALSTORAGE_KEY = "kapa-support-form-deflector-state";
3
- type StoreDeflectorStateProps = {
4
- query: string;
5
- threadId: string;
6
- logger: Logger;
7
- };
8
- /**
9
- * Saves the provided query and threadId to local storage along with a timestamp.
10
- *
11
- * @param {Object} params - The parameters for the function.
12
- * @param {string} params.query - The query string to be saved.
13
- * @param {string} params.threadId - The thread ID to be saved.
14
- * @param {Object} params.logger - The logger object for logging debug information.
15
- *
16
- * @returns {void}
17
- */
18
- export declare function storeDeflectorState({ query, threadId, logger, }: StoreDeflectorStateProps): void;
19
- type CachedDeflectorStateProps = {
20
- query: string;
21
- logger: Logger;
22
- toggleDeflectionStatus: (threadId: string, isDeflected: boolean) => void;
23
- };
24
- /**
25
- * Hydrates the state from local storage if it matches the given query and is within the valid time window.
26
- * If the data is invalid or does not match the query, it returns false. If the data is valid and matches the query,
27
- * it toggles the deflection status and returns true.
28
- *
29
- * @param {Object} props - The properties for the function.
30
- * @param {string} props.query - The query to match against the stored data.
31
- * @param {Object} props.logger - The logger object to log debug information.
32
- * @param {Function} props.toggleDeflectionStatus - The function to toggle the deflection status.
33
- *
34
- * @returns {boolean} - Whether the cached deflector state was used.
35
- */
36
- export declare function shouldUseCachedDeflectorState({ query, logger, toggleDeflectionStatus, }: CachedDeflectorStateProps): boolean;
37
- export {};
2
+ export declare class QueryCache {
3
+ private key;
4
+ private logger;
5
+ private toggleDeflectionStatus;
6
+ private readonly TIME_WINDOW;
7
+ /**
8
+ * Creates an instance of QueryCache.
9
+ * @param {Object} params - The parameters for the cache.
10
+ * @param {string} params.key - The local storage key.
11
+ * @param {Logger} params.logger - The logger instance.
12
+ * @param {Function} params.toggleDeflectionStatus - Function to toggle the deflection status.
13
+ */
14
+ constructor({ key, logger, toggleDeflectionStatus, }: {
15
+ key: string;
16
+ logger: Logger;
17
+ toggleDeflectionStatus: (threadId: string, isDeflected: boolean) => void;
18
+ });
19
+ /**
20
+ * Stores the deflector state in local storage.
21
+ * @param {Object} params - The parameters for storing state.
22
+ * @param {string} params.threadId - The thread ID to be stored.
23
+ */
24
+ storeDeflectorState({ threadId }: {
25
+ threadId: string;
26
+ }): void;
27
+ /**
28
+ * Checks if the cached deflector state should be used.
29
+ * @returns {boolean} - Whether the cached state is valid and should be used.
30
+ */
31
+ shouldUseCachedDeflectorState(): boolean;
32
+ }
38
33
  //# sourceMappingURL=cached-deflector-state.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cached-deflector-state.d.ts","sourceRoot":"","sources":["../../../src/utils/cached-deflector-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,eAAO,MAAM,gBAAgB,sCAAsC,CAAC;AAQpE,KAAK,wBAAwB,GAAG;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,KAAK,EACL,QAAQ,EACR,MAAM,GACP,EAAE,wBAAwB,GAAG,IAAI,CAUjC;AAED,KAAK,yBAAyB,GAAG;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,sBAAsB,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,KAAK,IAAI,CAAC;CAC1E,CAAC;AAMF;;;;;;;;;;;GAWG;AACH,wBAAgB,6BAA6B,CAAC,EAC5C,KAAK,EACL,MAAM,EACN,sBAAsB,GACvB,EAAE,yBAAyB,GAAG,OAAO,CA8BrC"}
1
+ {"version":3,"file":"cached-deflector-state.d.ts","sourceRoot":"","sources":["../../../src/utils/cached-deflector-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,qBAAa,UAAU;IACrB,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,sBAAsB,CAGpB;IACV,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAyB;IAErD;;;;;;OAMG;gBACS,EACV,GAAG,EACH,MAAM,EACN,sBAAsB,GACvB,EAAE;QACD,GAAG,EAAE,MAAM,CAAC;QACZ,MAAM,EAAE,MAAM,CAAC;QACf,sBAAsB,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,KAAK,IAAI,CAAC;KAC1E;IAMD;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,QAAQ,EAAE,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAW7D;;;OAGG;IACH,6BAA6B,IAAI,OAAO;CAgCzC"}
@@ -1 +1 @@
1
- {"version":3,"file":"toggle-button-disabled.d.ts","sourceRoot":"","sources":["../../../src/utils/toggle-button-disabled.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,oBAAoB,aACrB,MAAM,GAAG,SAAS,YAClB,OAAO,SA8BlB,CAAC"}
1
+ {"version":3,"file":"toggle-button-disabled.d.ts","sourceRoot":"","sources":["../../../src/utils/toggle-button-disabled.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,oBAAoB,aACrB,MAAM,GAAG,SAAS,YAClB,OAAO,SAgClB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kapaai/support-form-deflector",
3
- "version": "0.9.7",
3
+ "version": "0.9.9",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/esm/index.js",
6
6
  "types": "./dist/esm/index.d.ts",
@@ -76,8 +76,8 @@
76
76
  "@types/react-syntax-highlighter": "^15.5.6",
77
77
  "@types/turndown": "^5.0.5",
78
78
  "html-webpack-plugin": "^5.5.0",
79
- "react-scripts": "^5.0.1",
80
- "vitest": "^2.1.5",
79
+ "jsdom": "^26.0.0",
80
+ "vitest": "^3.0.5",
81
81
  "web-vitals": "^2.1.4",
82
82
  "webpack": "^5.79.0",
83
83
  "webpack-cli": "^5.0.1",