@adminforth/text-complete 1.8.2 → 1.8.3

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/build.log CHANGED
@@ -9,5 +9,5 @@ custom/package-lock.json
9
9
  custom/package.json
10
10
  custom/tsconfig.json
11
11
 
12
- sent 22,349 bytes received 96 bytes 44,890.00 bytes/sec
12
+ sent 22,354 bytes received 96 bytes 44,900.00 bytes/sec
13
13
  total size is 21,996 speedup is 0.98
package/dist/index.js CHANGED
@@ -66,8 +66,13 @@ export default class TextCompletePlugin extends AdminForthPlugin {
66
66
  var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
67
67
  if ((_b = this.options.rateLimit) === null || _b === void 0 ? void 0 : _b.limit) {
68
68
  // rate limit
69
- const { error } = RateLimiter.checkRateLimit(this.pluginInstanceId, (_c = this.options.rateLimit) === null || _c === void 0 ? void 0 : _c.limit, this.adminforth.auth.getClientIp(headers));
70
- if (error) {
69
+ // const { error } = RateLimiter.checkRateLimit(
70
+ // this.pluginInstanceId,
71
+ // this.options.rateLimit?.limit,
72
+ // this.adminforth.auth.getClientIp(headers),
73
+ // );
74
+ const rateLimiter = new RateLimiter((_c = this.options.rateLimit) === null || _c === void 0 ? void 0 : _c.limit);
75
+ if (!rateLimiter.consume(`${this.pluginInstanceId}-${this.adminforth.auth.getClientIp(headers)}`)) {
71
76
  return {
72
77
  completion: [],
73
78
  };
package/index.ts CHANGED
@@ -80,12 +80,13 @@ export default class TextCompletePlugin extends AdminForthPlugin {
80
80
  handler: async ({ body, headers }) => {
81
81
  if (this.options.rateLimit?.limit) {
82
82
  // rate limit
83
- const { error } = RateLimiter.checkRateLimit(
84
- this.pluginInstanceId,
85
- this.options.rateLimit?.limit,
86
- this.adminforth.auth.getClientIp(headers),
87
- );
88
- if (error) {
83
+ // const { error } = RateLimiter.checkRateLimit(
84
+ // this.pluginInstanceId,
85
+ // this.options.rateLimit?.limit,
86
+ // this.adminforth.auth.getClientIp(headers),
87
+ // );
88
+ const rateLimiter = new RateLimiter(this.options.rateLimit?.limit);
89
+ if (!rateLimiter.consume(`${this.pluginInstanceId}-${this.adminforth.auth.getClientIp(headers)}`)) {
89
90
  return {
90
91
  completion: [],
91
92
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/text-complete",
3
- "version": "1.8.2",
3
+ "version": "1.8.3",
4
4
  "description": "Text completion plugin for adminforth",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -52,5 +52,8 @@
52
52
  "prerelease": true
53
53
  }
54
54
  ]
55
+ },
56
+ "dependencies": {
57
+ "adminforth": "^2.4.0-next.222"
55
58
  }
56
59
  }