feat: fix openai / prisma typings and conversions

This commit is contained in:
Travis Fischer
2023-11-10 20:15:04 -06:00
parent d0c1c67725
commit 7458a92ead
12 changed files with 1155 additions and 5 deletions
+1 -1
View File
@@ -285,7 +285,7 @@ async function main() {
)
.replaceAll(/OpenAi/g, 'OpenAI')
// remove inferred types, as we don't use them
.replaceAll(/^.* = z.infer<[^>]*>;?$/gm, '')
// .replaceAll(/^.* = z.infer<[^>]*>;?$/gm, '')
.trim()
const prettySchemasSource0 = prettify(schemasSource)
+9 -2
View File
@@ -12,7 +12,7 @@
},
"scripts": {
"build": "tsc --project tsconfig.json",
"prebuild": "run-s clean",
"prebuild": "run-s clean && prisma generate",
"clean": "del dist",
"dev": "tsc --watch",
"prepare": "husky install",
@@ -20,11 +20,13 @@
"test": "run-p test:*",
"test:format": "prettier --check \"**/*.{js,ts,tsx}\"",
"test:lint": "eslint .",
"test:unit": "vitest",
"test:typecheck": "tsc --noEmit"
},
"dependencies": {
"@hono/node-server": "^1.2.0",
"@hono/zod-openapi": "^0.8.3",
"@prisma/client": "^5.5.2",
"hono": "^3.9.2",
"zod": "^3.22.4"
},
@@ -43,9 +45,14 @@
"openapi-jsonschema-parameters": "^12.1.3",
"openapi-types": "^12.1.3",
"prettier": "^2.8.8",
"prisma": "^5.5.2",
"prisma-json-types-generator": "^3.0.3",
"quicktype-core": "^23.0.77",
"tsx": "^4.0.0",
"typescript": "^5.2.2"
"type-fest": "^4.7.1",
"typescript": "^5.2.2",
"vite": "^4.5.0",
"vitest": "^0.34.6"
},
"lint-staged": {
"*.{ts,tsx}": [
+480
View File
@@ -11,6 +11,9 @@ dependencies:
'@hono/zod-openapi':
specifier: ^0.8.3
version: 0.8.3(hono@3.9.2)(zod@3.22.4)
'@prisma/client':
specifier: ^5.5.2
version: 5.5.2(prisma@5.5.2)
hono:
specifier: ^3.9.2
version: 3.9.2
@@ -61,15 +64,30 @@ devDependencies:
prettier:
specifier: ^2.8.8
version: 2.8.8
prisma:
specifier: ^5.5.2
version: 5.5.2
prisma-json-types-generator:
specifier: ^3.0.3
version: 3.0.3(prisma@5.5.2)(typescript@5.2.2)
quicktype-core:
specifier: ^23.0.77
version: 23.0.77
tsx:
specifier: ^4.0.0
version: 4.0.0
type-fest:
specifier: ^4.7.1
version: 4.7.1
typescript:
specifier: ^5.2.2
version: 5.2.2
vite:
specifier: ^4.5.0
version: 4.5.0(@types/node@20.9.0)
vitest:
specifier: ^0.34.6
version: 0.34.6
packages:
@@ -785,6 +803,13 @@ packages:
resolution: {integrity: sha512-dvuCeX5fC9dXgJn9t+X5atfmgQAzUOWqS1254Gh0m6i8wKd10ebXkfNKiRK+1GWi/yTvvLDHpoxLr0xxxeslWw==}
dev: true
/@jest/schemas@29.6.3:
resolution: {integrity: sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==}
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
dependencies:
'@sinclair/typebox': 0.27.8
dev: true
/@jridgewell/gen-mapping@0.3.3:
resolution: {integrity: sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ==}
engines: {node: '>=6.0.0'}
@@ -874,6 +899,49 @@ packages:
config-chain: 1.1.13
dev: true
/@prisma/client@5.5.2(prisma@5.5.2):
resolution: {integrity: sha512-54XkqR8M+fxbzYqe+bIXimYnkkcGqgOh0dn0yWtIk6CQT4IUCAvNFNcQZwk2KqaLU+/1PHTSWrcHtx4XjluR5w==}
engines: {node: '>=16.13'}
requiresBuild: true
peerDependencies:
prisma: '*'
peerDependenciesMeta:
prisma:
optional: true
dependencies:
'@prisma/engines-version': 5.5.1-1.aebc046ce8b88ebbcb45efe31cbe7d06fd6abc0a
prisma: 5.5.2
dev: false
/@prisma/debug@5.5.2:
resolution: {integrity: sha512-OeyuNABo1dgWHIQuJAdvW5qp5ccFfbI0CKNvdg8D34YWOfo6L+4J0gmnRI/j+h40HvM3S5WH2T8e3W9bPa7EVg==}
dependencies:
'@types/debug': 4.1.9
debug: 4.3.4
strip-ansi: 6.0.1
transitivePeerDependencies:
- supports-color
dev: true
/@prisma/engines-version@5.5.1-1.aebc046ce8b88ebbcb45efe31cbe7d06fd6abc0a:
resolution: {integrity: sha512-O+qHFnZvAyOFk1tUco2/VdiqS0ym42a3+6CYLScllmnpbyiTplgyLt2rK/B9BTjYkSHjrgMhkG47S0oqzdIckA==}
dev: false
/@prisma/engines@5.5.2:
resolution: {integrity: sha512-Be5hoNF8k+lkB3uEMiCHbhbfF6aj1GnrTBnn5iYFT7GEr3TsOEp1soviEcBR0tYCgHbxjcIxJMhdbvxALJhAqg==}
requiresBuild: true
/@prisma/generator-helper@5.5.2:
resolution: {integrity: sha512-qQz4JfhjjMs+C/dbZUoGAU+JV685Qe72iGonDM0c9H05A5s5MCWj5wV2kVi1/DNiy7jkfqGGM7bX8k0/8yO0FQ==}
dependencies:
'@prisma/debug': 5.5.2
'@types/cross-spawn': 6.0.3
cross-spawn: 7.0.3
kleur: 4.1.5
transitivePeerDependencies:
- supports-color
dev: true
/@rushstack/eslint-patch@1.5.1:
resolution: {integrity: sha512-6i/8UoL0P5y4leBIGzvkZdS85RDMG9y1ihZzmTZQ5LdHUYmZ7pKFoj8X0236s3lusPs1Fa5HTQUpwI+UfTcmeA==}
dev: true
@@ -896,6 +964,10 @@ packages:
- zenObservable
dev: true
/@sinclair/typebox@0.27.8:
resolution: {integrity: sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==}
dev: true
/@sindresorhus/is@4.6.0:
resolution: {integrity: sha512-t09vSN3MdfsyCHoFcTRCH/iUtG7OJ0CsjzB8cjAmKc/va/kIgeDI/TxsigdncE/4be734m0cvIYwNaV4i2XqAw==}
engines: {node: '>=10'}
@@ -967,6 +1039,28 @@ packages:
'@types/responselike': 1.0.3
dev: true
/@types/chai-subset@1.3.5:
resolution: {integrity: sha512-c2mPnw+xHtXDoHmdtcCXGwyLMiauiAyxWMzhGpqHC4nqI/Y5G2XhTampslK2rb59kpcuHon03UH8W6iYUzw88A==}
dependencies:
'@types/chai': 4.3.10
dev: true
/@types/chai@4.3.10:
resolution: {integrity: sha512-of+ICnbqjmFCiixUnqRulbylyXQrPqIGf/B3Jax1wIF3DvSheysQxAWvqHhZiW3IQrycvokcLcFQlveGp+vyNg==}
dev: true
/@types/cross-spawn@6.0.3:
resolution: {integrity: sha512-BDAkU7WHHRHnvBf5z89lcvACsvkz/n7Tv+HyD/uW76O29HoH1Tk/W6iQrepaZVbisvlEek4ygwT8IW7ow9XLAA==}
dependencies:
'@types/node': 20.9.0
dev: true
/@types/debug@4.1.9:
resolution: {integrity: sha512-8Hz50m2eoS56ldRlepxSBa6PWEVCtzUo/92HgLc2qTMnotJNIm7xP+UZhyWoYsyOdd5dxZ+NZLb24rsKyFs2ow==}
dependencies:
'@types/ms': 0.7.34
dev: true
/@types/http-cache-semantics@4.0.4:
resolution: {integrity: sha512-1m0bIFVc7eJWyve9S0RnuRgcQqF/Xd5QsUZAZeQFr1Q3/p9JWoQQEqmVy+DPTNpGXwhgIetAoYF8JSc33q29QA==}
dev: true
@@ -989,6 +1083,10 @@ packages:
resolution: {integrity: sha512-hov8bUuiLiyFPGyFPE1lwWhmzYbirOXQNNo40+y3zow8aFVTeyn3VWL0VFFfdNddA8S4Vf0Tc062rzyNr7Paag==}
dev: true
/@types/ms@0.7.34:
resolution: {integrity: sha512-nG96G3Wp6acyAgJqGasjODb+acrI7KltPiRxzHPXnP3NgI28bpQDRv53olbqGXbfcgF5aiiHmO3xpwEpS5Ld9g==}
dev: true
/@types/node-fetch@2.6.9:
resolution: {integrity: sha512-bQVlnMLFJ2d35DkPNjEPmd9ueO/rh5EiaZt2bhqiSarPjZIuIV6bPQVqcrEyvNo+AfTrRGVazle1tl597w3gfA==}
dependencies:
@@ -1160,6 +1258,44 @@ packages:
resolution: {integrity: sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==}
dev: true
/@vitest/expect@0.34.6:
resolution: {integrity: sha512-QUzKpUQRc1qC7qdGo7rMK3AkETI7w18gTCUrsNnyjjJKYiuUB9+TQK3QnR1unhCnWRC0AbKv2omLGQDF/mIjOw==}
dependencies:
'@vitest/spy': 0.34.6
'@vitest/utils': 0.34.6
chai: 4.3.10
dev: true
/@vitest/runner@0.34.6:
resolution: {integrity: sha512-1CUQgtJSLF47NnhN+F9X2ycxUP0kLHQ/JWvNHbeBfwW8CzEGgeskzNnHDyv1ieKTltuR6sdIHV+nmR6kPxQqzQ==}
dependencies:
'@vitest/utils': 0.34.6
p-limit: 4.0.0
pathe: 1.1.1
dev: true
/@vitest/snapshot@0.34.6:
resolution: {integrity: sha512-B3OZqYn6k4VaN011D+ve+AA4whM4QkcwcrwaKwAbyyvS/NB1hCWjFIBQxAQQSQir9/RtyAAGuq+4RJmbn2dH4w==}
dependencies:
magic-string: 0.30.5
pathe: 1.1.1
pretty-format: 29.7.0
dev: true
/@vitest/spy@0.34.6:
resolution: {integrity: sha512-xaCvneSaeBw/cz8ySmF7ZwGvL0lBjfvqc1LpQ/vcdHEvpLn3Ff1vAvjw+CoGn0802l++5L/pxb7whwcWAw+DUQ==}
dependencies:
tinyspy: 2.2.0
dev: true
/@vitest/utils@0.34.6:
resolution: {integrity: sha512-IG5aDD8S6zlvloDsnzHw0Ut5xczlF+kv2BOTo+iXfPr54Yhi5qbVOgGB1hZaVq4iJ4C/MZ2J0y15IlsV/ZcI0A==}
dependencies:
diff-sequences: 29.6.3
loupe: 2.3.7
pretty-format: 29.7.0
dev: true
/abort-controller@3.0.0:
resolution: {integrity: sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==}
engines: {node: '>=6.5'}
@@ -1175,6 +1311,11 @@ packages:
acorn: 8.11.2
dev: true
/acorn-walk@8.3.0:
resolution: {integrity: sha512-FS7hV565M5l1R08MXqo8odwMTB02C2UqzB17RVgu9EyuYFBqJZ3/ZY97sQD5FewVu1UyDFc1yztUDrAwT0EypA==}
engines: {node: '>=0.4.0'}
dev: true
/acorn@8.11.2:
resolution: {integrity: sha512-nc0Axzp/0FILLEVsm4fNwLCwMttvhEI263QtVPQcbpfZZ3ts0hLsZGOpE6czNlid7CJ9MlyH8reXkpsf3YUY4w==}
engines: {node: '>=0.4.0'}
@@ -1434,6 +1575,10 @@ packages:
engines: {node: '>=0.10.0'}
dev: true
/assertion-error@1.1.0:
resolution: {integrity: sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==}
dev: true
/ast-types-flow@0.0.8:
resolution: {integrity: sha512-OH/2E5Fg20h2aPrbe+QL8JZQFko0YZaF+j4mnQ7BGhfavO7OpSLa8a0y9sBwomHdSbkhTS8TQNayBfnW5DwbvQ==}
dev: true
@@ -1574,6 +1719,11 @@ packages:
run-applescript: 5.0.0
dev: true
/cac@6.7.14:
resolution: {integrity: sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==}
engines: {node: '>=8'}
dev: true
/cacheable-lookup@5.0.4:
resolution: {integrity: sha512-2/kNscPhpcxrOigMZzbiWF7dz8ilhb/nIHU3EyZiXWXpeq/au8qJ8VhdftMkty3n7Gj6HIGalQG8oiBNB3AJgA==}
engines: {node: '>=10.6.0'}
@@ -1656,6 +1806,19 @@ packages:
resolution: {integrity: sha512-NTt0DNoKe958Q0BE0j0c1V9jbUzhBxHIEJy7asmGrpE0yG63KTV7PLHPnK2E1O9RsQrQ081I3NLuXGS6zht3cw==}
dev: true
/chai@4.3.10:
resolution: {integrity: sha512-0UXG04VuVbruMUYbJ6JctvH0YnC/4q3/AkT18q4NaITo91CUm0liMS9VqzT9vZhVQ/1eqPanMWjBM+Juhfb/9g==}
engines: {node: '>=4'}
dependencies:
assertion-error: 1.1.0
check-error: 1.0.3
deep-eql: 4.1.3
get-func-name: 2.0.2
loupe: 2.3.7
pathval: 1.1.1
type-detect: 4.0.8
dev: true
/chalk@1.1.3:
resolution: {integrity: sha512-U3lRVLMSlsCfjqYPbLyVv11M9CPW4I728d6TCKMAOJueEeB9/8o+eSsMnxPJD+Q+K909sdESg7C+tIkoH6on1A==}
engines: {node: '>=0.10.0'}
@@ -1697,6 +1860,12 @@ packages:
resolution: {integrity: sha512-yrLQ/yVUFXkzg7EDQsPieE/53+0RlaWTs+wBrvW36cyilJ2SaDWfl4Yj7MtLTXleV9uEKefbAGUPv2/iWSooRA==}
dev: true
/check-error@1.0.3:
resolution: {integrity: sha512-iKEoDYaRmd1mxM90a2OEfWhjsjPpYPuQ+lMYsoxB126+t8fw7ySEO48nmDg5COTjxDI65/Y2OWpeEHk3ZOe8zg==}
dependencies:
get-func-name: 2.0.2
dev: true
/ci-info@3.9.0:
resolution: {integrity: sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ==}
engines: {node: '>=8'}
@@ -1976,6 +2145,13 @@ packages:
mimic-response: 3.1.0
dev: true
/deep-eql@4.1.3:
resolution: {integrity: sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw==}
engines: {node: '>=6'}
dependencies:
type-detect: 4.0.8
dev: true
/deep-equal@2.2.3:
resolution: {integrity: sha512-ZIwpnevOurS8bpT4192sqAowWM76JDKSHYzMLty3BZGSswgq6pBaH3DhCSW5xVAZICZyKdOBPjwww5wfgT/6PA==}
engines: {node: '>= 0.4'}
@@ -2094,6 +2270,11 @@ packages:
engines: {node: '>=6'}
dev: true
/diff-sequences@29.6.3:
resolution: {integrity: sha512-EjePK1srD3P08o2j4f0ExnylqRs5B9tJjcp9t1krH2qRi8CCdsYfwe9JgSLurFBWwq4uOlipzfk5fHNvwFKr8Q==}
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
dev: true
/digest-fetch@1.3.0:
resolution: {integrity: sha512-CGJuv6iKNM7QyZlM2T3sPAdZWd/p9zQiRNS9G+9COUCwzWFTs0Xp8NF5iePx7wtvhDykReiRRrSeNb4oMmB8lA==}
dependencies:
@@ -2973,6 +3154,10 @@ packages:
engines: {node: '>=6.9.0'}
dev: true
/get-func-name@2.0.2:
resolution: {integrity: sha512-8vXOvuE167CtIc3OyItco7N/dpRtBbYOsPsXCz7X/PMnlGjYjSGuZJgM1Y7mmew7BKf9BqvLX2tnOVy1BBUsxQ==}
dev: true
/get-intrinsic@1.2.2:
resolution: {integrity: sha512-0gSo4ml/0j98Y3lngkFEot/zhiCeWsbYIlZ+uZOVgzLyLaUw7wxUL+nCTP0XJvJg1AXulJRI3UJi8GsbDuxdGA==}
dependencies:
@@ -3861,6 +4046,10 @@ packages:
hasBin: true
dev: true
/jsonc-parser@3.2.0:
resolution: {integrity: sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==}
dev: true
/jsx-ast-utils@3.3.5:
resolution: {integrity: sha512-ZZow9HBI5O6EPgSJLUb8n2NKgmVWTwCvHGwFuJlMjvLFqlGG6pjirPhtdsseaLZjSibD8eegzmYpUZwoIlj2cQ==}
engines: {node: '>=4.0'}
@@ -3882,6 +4071,11 @@ packages:
engines: {node: '>=0.10.0'}
dev: true
/kleur@4.1.5:
resolution: {integrity: sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==}
engines: {node: '>=6'}
dev: true
/language-subtag-registry@0.3.22:
resolution: {integrity: sha512-tN0MCzyWnoz/4nHS6uxdlFWoUZT7ABptwKPQ52Ea7URk6vll88bWBVhodtnlfEuCcKWNGoc+uGbw1cwa9IKh/w==}
dev: true
@@ -4018,6 +4212,11 @@ packages:
strip-bom: 3.0.0
dev: true
/local-pkg@0.4.3:
resolution: {integrity: sha512-SFppqq5p42fe2qcZQqqEOiVRXl+WCP1MdT6k7BDEW1j++sp5fIY+/fdRQitvKgB5BrBcmrs5m/L0v2FrU5MY1g==}
engines: {node: '>=14'}
dev: true
/locate-path@5.0.0:
resolution: {integrity: sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==}
engines: {node: '>=8'}
@@ -4105,6 +4304,12 @@ packages:
js-tokens: 4.0.0
dev: true
/loupe@2.3.7:
resolution: {integrity: sha512-zSMINGVYkdpYSOBmLi0D1Uo7JU9nVdQKrHxC8eYlV+9YKK9WePqAlL7lSlorG/U2Fw1w0hTBmaa/jrQ3UbPHtA==}
dependencies:
get-func-name: 2.0.2
dev: true
/lowercase-keys@2.0.0:
resolution: {integrity: sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA==}
engines: {node: '>=8'}
@@ -4138,6 +4343,13 @@ packages:
hasBin: true
dev: true
/magic-string@0.30.5:
resolution: {integrity: sha512-7xlpfBaQaP/T6Vh8MO/EqXSW5En6INHEvEXQiuff7Gku0PWjU3uf6w/j9o7O+SpB5fOAkrI5HeoNgwjEO0pFsA==}
engines: {node: '>=12'}
dependencies:
'@jridgewell/sourcemap-codec': 1.4.15
dev: true
/map-obj@1.0.1:
resolution: {integrity: sha512-7N/q3lyZ+LVCp7PzuxrJr4KMbBE2hW7BT7YNia330OFxIf4d3r5zVpicP2650l7CPN6RM9zOJRl3NGpqSiw3Eg==}
engines: {node: '>=0.10.0'}
@@ -4274,6 +4486,15 @@ packages:
resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==}
dev: true
/mlly@1.4.2:
resolution: {integrity: sha512-i/Ykufi2t1EZ6NaPLdfnZk2AX8cs0d+mTzVKuPfqPKPatxLApaBoxJQ9x1/uckXtrS/U5oisPMDkNs0yQTaBRg==}
dependencies:
acorn: 8.11.2
pathe: 1.1.1
pkg-types: 1.0.3
ufo: 1.3.1
dev: true
/ms@2.1.2:
resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==}
dev: true
@@ -4295,6 +4516,12 @@ packages:
engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0}
dev: true
/nanoid@3.3.7:
resolution: {integrity: sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==}
engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}
hasBin: true
dev: true
/natural-compare-lite@1.4.0:
resolution: {integrity: sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g==}
dev: true
@@ -4846,6 +5073,14 @@ packages:
engines: {node: '>=8'}
dev: true
/pathe@1.1.1:
resolution: {integrity: sha512-d+RQGp0MAYTIaDBIMmOfMwz3E+LOZnxx1HZd5R18mmCZY0QBlK0LDZfPc8FW8Ed2DlvsuE6PRjroDY+wg4+j/Q==}
dev: true
/pathval@1.1.1:
resolution: {integrity: sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==}
dev: true
/picocolors@1.0.0:
resolution: {integrity: sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==}
dev: true
@@ -4886,11 +5121,28 @@ packages:
find-up: 6.3.0
dev: true
/pkg-types@1.0.3:
resolution: {integrity: sha512-nN7pYi0AQqJnoLPC9eHFQ8AcyaixBUOwvqc5TDnIKCMEE6I0y8P7OKA7fPexsXGCGxQDl/cmrLAp26LhcwxZ4A==}
dependencies:
jsonc-parser: 3.2.0
mlly: 1.4.2
pathe: 1.1.1
dev: true
/pluralize@8.0.0:
resolution: {integrity: sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==}
engines: {node: '>=4'}
dev: true
/postcss@8.4.31:
resolution: {integrity: sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==}
engines: {node: ^10 || ^12 || >=14}
dependencies:
nanoid: 3.3.7
picocolors: 1.0.0
source-map-js: 1.0.2
dev: true
/prelude-ls@1.2.1:
resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==}
engines: {node: '>= 0.8.0'}
@@ -4911,6 +5163,39 @@ packages:
react-is: 17.0.2
dev: true
/pretty-format@29.7.0:
resolution: {integrity: sha512-Pdlw/oPxN+aXdmM9R00JVC9WVFoCLTKJvDVLgmJ+qAffBMxsV85l/Lu7sNx4zSzPyoL2euImuEwHhOXdEgNFZQ==}
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
dependencies:
'@jest/schemas': 29.6.3
ansi-styles: 5.2.0
react-is: 18.2.0
dev: true
/prisma-json-types-generator@3.0.3(prisma@5.5.2)(typescript@5.2.2):
resolution: {integrity: sha512-6TT1J6biRpQdU1Z7ggLeQ74pQNFMxxvT2vwTc9/yYV3znDhy9kW/e/CE6j0XhL8nkP2xzshtCQ1Y/EAh+LO3jQ==}
engines: {node: '>=14.0'}
hasBin: true
peerDependencies:
prisma: ^5.1
typescript: ^5.1
dependencies:
'@prisma/generator-helper': 5.5.2
prisma: 5.5.2
tslib: 2.6.2
typescript: 5.2.2
transitivePeerDependencies:
- supports-color
dev: true
/prisma@5.5.2:
resolution: {integrity: sha512-WQtG6fevOL053yoPl6dbHV+IWgKo25IRN4/pwAGqcWmg7CrtoCzvbDbN9fXUc7QS2KK0LimHIqLsaCOX/vHl8w==}
engines: {node: '>=16.13'}
hasBin: true
requiresBuild: true
dependencies:
'@prisma/engines': 5.5.2
/process@0.11.10:
resolution: {integrity: sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==}
engines: {node: '>= 0.6.0'}
@@ -5001,6 +5286,10 @@ packages:
resolution: {integrity: sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==}
dev: true
/react-is@18.2.0:
resolution: {integrity: sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==}
dev: true
/read-file-safe@1.0.10:
resolution: {integrity: sha512-qW25fd2uMX3dV6Ui/R0jYK1MhTpjx8FO/VHaHTXzwWsGnkNwLRcqYfCXd9qDM+NZ273DPUvP2RaimYuLSu1K/g==}
dev: true
@@ -5244,6 +5533,14 @@ packages:
glob: 7.2.3
dev: true
/rollup@3.29.4:
resolution: {integrity: sha512-oWzmBZwvYrU0iJHtDmhsm662rC15FRXmcjCk1xD771dFDx5jJ02ufAQQTn0etB2emNk4J9EZg/yWKpsn9BWGRw==}
engines: {node: '>=14.18.0', npm: '>=8.0.0'}
hasBin: true
optionalDependencies:
fsevents: 2.3.3
dev: true
/run-applescript@5.0.0:
resolution: {integrity: sha512-XcT5rBksx1QdIhlFOCtgZkB99ZEouFZ1E2Kc2LHqNW13U3/74YGdkQRmThTwxy4QIyookibDKYZOPqX//6BlAg==}
engines: {node: '>=12'}
@@ -5391,6 +5688,10 @@ packages:
object-inspect: 1.13.1
dev: true
/siginfo@2.0.0:
resolution: {integrity: sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==}
dev: true
/signal-exit@3.0.7:
resolution: {integrity: sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==}
dev: true
@@ -5423,6 +5724,11 @@ packages:
is-fullwidth-code-point: 4.0.0
dev: true
/source-map-js@1.0.2:
resolution: {integrity: sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==}
engines: {node: '>=0.10.0'}
dev: true
/source-map-support@0.5.21:
resolution: {integrity: sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==}
dependencies:
@@ -5466,6 +5772,14 @@ packages:
resolution: {integrity: sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==}
dev: true
/stackback@0.0.2:
resolution: {integrity: sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==}
dev: true
/std-env@3.4.3:
resolution: {integrity: sha512-f9aPhy8fYBuMN+sNfakZV18U39PbalgjXG3lLB9WkaYTxijru61wb57V9wxxNthXM5Sd88ETBWi29qLAsHO52Q==}
dev: true
/stop-iteration-iterator@1.0.0:
resolution: {integrity: sha512-iCGQj+0l0HOdZ2AEeBADlsRC+vsnDsZsbdSiH1yNSjcfKM7fdpCMfqAL/dwF5BLiw/XhRft/Wax6zQbhq2BcjQ==}
engines: {node: '>= 0.4'}
@@ -5634,6 +5948,12 @@ packages:
engines: {node: '>=8'}
dev: true
/strip-literal@1.3.0:
resolution: {integrity: sha512-PugKzOsyXpArk0yWmUwqOZecSO0GH0bPoctLcqNDH9J04pVW3lflYE0ujElBGTloevcxF5MofAOZ7C5l2b+wLg==}
dependencies:
acorn: 8.11.2
dev: true
/supports-color@2.0.0:
resolution: {integrity: sha512-KKNVtd6pCYgPIKU4cp2733HWYCpplQhddZLBUryaAHou723x+FRzQ5Df824Fj+IyyuiQTRoub4SnIFfIcrp70g==}
engines: {node: '>=0.8.0'}
@@ -5701,6 +6021,20 @@ packages:
resolution: {integrity: sha512-pkY1fj1cKHb2seWDy0B16HeWyczlJA9/WW3u3c4z/NiWDsO3DOU5D7nhTLE9CF0yXv/QZFY7sEJmj24dK+Rrqw==}
dev: true
/tinybench@2.5.1:
resolution: {integrity: sha512-65NKvSuAVDP/n4CqH+a9w2kTlLReS9vhsAP06MWx+/89nMinJyB2icyl58RIcqCmIggpojIGeuJGhjU1aGMBSg==}
dev: true
/tinypool@0.7.0:
resolution: {integrity: sha512-zSYNUlYSMhJ6Zdou4cJwo/p7w5nmAH17GRfU/ui3ctvjXFErXXkruT4MWW6poDeXgCaIBlGLrfU6TbTXxyGMww==}
engines: {node: '>=14.0.0'}
dev: true
/tinyspy@2.2.0:
resolution: {integrity: sha512-d2eda04AN/cPOR89F7Xv5bK/jrQEhmcLFe6HFldoeO9AJtps+fqEnh486vnT/8y4bw38pSyxDcTCAq+Ks2aJTg==}
engines: {node: '>=14.0.0'}
dev: true
/titleize@3.0.0:
resolution: {integrity: sha512-KxVu8EYHDPBdUYdKZdKtU2aj2XfEx9AfjXxE/Aj0vT06w2icA09Vus1rh6eSu1y01akYg6BjIK/hxyLJINoMLQ==}
engines: {node: '>=12'}
@@ -5780,6 +6114,11 @@ packages:
prelude-ls: 1.2.1
dev: true
/type-detect@4.0.8:
resolution: {integrity: sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==}
engines: {node: '>=4'}
dev: true
/type-fest@0.20.2:
resolution: {integrity: sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==}
engines: {node: '>=10'}
@@ -5805,6 +6144,11 @@ packages:
engines: {node: '>=14.16'}
dev: true
/type-fest@4.7.1:
resolution: {integrity: sha512-iWr8RUmzAJRfhZugX9O7nZE6pCxDU8CZ3QxsLuTnGcBLJpCaP2ll3s4eMTBoFnU/CeXY/5rfQSuAEsTGJO4y8A==}
engines: {node: '>=16'}
dev: true
/typed-array-buffer@1.0.0:
resolution: {integrity: sha512-Y8KTSIglk9OZEr8zywiIHG/kmQ7KWyjseXs1CbSo8vC42w7hg2HgYTxSWwP0+is7bWDc1H+Fo026CpHFwm8tkw==}
engines: {node: '>= 0.4'}
@@ -5872,6 +6216,10 @@ packages:
hasBin: true
dev: true
/ufo@1.3.1:
resolution: {integrity: sha512-uY/99gMLIOlJPwATcMVYfqDSxUR9//AUcgZMzwfSTJPDKzA1S8mX4VLqa+fiAtveraQUBCz4FFcwVZBGbwBXIw==}
dev: true
/unbox-primitive@1.0.2:
resolution: {integrity: sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw==}
dependencies:
@@ -5974,6 +6322,129 @@ packages:
builtins: 1.0.3
dev: true
/vite-node@0.34.6(@types/node@20.9.0):
resolution: {integrity: sha512-nlBMJ9x6n7/Amaz6F3zJ97EBwR2FkzhBRxF5e+jE6LA3yi6Wtc2lyTij1OnDMIr34v5g/tVQtsVAzhT0jc5ygA==}
engines: {node: '>=v14.18.0'}
hasBin: true
dependencies:
cac: 6.7.14
debug: 4.3.4
mlly: 1.4.2
pathe: 1.1.1
picocolors: 1.0.0
vite: 4.5.0(@types/node@20.9.0)
transitivePeerDependencies:
- '@types/node'
- less
- lightningcss
- sass
- stylus
- sugarss
- supports-color
- terser
dev: true
/vite@4.5.0(@types/node@20.9.0):
resolution: {integrity: sha512-ulr8rNLA6rkyFAlVWw2q5YJ91v098AFQ2R0PRFwPzREXOUJQPtFUG0t+/ZikhaOCDqFoDhN6/v8Sq0o4araFAw==}
engines: {node: ^14.18.0 || >=16.0.0}
hasBin: true
peerDependencies:
'@types/node': '>= 14'
less: '*'
lightningcss: ^1.21.0
sass: '*'
stylus: '*'
sugarss: '*'
terser: ^5.4.0
peerDependenciesMeta:
'@types/node':
optional: true
less:
optional: true
lightningcss:
optional: true
sass:
optional: true
stylus:
optional: true
sugarss:
optional: true
terser:
optional: true
dependencies:
'@types/node': 20.9.0
esbuild: 0.18.20
postcss: 8.4.31
rollup: 3.29.4
optionalDependencies:
fsevents: 2.3.3
dev: true
/vitest@0.34.6:
resolution: {integrity: sha512-+5CALsOvbNKnS+ZHMXtuUC7nL8/7F1F2DnHGjSsszX8zCjWSSviphCb/NuS9Nzf4Q03KyyDRBAXhF/8lffME4Q==}
engines: {node: '>=v14.18.0'}
hasBin: true
peerDependencies:
'@edge-runtime/vm': '*'
'@vitest/browser': '*'
'@vitest/ui': '*'
happy-dom: '*'
jsdom: '*'
playwright: '*'
safaridriver: '*'
webdriverio: '*'
peerDependenciesMeta:
'@edge-runtime/vm':
optional: true
'@vitest/browser':
optional: true
'@vitest/ui':
optional: true
happy-dom:
optional: true
jsdom:
optional: true
playwright:
optional: true
safaridriver:
optional: true
webdriverio:
optional: true
dependencies:
'@types/chai': 4.3.10
'@types/chai-subset': 1.3.5
'@types/node': 20.9.0
'@vitest/expect': 0.34.6
'@vitest/runner': 0.34.6
'@vitest/snapshot': 0.34.6
'@vitest/spy': 0.34.6
'@vitest/utils': 0.34.6
acorn: 8.11.2
acorn-walk: 8.3.0
cac: 6.7.14
chai: 4.3.10
debug: 4.3.4
local-pkg: 0.4.3
magic-string: 0.30.5
pathe: 1.1.1
picocolors: 1.0.0
std-env: 3.4.3
strip-literal: 1.3.0
tinybench: 2.5.1
tinypool: 0.7.0
vite: 4.5.0(@types/node@20.9.0)
vite-node: 0.34.6(@types/node@20.9.0)
why-is-node-running: 2.2.2
transitivePeerDependencies:
- less
- lightningcss
- sass
- stylus
- sugarss
- supports-color
- terser
dev: true
/wcwidth@1.0.1:
resolution: {integrity: sha512-XHPEwS0q6TaxcvG85+8EYkbiCux2XtWG2mkc47Ng2A77BQu9+DqIOJldST4HgPkuea7dvKSj5VgX3P1d4rW8Tg==}
dependencies:
@@ -6064,6 +6535,15 @@ packages:
isexe: 2.0.0
dev: true
/why-is-node-running@2.2.2:
resolution: {integrity: sha512-6tSwToZxTOcotxHeA+qGCq1mVzKR3CwcJGmVcY+QE8SHy6TnpFnh8PAvPNHYr7EcuVeG0QSMxtYCuO1ta/G/oA==}
engines: {node: '>=8'}
hasBin: true
dependencies:
siginfo: 2.0.0
stackback: 0.0.2
dev: true
/widest-line@4.0.1:
resolution: {integrity: sha512-o0cyEG0e8GPzT4iGHphIOh0cJOV8fivsXxddQasHPHfoZf1ZexrfeA21w2NaEN1RHE+fXlfISmOE8R9N3u3Qig==}
engines: {node: '>=12'}
+214
View File
@@ -0,0 +1,214 @@
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
generator json {
provider = "prisma-json-types-generator"
}
model File {
id String @id @default(uuid())
created_at DateTime @default(now())
updated_at DateTime @updatedAt @ignore
bytes Int
filename String
purpose String
status FileStatus?
status_details String?
/// [FileObject]
object String @default("file")
@@index([purpose])
}
model Assistant {
id String @id @default(uuid())
created_at DateTime @default(now())
updated_at DateTime @updatedAt @ignore
description String?
file_ids String[] @default([])
instructions String?
/// [Metadata]
metadata Json?
model String
name String?
/// [Tool]
tools Json[] @default([])
/// [AssistantObject]
object String @default("assistant")
files AssistantFile[]
messages Message[]
runs Run[]
run_steps RunStep[]
}
model AssistantFile {
id String @id @default(uuid())
created_at DateTime @default(now())
updated_at DateTime @updatedAt @ignore
assistant_id String
/// [AssistantFileObject]
object String @default("assistant.file")
assistant Assistant @relation(fields: [assistant_id], references: [id])
}
model Thread {
id String @id @default(uuid())
created_at DateTime @default(now())
updated_at DateTime @updatedAt @ignore
/// [Metadata]
metadata Json?
/// [ThreadObject]
object String @default("thread")
messages Message[]
runs Run[]
run_steps RunStep[]
}
model Message {
id String @id @default(uuid())
created_at DateTime @default(now())
updated_at DateTime @updatedAt @ignore
/// [MessageContent]
content Json[]
file_ids String[] @default([])
/// [Metadata]
metadata Json?
role Role
assistant_id String
thread_id String
run_id String
/// [MessageObject]
object String @default("thread.message")
files MessageFile[]
thread Thread @relation(fields: [thread_id], references: [id])
assistant Assistant @relation(fields: [assistant_id], references: [id])
run Run @relation(fields: [run_id], references: [id])
}
model MessageFile {
id String @id @default(uuid())
created_at DateTime @default(now())
updated_at DateTime @updatedAt @ignore
message_id String
/// [MessageFileObject]
object String @default("thread.message.file")
message Message @relation(fields: [message_id], references: [id])
}
model Run {
id String @id @default(uuid())
created_at DateTime @default(now())
updated_at DateTime @updatedAt @ignore
instructions String
model String
file_ids String[] @default([])
/// [Metadata]
metadata Json?
/// [LastError]
last_error Json
/// [RequiredAction]
required_action Json
/// [Tool]
tools Json[] @default([])
status RunStatus
started_at DateTime?
completed_at DateTime?
cancelled_at DateTime?
expires_at DateTime?
failed_at DateTime?
assistant_id String
thread_id String
/// [RunObject]
object String @default("thread.run")
messages Message[]
run_steps RunStep[]
thread Thread @relation(fields: [thread_id], references: [id])
assistant Assistant @relation(fields: [assistant_id], references: [id])
}
model RunStep {
id String @id @default(uuid())
created_at DateTime @default(now())
updated_at DateTime @updatedAt @ignore
/// [Metadata]
metadata Json?
/// [LastError]
last_error Json
/// [StepDetails]
step_details Json
status RunStepStatus
type RunStepType
completed_at DateTime?
cancelled_at DateTime?
expires_at DateTime?
failed_at DateTime?
assistant_id String
thread_id String
run_id String
/// [RunStepObject]
object String @default("thread.run.step")
thread Thread @relation(fields: [thread_id], references: [id])
assistant Assistant @relation(fields: [assistant_id], references: [id])
run Run @relation(fields: [run_id], references: [id])
}
enum FileStatus {
error
processed
uploaded
}
enum Role {
assistant
user
system
function
tool
}
enum RunStatus {
cancelled
cancelling
completed
expired
failed
in_progress
queued
requires_action
}
enum RunStepStatus {
cancelled
completed
expired
failed
in_progress
}
enum RunStepType {
message_creation
tool_calls
}
+2
View File
@@ -18,6 +18,8 @@ TODO
## TODO
ThreadObjectSchema is incorrectly mapped
ListAssistantsParamsQueryClassSchema
ListMessagesParamsQueryClassSchema number causes issue with typings of all params
+6 -2
View File
@@ -1,6 +1,8 @@
import { OpenAPIHono } from '@hono/zod-openapi'
import * as routes from './generated/oai-routes'
import * as utils from './utils'
import { prisma } from './db'
const app: OpenAPIHono = new OpenAPIHono()
@@ -25,9 +27,11 @@ app.openapi(routes.createAssistant, async (c) => {
const body = c.req.valid('json')
console.log('createAssistant', { body })
// TODO
const res = await prisma.assistant.create({
data: utils.convertOAIToPrisma(body)
})
return c.jsonT({} as any)
return c.jsonT(utils.convertPrismaToOAI(res))
})
app.openapi(routes.getAssistant, async (c) => {
+5
View File
@@ -0,0 +1,5 @@
import { PrismaClient } from '@prisma/client'
const prisma = new PrismaClient()
export { prisma }
+241
View File
@@ -7,14 +7,17 @@
import { z } from '@hono/zod-openapi'
export const OrderSchema = z.enum(['asc', 'desc'])
export type Order = z.infer<typeof OrderSchema>
// One of `server_error` or `rate_limit_exceeded`.
export const CodeSchema = z.enum(['rate_limit_exceeded', 'server_error'])
export type Code = z.infer<typeof CodeSchema>
// The object type, which is always `thread.run.step``.
export const PurpleObjectSchema = z.literal('thread.run.step')
export type PurpleObject = z.infer<typeof PurpleObjectSchema>
// The status of the run step, which can be either `in_progress`, `cancelled`, `failed`,
// `completed`, or `expired`.
@@ -26,12 +29,14 @@ export const PurpleStatusSchema = z.enum([
'failed',
'in_progress'
])
export type PurpleStatus = z.infer<typeof PurpleStatusSchema>
// Always `logs`.
//
// Always `image`.
export const OutputTypeSchema = z.enum(['image', 'logs'])
export type OutputType = z.infer<typeof OutputTypeSchema>
// The type of tool call. This is always going to be `code_interpreter` for this type of
// tool call.
@@ -52,6 +57,7 @@ export const ToolTypeSchema = z.enum([
'function',
'retrieval'
])
export type ToolType = z.infer<typeof ToolTypeSchema>
// Always `message_creation``.
//
@@ -60,22 +66,27 @@ export const ToolTypeSchema = z.enum([
// The type of run step, which can be either `message_creation` or `tool_calls`.
export const StepDetailsTypeSchema = z.enum(['message_creation', 'tool_calls'])
export type StepDetailsType = z.infer<typeof StepDetailsTypeSchema>
// The role of the entity that is creating the message. Currently only `user` is supported.
export const MessageRoleSchema = z.literal('user')
export type MessageRole = z.infer<typeof MessageRoleSchema>
// The object type, which is always `thread.run`.
export const FluffyObjectSchema = z.literal('thread.run')
export type FluffyObject = z.infer<typeof FluffyObjectSchema>
// The type of tool call the output is required for. For now, this is always `function`.
export const PurpleTypeSchema = z.literal('function')
export type PurpleType = z.infer<typeof PurpleTypeSchema>
// For now, this is always `submit_tool_outputs`.
export const RequiredActionTypeSchema = z.literal('submit_tool_outputs')
export type RequiredActionType = z.infer<typeof RequiredActionTypeSchema>
// The status of the run, which can be either `queued`, `in_progress`, `requires_action`,
// `cancelling`, `cancelled`, `failed`, `completed`, or `expired`.
@@ -90,34 +101,41 @@ export const FluffyStatusSchema = z.enum([
'queued',
'requires_action'
])
export type FluffyStatus = z.infer<typeof FluffyStatusSchema>
// The object type, which is always `assistant`.
export const TentacledObjectSchema = z.literal('assistant')
export type TentacledObject = z.infer<typeof TentacledObjectSchema>
// Always `file_citation`.
//
// Always `file_path`.
export const AnnotationTypeSchema = z.enum(['file_citation', 'file_path'])
export type AnnotationType = z.infer<typeof AnnotationTypeSchema>
// Always `image_file`.
//
// Always `text`.
export const ContentTypeSchema = z.enum(['image_file', 'text'])
export type ContentType = z.infer<typeof ContentTypeSchema>
// The object type, which is always `thread.message`.
export const StickyObjectSchema = z.literal('thread.message')
export type StickyObject = z.infer<typeof StickyObjectSchema>
// The entity that produced the message. One of `user` or `assistant`.
export const DatumRoleSchema = z.enum(['assistant', 'user'])
export type DatumRole = z.infer<typeof DatumRoleSchema>
// The object type, which is always `file`.
export const OpenAIFileObjectSchema = z.literal('file')
export type OpenAIFileObject = z.infer<typeof OpenAIFileObjectSchema>
// The intended purpose of the file. Supported values are `fine-tune`, `fine-tune-results`,
// `assistants`, and `assistants_output`.
@@ -128,21 +146,28 @@ export const OpenAIFilePurposeSchema = z.enum([
'fine-tune',
'fine-tune-results'
])
export type OpenAIFilePurpose = z.infer<typeof OpenAIFilePurposeSchema>
// Deprecated. The current status of the file, which can be either `uploaded`, `processed`,
// or `error`.
export const OpenAIFileStatusSchema = z.enum(['error', 'processed', 'uploaded'])
export type OpenAIFileStatus = z.infer<typeof OpenAIFileStatusSchema>
export const ListFilesResponseObjectSchema = z.literal('list')
export type ListFilesResponseObject = z.infer<
typeof ListFilesResponseObjectSchema
>
// The object type, which is always `assistant.file`.
export const IndigoObjectSchema = z.literal('assistant.file')
export type IndigoObject = z.infer<typeof IndigoObjectSchema>
// The object type, which is always `thread.message.file`.
export const IndecentObjectSchema = z.literal('thread.message.file')
export type IndecentObject = z.infer<typeof IndecentObjectSchema>
// The intended purpose of the uploaded file.
//
@@ -155,56 +180,83 @@ export const CreateFileRequestPurposeSchema = z.enum([
'assistants',
'fine-tune'
])
export type CreateFileRequestPurpose = z.infer<
typeof CreateFileRequestPurposeSchema
>
export const DeleteAssistantResponseObjectSchema =
z.literal('assistant.deleted')
export type DeleteAssistantResponseObject = z.infer<
typeof DeleteAssistantResponseObjectSchema
>
// The object type, which is always `thread`.
export const ThreadObjectSchema = z.literal('thread')
export type ThreadObject = z.infer<typeof ThreadObjectSchema>
export const DeleteThreadResponseObjectSchema = z.literal('thread.deleted')
export type DeleteThreadResponseObject = z.infer<
typeof DeleteThreadResponseObjectSchema
>
export const DeleteAssistantFileResponseObjectSchema = z.literal(
'assistant.file.deleted'
)
export type DeleteAssistantFileResponseObject = z.infer<
typeof DeleteAssistantFileResponseObjectSchema
>
export const DeleteAssistantFileResponseSchema = z.object({
deleted: z.boolean(),
id: z.string(),
object: DeleteAssistantFileResponseObjectSchema
})
export type DeleteAssistantFileResponse = z.infer<
typeof DeleteAssistantFileResponseSchema
>
export const CreateAssistantFileRequestSchema = z.object({
file_id: z.string()
})
export type CreateAssistantFileRequest = z.infer<
typeof CreateAssistantFileRequestSchema
>
export const ToolOutputSchema = z.object({
output: z.string().optional(),
tool_call_id: z.string().optional()
})
export type ToolOutput = z.infer<typeof ToolOutputSchema>
export const SubmitToolOutputsRunRequestSchema = z.object({
tool_outputs: z.array(ToolOutputSchema)
})
export type SubmitToolOutputsRunRequest = z.infer<
typeof SubmitToolOutputsRunRequestSchema
>
export const ModifyRunRequestSchema = z.object({
metadata: z.union([z.record(z.string(), z.any()), z.null()]).optional()
})
export type ModifyRunRequest = z.infer<typeof ModifyRunRequestSchema>
export const ModifyMessageRequestSchema = z.object({
metadata: z.union([z.record(z.string(), z.any()), z.null()]).optional()
})
export type ModifyMessageRequest = z.infer<typeof ModifyMessageRequestSchema>
export const DeleteThreadResponseSchema = z.object({
deleted: z.boolean(),
id: z.string(),
object: DeleteThreadResponseObjectSchema
})
export type DeleteThreadResponse = z.infer<typeof DeleteThreadResponseSchema>
export const ModifyThreadRequestSchema = z.object({
metadata: z.union([z.record(z.string(), z.any()), z.null()]).optional()
})
export type ModifyThreadRequest = z.infer<typeof ModifyThreadRequestSchema>
export const ThreadSchema = z.object({
created_at: z.number(),
@@ -212,23 +264,29 @@ export const ThreadSchema = z.object({
metadata: z.record(z.string(), z.any()),
object: ThreadObjectSchema
})
export type Thread = z.infer<typeof ThreadSchema>
export const DeleteAssistantResponseSchema = z.object({
deleted: z.boolean(),
id: z.string(),
object: DeleteAssistantResponseObjectSchema
})
export type DeleteAssistantResponse = z.infer<
typeof DeleteAssistantResponseSchema
>
export const DeleteFileResponseSchema = z.object({
deleted: z.boolean(),
id: z.string(),
object: OpenAIFileObjectSchema
})
export type DeleteFileResponse = z.infer<typeof DeleteFileResponseSchema>
export const CreateFileRequestSchema = z.object({
file: z.string(),
purpose: CreateFileRequestPurposeSchema
})
export type CreateFileRequest = z.infer<typeof CreateFileRequestSchema>
export const MessageFileObjectSchema = z.object({
created_at: z.number(),
@@ -236,6 +294,7 @@ export const MessageFileObjectSchema = z.object({
message_id: z.string(),
object: IndecentObjectSchema
})
export type MessageFileObject = z.infer<typeof MessageFileObjectSchema>
export const ListMessageFilesResponseClassSchema = z.object({
data: z.array(MessageFileObjectSchema),
@@ -245,6 +304,9 @@ export const ListMessageFilesResponseClassSchema = z.object({
object: z.string(),
items: z.any()
})
export type ListMessageFilesResponseClass = z.infer<
typeof ListMessageFilesResponseClassSchema
>
export const AssistantFileObjectSchema = z.object({
assistant_id: z.string(),
@@ -252,6 +314,7 @@ export const AssistantFileObjectSchema = z.object({
id: z.string(),
object: IndigoObjectSchema
})
export type AssistantFileObject = z.infer<typeof AssistantFileObjectSchema>
export const ListAssistantFilesResponseClassSchema = z.object({
data: z.array(AssistantFileObjectSchema),
@@ -261,6 +324,9 @@ export const ListAssistantFilesResponseClassSchema = z.object({
object: z.string(),
items: z.any()
})
export type ListAssistantFilesResponseClass = z.infer<
typeof ListAssistantFilesResponseClassSchema
>
export const OpenAIFileClassSchema = z.object({
bytes: z.number(),
@@ -272,6 +338,7 @@ export const OpenAIFileClassSchema = z.object({
status: OpenAIFileStatusSchema,
status_details: z.string().optional()
})
export type OpenAIFileClass = z.infer<typeof OpenAIFileClassSchema>
export const ListFilesResponseSchema = z.object({
data: z.array(
@@ -287,17 +354,22 @@ export const ListFilesResponseSchema = z.object({
),
object: ListFilesResponseObjectSchema
})
export type ListFilesResponse = z.infer<typeof ListFilesResponseSchema>
export const IndecentFunctionObjectSchema = z.object({
description: z.string().optional(),
name: z.string(),
parameters: z.record(z.string(), z.any())
})
export type IndecentFunctionObject = z.infer<
typeof IndecentFunctionObjectSchema
>
export const CreateRunRequestToolSchema = z.object({
type: ToolTypeSchema,
function: IndecentFunctionObjectSchema.optional()
})
export type CreateRunRequestTool = z.infer<typeof CreateRunRequestToolSchema>
export const CreateRunRequestSchema = z.object({
assistant_id: z.string(),
@@ -306,15 +378,18 @@ export const CreateRunRequestSchema = z.object({
model: z.string().optional(),
tools: z.array(CreateRunRequestToolSchema).optional()
})
export type CreateRunRequest = z.infer<typeof CreateRunRequestSchema>
export const FilePathSchema = z.object({
file_id: z.string()
})
export type FilePath = z.infer<typeof FilePathSchema>
export const FileCitationSchema = z.object({
file_id: z.string(),
quote: z.string()
})
export type FileCitation = z.infer<typeof FileCitationSchema>
export const MessageContentTextAnnotationsFileObjectSchema = z.object({
end_index: z.number(),
@@ -324,21 +399,27 @@ export const MessageContentTextAnnotationsFileObjectSchema = z.object({
type: AnnotationTypeSchema,
file_path: FilePathSchema.optional()
})
export type MessageContentTextAnnotationsFileObject = z.infer<
typeof MessageContentTextAnnotationsFileObjectSchema
>
export const TextSchema = z.object({
annotations: z.array(MessageContentTextAnnotationsFileObjectSchema),
value: z.string()
})
export type Text = z.infer<typeof TextSchema>
export const ImageFileSchema = z.object({
file_id: z.string()
})
export type ImageFile = z.infer<typeof ImageFileSchema>
export const MessageContentObjectSchema = z.object({
image_file: ImageFileSchema.optional(),
type: ContentTypeSchema,
text: TextSchema.optional()
})
export type MessageContentObject = z.infer<typeof MessageContentObjectSchema>
export const MessageObjectSchema = z.object({
assistant_id: z.string(),
@@ -352,6 +433,7 @@ export const MessageObjectSchema = z.object({
run_id: z.string(),
thread_id: z.string()
})
export type MessageObject = z.infer<typeof MessageObjectSchema>
export const ListMessagesResponseClassSchema = z.object({
data: z.array(MessageObjectSchema),
@@ -360,17 +442,24 @@ export const ListMessagesResponseClassSchema = z.object({
last_id: z.string(),
object: z.string()
})
export type ListMessagesResponseClass = z.infer<
typeof ListMessagesResponseClassSchema
>
export const IndigoFunctionObjectSchema = z.object({
description: z.string().optional(),
name: z.string(),
parameters: z.record(z.string(), z.any())
})
export type IndigoFunctionObject = z.infer<typeof IndigoFunctionObjectSchema>
export const ModifyAssistantRequestToolSchema = z.object({
type: ToolTypeSchema,
function: IndigoFunctionObjectSchema.optional()
})
export type ModifyAssistantRequestTool = z.infer<
typeof ModifyAssistantRequestToolSchema
>
export const ModifyAssistantRequestSchema = z.object({
description: z.string().optional(),
@@ -381,17 +470,24 @@ export const ModifyAssistantRequestSchema = z.object({
name: z.string().optional(),
tools: z.array(ModifyAssistantRequestToolSchema).optional()
})
export type ModifyAssistantRequest = z.infer<
typeof ModifyAssistantRequestSchema
>
export const StickyFunctionObjectSchema = z.object({
description: z.string().optional(),
name: z.string(),
parameters: z.record(z.string(), z.any())
})
export type StickyFunctionObject = z.infer<typeof StickyFunctionObjectSchema>
export const CreateAssistantRequestToolSchema = z.object({
type: ToolTypeSchema,
function: StickyFunctionObjectSchema.optional()
})
export type CreateAssistantRequestTool = z.infer<
typeof CreateAssistantRequestToolSchema
>
export const CreateAssistantRequestSchema = z.object({
description: z.string().optional(),
@@ -402,17 +498,24 @@ export const CreateAssistantRequestSchema = z.object({
name: z.string().optional(),
tools: z.array(CreateAssistantRequestToolSchema).optional()
})
export type CreateAssistantRequest = z.infer<
typeof CreateAssistantRequestSchema
>
export const TentacledFunctionObjectSchema = z.object({
description: z.string().optional(),
name: z.string(),
parameters: z.record(z.string(), z.any())
})
export type TentacledFunctionObject = z.infer<
typeof TentacledFunctionObjectSchema
>
export const FluffyAssistantToolsSchema = z.object({
type: ToolTypeSchema,
function: TentacledFunctionObjectSchema.optional()
})
export type FluffyAssistantTools = z.infer<typeof FluffyAssistantToolsSchema>
export const AssistantObjectSchema = z.object({
created_at: z.number(),
@@ -426,6 +529,7 @@ export const AssistantObjectSchema = z.object({
object: TentacledObjectSchema,
tools: z.array(FluffyAssistantToolsSchema)
})
export type AssistantObject = z.infer<typeof AssistantObjectSchema>
export const ListAssistantsResponseSchema = z.object({
data: z.array(AssistantObjectSchema),
@@ -434,42 +538,52 @@ export const ListAssistantsResponseSchema = z.object({
last_id: z.string(),
object: z.string()
})
export type ListAssistantsResponse = z.infer<
typeof ListAssistantsResponseSchema
>
export const FluffyFunctionObjectSchema = z.object({
description: z.string().optional(),
name: z.string(),
parameters: z.record(z.string(), z.any())
})
export type FluffyFunctionObject = z.infer<typeof FluffyFunctionObjectSchema>
export const PurpleAssistantToolsSchema = z.object({
type: ToolTypeSchema,
function: FluffyFunctionObjectSchema.optional()
})
export type PurpleAssistantTools = z.infer<typeof PurpleAssistantToolsSchema>
export const FluffyFunctionSchema = z.object({
arguments: z.string(),
name: z.string()
})
export type FluffyFunction = z.infer<typeof FluffyFunctionSchema>
export const RunToolCallObjectSchema = z.object({
function: FluffyFunctionSchema,
id: z.string(),
type: PurpleTypeSchema
})
export type RunToolCallObject = z.infer<typeof RunToolCallObjectSchema>
export const SubmitToolOutputsSchema = z.object({
tool_calls: z.array(RunToolCallObjectSchema)
})
export type SubmitToolOutputs = z.infer<typeof SubmitToolOutputsSchema>
export const RequiredActionSchema = z.object({
submit_tool_outputs: SubmitToolOutputsSchema,
type: RequiredActionTypeSchema
})
export type RequiredAction = z.infer<typeof RequiredActionSchema>
export const FluffyLastErrorSchema = z.object({
code: CodeSchema,
message: z.string()
})
export type FluffyLastError = z.infer<typeof FluffyLastErrorSchema>
export const RunObjectSchema = z.object({
assistant_id: z.string(),
@@ -491,6 +605,7 @@ export const RunObjectSchema = z.object({
thread_id: z.string(),
tools: z.array(PurpleAssistantToolsSchema)
})
export type RunObject = z.infer<typeof RunObjectSchema>
export const ListRunsResponseSchema = z.object({
data: z.array(RunObjectSchema),
@@ -499,17 +614,22 @@ export const ListRunsResponseSchema = z.object({
last_id: z.string(),
object: z.string()
})
export type ListRunsResponse = z.infer<typeof ListRunsResponseSchema>
export const PurpleFunctionObjectSchema = z.object({
description: z.string().optional(),
name: z.string(),
parameters: z.record(z.string(), z.any())
})
export type PurpleFunctionObject = z.infer<typeof PurpleFunctionObjectSchema>
export const CreateThreadAndRunRequestToolSchema = z.object({
type: ToolTypeSchema,
function: PurpleFunctionObjectSchema.optional()
})
export type CreateThreadAndRunRequestTool = z.infer<
typeof CreateThreadAndRunRequestToolSchema
>
export const CreateMessageRequestSchema = z.object({
content: z.string(),
@@ -517,11 +637,13 @@ export const CreateMessageRequestSchema = z.object({
metadata: z.union([z.record(z.string(), z.any()), z.null()]).optional(),
role: MessageRoleSchema
})
export type CreateMessageRequest = z.infer<typeof CreateMessageRequestSchema>
export const CreateThreadRequestSchema = z.object({
messages: z.array(CreateMessageRequestSchema).optional(),
metadata: z.union([z.record(z.string(), z.any()), z.null()]).optional()
})
export type CreateThreadRequest = z.infer<typeof CreateThreadRequestSchema>
export const CreateThreadAndRunRequestSchema = z.object({
assistant_id: z.string(),
@@ -531,27 +653,36 @@ export const CreateThreadAndRunRequestSchema = z.object({
thread: CreateThreadRequestSchema.optional(),
tools: z.array(CreateThreadAndRunRequestToolSchema).optional()
})
export type CreateThreadAndRunRequest = z.infer<
typeof CreateThreadAndRunRequestSchema
>
export const PurpleFunctionSchema = z.object({
arguments: z.string(),
name: z.string(),
output: z.string()
})
export type PurpleFunction = z.infer<typeof PurpleFunctionSchema>
export const ImageSchema = z.object({
file_id: z.string()
})
export type Image = z.infer<typeof ImageSchema>
export const RunStepDetailsToolCallsCodeOutputObjectSchema = z.object({
logs: z.string().optional(),
type: OutputTypeSchema,
image: ImageSchema.optional()
})
export type RunStepDetailsToolCallsCodeOutputObject = z.infer<
typeof RunStepDetailsToolCallsCodeOutputObjectSchema
>
export const CodeInterpreterSchema = z.object({
input: z.string(),
outputs: z.array(RunStepDetailsToolCallsCodeOutputObjectSchema)
})
export type CodeInterpreter = z.infer<typeof CodeInterpreterSchema>
export const RunStepDetailsToolCallsObjectSchema = z.object({
code_interpreter: CodeInterpreterSchema.optional(),
@@ -560,21 +691,27 @@ export const RunStepDetailsToolCallsObjectSchema = z.object({
retrieval: z.union([z.record(z.string(), z.any()), z.null()]).optional(),
function: PurpleFunctionSchema.optional()
})
export type RunStepDetailsToolCallsObject = z.infer<
typeof RunStepDetailsToolCallsObjectSchema
>
export const MessageCreationSchema = z.object({
message_id: z.string()
})
export type MessageCreation = z.infer<typeof MessageCreationSchema>
export const StepDetailsSchema = z.object({
message_creation: MessageCreationSchema.optional(),
type: StepDetailsTypeSchema,
tool_calls: z.array(RunStepDetailsToolCallsObjectSchema).optional()
})
export type StepDetails = z.infer<typeof StepDetailsSchema>
export const PurpleLastErrorSchema = z.object({
code: CodeSchema,
message: z.string()
})
export type PurpleLastError = z.infer<typeof PurpleLastErrorSchema>
export const RunStepObjectSchema = z.object({
assistant_id: z.string(),
@@ -593,6 +730,7 @@ export const RunStepObjectSchema = z.object({
thread_id: z.string(),
type: StepDetailsTypeSchema
})
export type RunStepObject = z.infer<typeof RunStepObjectSchema>
export const ListRunStepsResponseClassSchema = z.object({
data: z.array(RunStepObjectSchema),
@@ -601,12 +739,18 @@ export const ListRunStepsResponseClassSchema = z.object({
last_id: z.string(),
object: z.string()
})
export type ListRunStepsResponseClass = z.infer<
typeof ListRunStepsResponseClassSchema
>
export const GetMessageFileParamsPathClassSchema = z.object({
file_id: z.string(),
message_id: z.string(),
thread_id: z.string()
})
export type GetMessageFileParamsPathClass = z.infer<
typeof GetMessageFileParamsPathClassSchema
>
export const ListMessageFilesParamsQueryClassSchema = z.object({
after: z.string().optional(),
@@ -614,25 +758,40 @@ export const ListMessageFilesParamsQueryClassSchema = z.object({
limit: z.string().optional(),
order: OrderSchema.optional()
})
export type ListMessageFilesParamsQueryClass = z.infer<
typeof ListMessageFilesParamsQueryClassSchema
>
export const ListMessageFilesParamsPathClassSchema = z.object({
message_id: z.string(),
thread_id: z.string()
})
export type ListMessageFilesParamsPathClass = z.infer<
typeof ListMessageFilesParamsPathClassSchema
>
export const DeleteAssistantFileParamsPathClassSchema = z.object({
assistant_id: z.string(),
file_id: z.string()
})
export type DeleteAssistantFileParamsPathClass = z.infer<
typeof DeleteAssistantFileParamsPathClassSchema
>
export const GetAssistantFileParamsPathClassSchema = z.object({
assistant_id: z.string(),
file_id: z.string()
})
export type GetAssistantFileParamsPathClass = z.infer<
typeof GetAssistantFileParamsPathClassSchema
>
export const CreateAssistantFileParamsPathClassSchema = z.object({
assistant_id: z.string()
})
export type CreateAssistantFileParamsPathClass = z.infer<
typeof CreateAssistantFileParamsPathClassSchema
>
export const ListAssistantFilesParamsQueryClassSchema = z.object({
after: z.string().optional(),
@@ -640,16 +799,25 @@ export const ListAssistantFilesParamsQueryClassSchema = z.object({
limit: z.string().optional(),
order: OrderSchema.optional()
})
export type ListAssistantFilesParamsQueryClass = z.infer<
typeof ListAssistantFilesParamsQueryClassSchema
>
export const ListAssistantFilesParamsPathClassSchema = z.object({
assistant_id: z.string()
})
export type ListAssistantFilesParamsPathClass = z.infer<
typeof ListAssistantFilesParamsPathClassSchema
>
export const GetRunStepParamsPathClassSchema = z.object({
run_id: z.string(),
step_id: z.string(),
thread_id: z.string()
})
export type GetRunStepParamsPathClass = z.infer<
typeof GetRunStepParamsPathClassSchema
>
export const ListRunStepsParamsQueryClassSchema = z.object({
after: z.string().optional(),
@@ -657,35 +825,54 @@ export const ListRunStepsParamsQueryClassSchema = z.object({
limit: z.string().optional(),
order: OrderSchema.optional()
})
export type ListRunStepsParamsQueryClass = z.infer<
typeof ListRunStepsParamsQueryClassSchema
>
export const ListRunStepsParamsPathClassSchema = z.object({
run_id: z.string(),
thread_id: z.string()
})
export type ListRunStepsParamsPathClass = z.infer<
typeof ListRunStepsParamsPathClassSchema
>
export const CancelRunParamsPathClassSchema = z.object({
run_id: z.string(),
thread_id: z.string()
})
export type CancelRunParamsPathClass = z.infer<
typeof CancelRunParamsPathClassSchema
>
export const SubmitToolOuputsToRunParamsPathClassSchema = z.object({
run_id: z.string(),
thread_id: z.string()
})
export type SubmitToolOuputsToRunParamsPathClass = z.infer<
typeof SubmitToolOuputsToRunParamsPathClassSchema
>
export const ModifyRunParamsPathClassSchema = z.object({
run_id: z.string(),
thread_id: z.string()
})
export type ModifyRunParamsPathClass = z.infer<
typeof ModifyRunParamsPathClassSchema
>
export const GetRunParamsPathClassSchema = z.object({
run_id: z.string(),
thread_id: z.string()
})
export type GetRunParamsPathClass = z.infer<typeof GetRunParamsPathClassSchema>
export const CreateRunParamsPathClassSchema = z.object({
thread_id: z.string()
})
export type CreateRunParamsPathClass = z.infer<
typeof CreateRunParamsPathClassSchema
>
export const ListRunsParamsQueryClassSchema = z.object({
after: z.string().optional(),
@@ -693,24 +880,39 @@ export const ListRunsParamsQueryClassSchema = z.object({
limit: z.string().optional(),
order: OrderSchema.optional()
})
export type ListRunsParamsQueryClass = z.infer<
typeof ListRunsParamsQueryClassSchema
>
export const ListRunsParamsPathClassSchema = z.object({
thread_id: z.string()
})
export type ListRunsParamsPathClass = z.infer<
typeof ListRunsParamsPathClassSchema
>
export const ModifyMessageParamsPathClassSchema = z.object({
message_id: z.string(),
thread_id: z.string()
})
export type ModifyMessageParamsPathClass = z.infer<
typeof ModifyMessageParamsPathClassSchema
>
export const GetMessageParamsPathClassSchema = z.object({
message_id: z.string(),
thread_id: z.string()
})
export type GetMessageParamsPathClass = z.infer<
typeof GetMessageParamsPathClassSchema
>
export const CreateMessageParamsPathClassSchema = z.object({
thread_id: z.string()
})
export type CreateMessageParamsPathClass = z.infer<
typeof CreateMessageParamsPathClassSchema
>
export const ListMessagesParamsQueryClassSchema = z.object({
after: z.string().optional(),
@@ -718,34 +920,58 @@ export const ListMessagesParamsQueryClassSchema = z.object({
limit: z.string().optional(),
order: OrderSchema.optional()
})
export type ListMessagesParamsQueryClass = z.infer<
typeof ListMessagesParamsQueryClassSchema
>
export const ListMessagesParamsPathClassSchema = z.object({
thread_id: z.string()
})
export type ListMessagesParamsPathClass = z.infer<
typeof ListMessagesParamsPathClassSchema
>
export const DeleteThreadParamsPathClassSchema = z.object({
thread_id: z.string()
})
export type DeleteThreadParamsPathClass = z.infer<
typeof DeleteThreadParamsPathClassSchema
>
export const ModifyThreadParamsPathClassSchema = z.object({
thread_id: z.string()
})
export type ModifyThreadParamsPathClass = z.infer<
typeof ModifyThreadParamsPathClassSchema
>
export const GetThreadParamsPathClassSchema = z.object({
thread_id: z.string()
})
export type GetThreadParamsPathClass = z.infer<
typeof GetThreadParamsPathClassSchema
>
export const DeleteAssistantParamsPathClassSchema = z.object({
assistant_id: z.string()
})
export type DeleteAssistantParamsPathClass = z.infer<
typeof DeleteAssistantParamsPathClassSchema
>
export const ModifyAssistantParamsPathClassSchema = z.object({
assistant_id: z.string()
})
export type ModifyAssistantParamsPathClass = z.infer<
typeof ModifyAssistantParamsPathClassSchema
>
export const GetAssistantParamsPathClassSchema = z.object({
assistant_id: z.string()
})
export type GetAssistantParamsPathClass = z.infer<
typeof GetAssistantParamsPathClassSchema
>
export const ListAssistantsParamsQueryClassSchema = z.object({
after: z.string().optional(),
@@ -753,19 +979,34 @@ export const ListAssistantsParamsQueryClassSchema = z.object({
limit: z.string().optional(),
order: OrderSchema.optional()
})
export type ListAssistantsParamsQueryClass = z.infer<
typeof ListAssistantsParamsQueryClassSchema
>
export const DownloadFileParamsPathClassSchema = z.object({
file_id: z.string()
})
export type DownloadFileParamsPathClass = z.infer<
typeof DownloadFileParamsPathClassSchema
>
export const RetrieveFileParamsPathClassSchema = z.object({
file_id: z.string()
})
export type RetrieveFileParamsPathClass = z.infer<
typeof RetrieveFileParamsPathClassSchema
>
export const DeleteFileParamsPathClassSchema = z.object({
file_id: z.string()
})
export type DeleteFileParamsPathClass = z.infer<
typeof DeleteFileParamsPathClassSchema
>
export const ListFilesParamsQueryClassSchema = z.object({
purpose: z.string().optional()
})
export type ListFilesParamsQueryClass = z.infer<
typeof ListFilesParamsQueryClassSchema
>
+27
View File
@@ -0,0 +1,27 @@
import type * as prisma from '@prisma/client'
import type { z } from '@hono/zod-openapi'
import { describe, expectTypeOf, it } from 'vitest'
import type * as oai from './generated/oai'
import type { OAITypeToPrismaType, PrismaTypeToOAIType } from './utils'
describe('Assistant', () => {
it('Assistant OAI to Prisma types', async () => {
const oaiInput = {} as OAITypeToPrismaType<
z.infer<typeof oai.AssistantObjectSchema>
>
const prismaOutput: prisma.Assistant = oaiInput
expectTypeOf<typeof oaiInput>().toMatchTypeOf<typeof prismaOutput>()
expectTypeOf<
typeof oaiInput
>().toMatchTypeOf<prisma.Prisma.AssistantCreateInput>()
})
it('Assistant Prisma types to OAI types', async () => {
const prismaInput = {} as PrismaTypeToOAIType<prisma.Assistant>
const oaiOutput: z.infer<typeof oai.AssistantObjectSchema> = prismaInput
expectTypeOf<typeof prismaInput>().toMatchTypeOf<typeof oaiOutput>()
})
})
+29
View File
@@ -0,0 +1,29 @@
import type { JsonifiableObject } from 'type-fest'
import type * as oai from './generated/oai'
declare global {
/**
* This namespace allows us to customize generated Prisma types, which we use
* for `Json` typing and literal string typing.
*
* @see https://github.com/arthurfiorette/prisma-json-types-generator
*/
namespace PrismaJson {
type Metadata = JsonifiableObject
type Tool = oai.FluffyAssistantToolsSchema
type MessageContent = oai.MessageContentObject
type LastError = oai.FluffyLastError
type RequiredAction = oai.RequiredAction
type StepDetails = oai.StepDetails
type AssistantObject = 'assistant'
type AssistantFileObject = 'assistant.file'
type FileObject = 'file'
type ThreadObject = 'thread'
type MessageObject = 'thread.message'
type MessageFileObject = 'thread.message.file'
type RunObject = 'thread.run'
type RunStepObject = 'thread.run.step'
}
}
+128
View File
@@ -0,0 +1,128 @@
import type { Simplify } from 'type-fest'
import './prisma-json-types.d.ts'
export type OAITypeToPrismaType<T extends Record<string, unknown>> = Simplify<
RequiredNonNullableObject<
Omit<
T,
| 'created_at'
| 'updated_at'
| 'started_at'
| 'cancelled_at'
| 'expires_at'
| 'failed_at'
> &
(T extends { created_at: number }
? T & { created_at: Date }
: Omit<T, 'created_at'>) &
(T extends { updated_at: number }
? T & { updated_at: Date }
: Omit<T, 'updated_at'>) &
(T extends { started_at: number }
? T & { started_at: number }
: Omit<T, 'started_at'>) &
(T extends { cancelled_at: number }
? T & { cancelled_at: number }
: Omit<T, 'cancelled_at'>) &
(T extends { expires_at: number }
? T & { expires_at: number }
: Omit<T, 'expires_at'>) &
(T extends { failed_at: number }
? T & { failed_at: number }
: Omit<T, 'failed_at'>)
>
>
export type PrismaTypeToOAIType<T extends Record<string, unknown>> = Simplify<
RequiredNonNullableObject<
Omit<
T,
| 'created_at'
| 'updated_at'
| 'started_at'
| 'cancelled_at'
| 'expires_at'
| 'failed_at'
> &
(T extends { created_at: Date }
? T & { created_at: number }
: Omit<T, 'created_at'>) &
(T extends { updated_at: Date }
? T & { updated_at: number }
: Omit<T, 'updated_at'>) &
(T extends { started_at: Date }
? T & { started_at: number }
: Omit<T, 'started_at'>) &
(T extends { cancelled_at: Date }
? T & { cancelled_at: number }
: Omit<T, 'cancelled_at'>) &
(T extends { expires_at: Date }
? T & { expires_at: number }
: Omit<T, 'expires_at'>) &
(T extends { failed_at: Date }
? T & { failed_at: number }
: Omit<T, 'failed_at'>)
>
>
export type RequiredNonNullableObject<T extends object> = {
[P in keyof Required<T>]: NonNullable<T[P]>
}
export function convertPrismaToOAI<
T extends Record<string, unknown>,
U extends PrismaTypeToOAIType<T>
>(obj: T): U {
obj = removeUndefinedAndNullValues(obj)
const dateKeys = [
'created_at',
'updated_at',
'started_at',
'cancelled_at',
'expires_at',
'failed_at'
]
for (const key of dateKeys) {
if (key in obj && obj[key] instanceof Date) {
;(obj as any)[key] = ((obj[key] as Date).getTime() / 1000) | 0
}
}
return obj as unknown as U
}
export function convertOAIToPrisma<
T extends Record<string, unknown>,
U extends OAITypeToPrismaType<T>
>(obj: T): U {
obj = removeUndefinedAndNullValues(obj)
const dateKeys = [
'created_at',
'updated_at',
'started_at',
'cancelled_at',
'expires_at',
'failed_at'
]
for (const key of dateKeys) {
if (key in obj && obj[key]) {
;(obj as any)[key] = new Date(obj[key] as number)
}
}
return obj as unknown as U
}
export function removeUndefinedAndNullValues<T extends Record<string, unknown>>(
obj: T
): RequiredNonNullableObject<T> {
Object.keys(obj).forEach(
(key) => (obj[key] === undefined || obj[key] === null) && delete obj[key]
)
return obj as RequiredNonNullableObject<T>
}
+13
View File
@@ -0,0 +1,13 @@
import { defineConfig } from 'vite'
export default defineConfig(() => {
return {
mode: 'test',
test: {
environment: 'node',
globals: true,
watch: false
}
}
})