@ai-sdk/valibot 0.0.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/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # @ai-sdk/valibot
2
+
3
+ ## 0.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 704e17f: chore (schema/valibot): release valibot schema
package/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2023 Vercel, Inc.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,7 @@
1
+ # AI SDK - Valibot Schema Support
2
+
3
+ ## Setup
4
+
5
+ ```bash
6
+ npm i @ai-sdk/valibot
7
+ ```
@@ -0,0 +1,6 @@
1
+ import { Schema } from 'ai';
2
+ import * as v from 'valibot';
3
+
4
+ declare function valibotSchema<OBJECT>(valibotSchema: v.GenericSchema<unknown, OBJECT>): Schema<OBJECT>;
5
+
6
+ export { valibotSchema };
@@ -0,0 +1,6 @@
1
+ import { Schema } from 'ai';
2
+ import * as v from 'valibot';
3
+
4
+ declare function valibotSchema<OBJECT>(valibotSchema: v.GenericSchema<unknown, OBJECT>): Schema<OBJECT>;
5
+
6
+ export { valibotSchema };
package/dist/index.js ADDED
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var src_exports = {};
32
+ __export(src_exports, {
33
+ valibotSchema: () => valibotSchema
34
+ });
35
+ module.exports = __toCommonJS(src_exports);
36
+
37
+ // src/valibot-schema.ts
38
+ var import_to_json_schema = require("@valibot/to-json-schema");
39
+ var import_ai = require("ai");
40
+ var v = __toESM(require("valibot"));
41
+ function valibotSchema(valibotSchema2) {
42
+ return (0, import_ai.jsonSchema)((0, import_to_json_schema.toJsonSchema)(valibotSchema2), {
43
+ validate: (value) => {
44
+ const result = v.safeParse(valibotSchema2, value);
45
+ return result.success ? { success: true, value: result.output } : { success: false, error: new v.ValiError(result.issues) };
46
+ }
47
+ });
48
+ }
49
+ // Annotate the CommonJS export names for ESM import in node:
50
+ 0 && (module.exports = {
51
+ valibotSchema
52
+ });
53
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/valibot-schema.ts"],"sourcesContent":["export { valibotSchema } from './valibot-schema';\n","import { toJsonSchema as valibotToJsonSchema } from '@valibot/to-json-schema';\nimport { jsonSchema, Schema } from 'ai';\nimport * as v from 'valibot';\n\nexport function valibotSchema<OBJECT>(\n valibotSchema: v.GenericSchema<unknown, OBJECT>,\n): Schema<OBJECT> {\n return jsonSchema(valibotToJsonSchema(valibotSchema), {\n validate: value => {\n const result = v.safeParse(valibotSchema, value);\n return result.success\n ? { success: true, value: result.output }\n : { success: false, error: new v.ValiError(result.issues) };\n },\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,4BAAoD;AACpD,gBAAmC;AACnC,QAAmB;AAEZ,SAAS,cACdA,gBACgB;AAChB,aAAO,0BAAW,sBAAAC,cAAoBD,cAAa,GAAG;AAAA,IACpD,UAAU,WAAS;AACjB,YAAM,SAAW,YAAUA,gBAAe,KAAK;AAC/C,aAAO,OAAO,UACV,EAAE,SAAS,MAAM,OAAO,OAAO,OAAO,IACtC,EAAE,SAAS,OAAO,OAAO,IAAM,YAAU,OAAO,MAAM,EAAE;AAAA,IAC9D;AAAA,EACF,CAAC;AACH;","names":["valibotSchema","valibotToJsonSchema"]}
package/dist/index.mjs ADDED
@@ -0,0 +1,16 @@
1
+ // src/valibot-schema.ts
2
+ import { toJsonSchema as valibotToJsonSchema } from "@valibot/to-json-schema";
3
+ import { jsonSchema } from "ai";
4
+ import * as v from "valibot";
5
+ function valibotSchema(valibotSchema2) {
6
+ return jsonSchema(valibotToJsonSchema(valibotSchema2), {
7
+ validate: (value) => {
8
+ const result = v.safeParse(valibotSchema2, value);
9
+ return result.success ? { success: true, value: result.output } : { success: false, error: new v.ValiError(result.issues) };
10
+ }
11
+ });
12
+ }
13
+ export {
14
+ valibotSchema
15
+ };
16
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/valibot-schema.ts"],"sourcesContent":["import { toJsonSchema as valibotToJsonSchema } from '@valibot/to-json-schema';\nimport { jsonSchema, Schema } from 'ai';\nimport * as v from 'valibot';\n\nexport function valibotSchema<OBJECT>(\n valibotSchema: v.GenericSchema<unknown, OBJECT>,\n): Schema<OBJECT> {\n return jsonSchema(valibotToJsonSchema(valibotSchema), {\n validate: value => {\n const result = v.safeParse(valibotSchema, value);\n return result.success\n ? { success: true, value: result.output }\n : { success: false, error: new v.ValiError(result.issues) };\n },\n });\n}\n"],"mappings":";AAAA,SAAS,gBAAgB,2BAA2B;AACpD,SAAS,kBAA0B;AACnC,YAAY,OAAO;AAEZ,SAAS,cACdA,gBACgB;AAChB,SAAO,WAAW,oBAAoBA,cAAa,GAAG;AAAA,IACpD,UAAU,WAAS;AACjB,YAAM,SAAW,YAAUA,gBAAe,KAAK;AAC/C,aAAO,OAAO,UACV,EAAE,SAAS,MAAM,OAAO,OAAO,OAAO,IACtC,EAAE,SAAS,OAAO,OAAO,IAAM,YAAU,OAAO,MAAM,EAAE;AAAA,IAC9D;AAAA,EACF,CAAC;AACH;","names":["valibotSchema"]}
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "@ai-sdk/valibot",
3
+ "version": "0.0.1",
4
+ "license": "Apache-2.0",
5
+ "sideEffects": false,
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.mjs",
8
+ "types": "./dist/index.d.ts",
9
+ "files": [
10
+ "dist/**/*",
11
+ "CHANGELOG.md"
12
+ ],
13
+ "exports": {
14
+ "./package.json": "./package.json",
15
+ ".": {
16
+ "types": "./dist/index.d.ts",
17
+ "import": "./dist/index.mjs",
18
+ "require": "./dist/index.js"
19
+ }
20
+ },
21
+ "dependencies": {
22
+ "ai": "4.1.34"
23
+ },
24
+ "devDependencies": {
25
+ "@types/node": "^18",
26
+ "tsup": "^8",
27
+ "typescript": "5.6.3",
28
+ "valibot": "^1.0.0-rc.0 || ^1.0.0",
29
+ "@vercel/ai-tsconfig": "0.0.0"
30
+ },
31
+ "peerDependencies": {
32
+ "@valibot/to-json-schema": "^1.0.0-rc.0 || ^1.0.0",
33
+ "valibot": "^1.0.0-rc.0 || ^1.0.0"
34
+ },
35
+ "engines": {
36
+ "node": ">=18"
37
+ },
38
+ "publishConfig": {
39
+ "access": "public"
40
+ },
41
+ "homepage": "https://sdk.vercel.ai/docs",
42
+ "repository": {
43
+ "type": "git",
44
+ "url": "git+https://github.com/vercel/ai.git"
45
+ },
46
+ "bugs": {
47
+ "url": "https://github.com/vercel/ai/issues"
48
+ },
49
+ "keywords": [
50
+ "ai"
51
+ ],
52
+ "scripts": {
53
+ "build": "tsup",
54
+ "build:watch": "tsup --watch",
55
+ "clean": "rm -rf dist",
56
+ "lint": "eslint \"./**/*.ts*\"",
57
+ "type-check": "tsc --noEmit",
58
+ "prettier-check": "prettier --check \"./**/*.ts*\""
59
+ }
60
+ }