Skip to content

Commit 5207069

Browse files
fix body issues (#206)
* fix json body issues * update v * tweak gen * more modeling tweaks * Generated new lib * update spec --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent c4a0ee3 commit 5207069

17 files changed

+154
-89
lines changed

__tests__/gen/ai-create_text_to_cad.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { ai } from '../../src/index.js';
22

33
async function example() {
4-
const response = await ai.create_text_to_cad({ output_format: 'stl' });
4+
const response = await ai.create_text_to_cad({
5+
output_format: 'stl',
6+
body: { prompt: 'The prompt for the model.' },
7+
});
58
if ('error_code' in response) throw response;
69

710
return response;

__tests__/gen/modeling-modeling_commands_ws.test.ts

Lines changed: 0 additions & 20 deletions
This file was deleted.

__tests__/gen/oauth2-device_auth_confirm.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { oauth2 } from '../../src/index.js';
22

33
async function example() {
4-
const response = await oauth2.device_auth_confirm();
4+
const response = await oauth2.device_auth_confirm({
5+
body: { user_code: 'The user code.' },
6+
});
57
if ('error_code' in response) throw response;
68

79
return response;

__tests__/gen/payments-create_payment_information_for_user.test.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
11
import { payments } from '../../src/index.js';
22

33
async function example() {
4-
const response = await payments.create_payment_information_for_user();
4+
const response = await payments.create_payment_information_for_user({
5+
body: {
6+
address: {
7+
city: 'The city component.',
8+
country: 'An ISO-3166 alpha-2 country code. Always uppercase.',
9+
state: 'The state component.',
10+
street1: 'The first street component.',
11+
street2: 'The second street component.',
12+
user_id: 'A UUID usually v4 or v7',
13+
zip: 'The zip component.',
14+
},
15+
name: 'The name of the customer.',
16+
phone: 'The phone for the customer.',
17+
},
18+
});
519
if ('error_code' in response) throw response;
620

721
return response;

__tests__/gen/payments-update_payment_information_for_user.test.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
11
import { payments } from '../../src/index.js';
22

33
async function example() {
4-
const response = await payments.update_payment_information_for_user();
4+
const response = await payments.update_payment_information_for_user({
5+
body: {
6+
address: {
7+
city: 'The city component.',
8+
country: 'An ISO-3166 alpha-2 country code. Always uppercase.',
9+
state: 'The state component.',
10+
street1: 'The first street component.',
11+
street2: 'The second street component.',
12+
user_id: 'A UUID usually v4 or v7',
13+
zip: 'The zip component.',
14+
},
15+
name: 'The name of the customer.',
16+
phone: 'The phone for the customer.',
17+
},
18+
});
519
if ('error_code' in response) throw response;
620

721
return response;

__tests__/gen/users-update_user_self.test.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
import { users } from '../../src/index.js';
22

33
async function example() {
4-
const response = await users.update_user_self();
4+
const response = await users.update_user_self({
5+
body: {
6+
company: "The user's company.",
7+
discord: "The user's Discord handle.",
8+
first_name: "The user's first name.",
9+
github: "The user's GitHub handle.",
10+
last_name: "The user's last name.",
11+
phone: "The user's phone number.",
12+
},
13+
});
514
if ('error_code' in response) throw response;
615

716
return response;

kittycad.ts.patch.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,15 +147,15 @@
147147
"op": "add",
148148
"path": "/paths/~1user~1payment/post/x-typescript",
149149
"value": {
150-
"example": "import { payments } from '@kittycad/lib'\n\nasync function example() {\n const response = await payments.create_payment_information_for_user()\n if ('error_code' in response) throw response\n console.log(JSON.stringify(response, null, 2))\n}\n",
150+
"example": "import { payments } from '@kittycad/lib'\n\nasync function example() {\n const response = await payments.create_payment_information_for_user({\n body: {\n address: {\n city: 'The city component.',\n country: 'An ISO-3166 alpha-2 country code. Always uppercase.',\n state: 'The state component.',\n street1: 'The first street component.',\n street2: 'The second street component.',\n user_id: 'A UUID usually v4 or v7',\n zip: 'The zip component.',\n },\n name: 'The name of the customer.',\n phone: 'The phone for the customer.',\n },\n })\n if ('error_code' in response) throw response\n console.log(JSON.stringify(response, null, 2))\n}\n",
151151
"libDocsLink": ""
152152
}
153153
},
154154
{
155155
"op": "add",
156156
"path": "/paths/~1user~1payment/put/x-typescript",
157157
"value": {
158-
"example": "import { payments } from '@kittycad/lib'\n\nasync function example() {\n const response = await payments.update_payment_information_for_user()\n if ('error_code' in response) throw response\n console.log(JSON.stringify(response, null, 2))\n}\n",
158+
"example": "import { payments } from '@kittycad/lib'\n\nasync function example() {\n const response = await payments.update_payment_information_for_user({\n body: {\n address: {\n city: 'The city component.',\n country: 'An ISO-3166 alpha-2 country code. Always uppercase.',\n state: 'The state component.',\n street1: 'The first street component.',\n street2: 'The second street component.',\n user_id: 'A UUID usually v4 or v7',\n zip: 'The zip component.',\n },\n name: 'The name of the customer.',\n phone: 'The phone for the customer.',\n },\n })\n if ('error_code' in response) throw response\n console.log(JSON.stringify(response, null, 2))\n}\n",
159159
"libDocsLink": ""
160160
}
161161
},
@@ -243,7 +243,7 @@
243243
"op": "add",
244244
"path": "/paths/~1user/put/x-typescript",
245245
"value": {
246-
"example": "import { users } from '@kittycad/lib'\n\nasync function example() {\n const response = await users.update_user_self()\n if ('error_code' in response) throw response\n console.log(JSON.stringify(response, null, 2))\n}\n",
246+
"example": "import { users } from '@kittycad/lib'\n\nasync function example() {\n const response = await users.update_user_self({\n body: {\n company: \"The user's company.\",\n discord: \"The user's Discord handle.\",\n first_name: \"The user's first name.\",\n github: \"The user's GitHub handle.\",\n last_name: \"The user's last name.\",\n phone: \"The user's phone number.\",\n },\n })\n if ('error_code' in response) throw response\n console.log(JSON.stringify(response, null, 2))\n}\n",
247247
"libDocsLink": ""
248248
}
249249
},
@@ -411,7 +411,7 @@
411411
"op": "add",
412412
"path": "/paths/~1oauth2~1device~1confirm/post/x-typescript",
413413
"value": {
414-
"example": "import { oauth2 } from '@kittycad/lib'\n\nasync function example() {\n const response = await oauth2.device_auth_confirm()\n if ('error_code' in response) throw response\n console.log(JSON.stringify(response, null, 2))\n}\n",
414+
"example": "import { oauth2 } from '@kittycad/lib'\n\nasync function example() {\n const response = await oauth2.device_auth_confirm({\n body: { user_code: 'The user code.' },\n })\n if ('error_code' in response) throw response\n console.log(JSON.stringify(response, null, 2))\n}\n",
415415
"libDocsLink": ""
416416
}
417417
},
@@ -555,7 +555,7 @@
555555
"op": "add",
556556
"path": "/paths/~1ai~1text-to-cad~1{output_format}/post/x-typescript",
557557
"value": {
558-
"example": "import { ai } from '@kittycad/lib'\n\nasync function example() {\n const response = await ai.create_text_to_cad({ output_format: 'stl' })\n if ('error_code' in response) throw response\n console.log(JSON.stringify(response, null, 2))\n}\n",
558+
"example": "import { ai } from '@kittycad/lib'\n\nasync function example() {\n const response = await ai.create_text_to_cad({\n output_format: 'stl',\n body: { prompt: 'The prompt for the model.' },\n })\n if ('error_code' in response) throw response\n console.log(JSON.stringify(response, null, 2))\n}\n",
559559
"libDocsLink": ""
560560
}
561561
},

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@kittycad/lib",
3-
"version": "0.0.48",
3+
"version": "0.0.49",
44
"description": "Javascript library for KittyCAD API",
55
"type": "module",
66
"keywords": [
@@ -66,7 +66,7 @@
6666
"build:js": "rollup -c",
6767
"build:types": "tsc --emitDeclarationOnly",
6868
"build": "rimraf dist && npm run build:types && npm run build:js",
69-
"gen": "node --experimental-loader ts-node/esm.mjs ./src/modelsGen.ts && yarn fmt",
69+
"gen": "node --experimental-loader ts-node/esm.mjs ./src/modelsGen.ts && rm -rf __tests__/gen/modeling-modeling_commands_ws.test.ts && rm -rf src/api/modeling/modeling_commands_ws.ts && yarn fmt",
7070
"test": "vitest",
7171
"tsc": "tsc",
7272
"fmt": "prettier --config .prettierrc --write './src' './__tests__' './kittycad.ts.patch.json' './rollup.config.js'"

spec.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19313,7 +19313,7 @@
1931319313
"tags": [
1931419314
{
1931519315
"name": "ai",
19316-
"description": "AI uses machine learning to generate 3D meshes.",
19316+
"description": "AI uses machine learning to generate CAD models.",
1931719317
"externalDocs": {
1931819318
"url": "https://docs.kittycad.io/api/ai"
1931919319
}

src/api/ai/create_text_to_cad.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,22 @@ import {
33
TextToCad_type,
44
Error_type,
55
FileExportFormat_type,
6+
TextToCadCreateBody_type,
67
} from '../../models.js';
78
import { Client } from '../../client.js';
89

910
interface Create_text_to_cad_params {
1011
client?: Client;
1112
output_format: FileExportFormat_type;
13+
body: TextToCadCreateBody_type;
1214
}
1315

1416
type Create_text_to_cad_return = TextToCad_type | Error_type;
1517

1618
export default async function create_text_to_cad({
1719
client,
1820
output_format,
21+
body,
1922
}: Create_text_to_cad_params): Promise<Create_text_to_cad_return> {
2023
const url = `/ai/text-to-cad/${output_format}`;
2124
const urlBase = process?.env?.BASE_URL || 'https://api.kittycad.io';
@@ -29,6 +32,7 @@ export default async function create_text_to_cad({
2932
const fetchOptions = {
3033
method: 'POST',
3134
headers,
35+
body: JSON.stringify(body),
3236
};
3337
const response = await fetch(fullUrl, fetchOptions);
3438
const result = (await response.json()) as Create_text_to_cad_return;

0 commit comments

Comments
 (0)