@adminforth/text-complete 2.0.24 → 2.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/dist/index.js CHANGED
@@ -8,6 +8,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { AdminForthPlugin, AdminForthDataTypes, RateLimiter } from "adminforth";
11
+ import { z } from "zod";
12
+ const doCompleteBodySchema = z.object({
13
+ record: z.record(z.string(), z.any()),
14
+ }).strict();
11
15
  export default class TextCompletePlugin extends AdminForthPlugin {
12
16
  constructor(options) {
13
17
  var _a, _b;
@@ -66,8 +70,10 @@ export default class TextCompletePlugin extends AdminForthPlugin {
66
70
  server.endpoint({
67
71
  method: 'POST',
68
72
  path: `/plugin/${this.pluginInstanceId}/doComplete`,
73
+ request_schema: doCompleteBodySchema,
69
74
  handler: (_a) => __awaiter(this, [_a], void 0, function* ({ body, headers }) {
70
75
  var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
76
+ const data = body;
71
77
  if (this.rateLimiter) {
72
78
  // rate limit
73
79
  // const { error } = RateLimiter.checkRateLimit(
@@ -81,7 +87,7 @@ export default class TextCompletePlugin extends AdminForthPlugin {
81
87
  };
82
88
  }
83
89
  }
84
- const { record } = body;
90
+ const { record } = data;
85
91
  if (!record) {
86
92
  return { completion: [] };
87
93
  }
package/index.ts CHANGED
@@ -1,6 +1,11 @@
1
1
 
2
2
  import { IAdminForth, IHttpServer, AdminForthPlugin, AdminForthResource, AdminForthDataTypes, RateLimiter } from "adminforth";
3
3
  import { PluginOptions } from './types.js';
4
+ import { z } from "zod";
5
+
6
+ const doCompleteBodySchema = z.object({
7
+ record: z.record(z.string(), z.any()),
8
+ }).strict();
4
9
 
5
10
 
6
11
  export default class TextCompletePlugin extends AdminForthPlugin {
@@ -82,7 +87,9 @@ export default class TextCompletePlugin extends AdminForthPlugin {
82
87
  server.endpoint({
83
88
  method: 'POST',
84
89
  path: `/plugin/${this.pluginInstanceId}/doComplete`,
90
+ request_schema: doCompleteBodySchema,
85
91
  handler: async ({ body, headers }) => {
92
+ const data = body as z.infer<typeof doCompleteBodySchema>;
86
93
  if (this.rateLimiter) {
87
94
  // rate limit
88
95
  // const { error } = RateLimiter.checkRateLimit(
@@ -97,7 +104,7 @@ export default class TextCompletePlugin extends AdminForthPlugin {
97
104
  }
98
105
  }
99
106
 
100
- const { record } = body;
107
+ const { record } = data;
101
108
  if (!record) {
102
109
  return { completion: [] };
103
110
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/text-complete",
3
- "version": "2.0.24",
3
+ "version": "2.1.1",
4
4
  "description": "Text completion plugin for adminforth",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -22,9 +22,12 @@
22
22
  ],
23
23
  "author": "DevForth (https://devforth.io)",
24
24
  "license": "MIT",
25
+ "dependencies": {
26
+ "zod": "^4.3.6"
27
+ },
25
28
  "devDependencies": {
26
29
  "@types/node": "^22.10.7",
27
- "adminforth": "^3.6.21",
30
+ "adminforth": "^3.8.2",
28
31
  "semantic-release": "^24.2.1",
29
32
  "semantic-release-slack-bot": "^4.0.2",
30
33
  "typescript": "^5.7.3"
@@ -55,6 +58,6 @@
55
58
  ]
56
59
  },
57
60
  "peerDependencies": {
58
- "adminforth": "^3.6.21"
61
+ "adminforth": "^3.8.2"
59
62
  }
60
63
  }