@adminforth/text-complete 1.8.1 → 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/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,10 +1,13 @@
1
1
  {
2
2
  "name": "@adminforth/text-complete",
3
- "version": "1.8.1",
3
+ "version": "1.8.3",
4
4
  "description": "Text completion plugin for adminforth",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
+ "publishConfig": {
9
+ "access": "public"
10
+ },
8
11
  "homepage": "https://adminforth.dev/docs/tutorial/Plugins/text-complete/",
9
12
  "scripts": {
10
13
  "build": "tsc && rsync -av --exclude 'node_modules' custom dist/",
@@ -49,5 +52,8 @@
49
52
  "prerelease": true
50
53
  }
51
54
  ]
55
+ },
56
+ "dependencies": {
57
+ "adminforth": "^2.4.0-next.222"
52
58
  }
53
59
  }