Skip to content

Commit

Permalink
fix body issues (#206)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
Irev-Dev and github-actions[bot] authored Dec 22, 2023
1 parent c4a0ee3 commit 5207069
Show file tree
Hide file tree
Showing 17 changed files with 154 additions and 89 deletions.
5 changes: 4 additions & 1 deletion __tests__/gen/ai-create_text_to_cad.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { ai } from '../../src/index.js';

async function example() {
const response = await ai.create_text_to_cad({ output_format: 'stl' });
const response = await ai.create_text_to_cad({
output_format: 'stl',
body: { prompt: 'The prompt for the model.' },
});
if ('error_code' in response) throw response;

return response;
Expand Down
20 changes: 0 additions & 20 deletions __tests__/gen/modeling-modeling_commands_ws.test.ts

This file was deleted.

4 changes: 3 additions & 1 deletion __tests__/gen/oauth2-device_auth_confirm.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { oauth2 } from '../../src/index.js';

async function example() {
const response = await oauth2.device_auth_confirm();
const response = await oauth2.device_auth_confirm({
body: { user_code: 'The user code.' },
});
if ('error_code' in response) throw response;

return response;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
import { payments } from '../../src/index.js';

async function example() {
const response = await payments.create_payment_information_for_user();
const response = await payments.create_payment_information_for_user({
body: {
address: {
city: 'The city component.',
country: 'An ISO-3166 alpha-2 country code. Always uppercase.',
state: 'The state component.',
street1: 'The first street component.',
street2: 'The second street component.',
user_id: 'A UUID usually v4 or v7',
zip: 'The zip component.',
},
name: 'The name of the customer.',
phone: 'The phone for the customer.',
},
});
if ('error_code' in response) throw response;

return response;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
import { payments } from '../../src/index.js';

async function example() {
const response = await payments.update_payment_information_for_user();
const response = await payments.update_payment_information_for_user({
body: {
address: {
city: 'The city component.',
country: 'An ISO-3166 alpha-2 country code. Always uppercase.',
state: 'The state component.',
street1: 'The first street component.',
street2: 'The second street component.',
user_id: 'A UUID usually v4 or v7',
zip: 'The zip component.',
},
name: 'The name of the customer.',
phone: 'The phone for the customer.',
},
});
if ('error_code' in response) throw response;

return response;
Expand Down
11 changes: 10 additions & 1 deletion __tests__/gen/users-update_user_self.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
import { users } from '../../src/index.js';

async function example() {
const response = await users.update_user_self();
const response = await users.update_user_self({
body: {
company: "The user's company.",
discord: "The user's Discord handle.",
first_name: "The user's first name.",
github: "The user's GitHub handle.",
last_name: "The user's last name.",
phone: "The user's phone number.",
},
});
if ('error_code' in response) throw response;

return response;
Expand Down
10 changes: 5 additions & 5 deletions kittycad.ts.patch.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,15 @@
"op": "add",
"path": "/paths/~1user~1payment/post/x-typescript",
"value": {
"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",
"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",
"libDocsLink": ""
}
},
{
"op": "add",
"path": "/paths/~1user~1payment/put/x-typescript",
"value": {
"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",
"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",
"libDocsLink": ""
}
},
Expand Down Expand Up @@ -243,7 +243,7 @@
"op": "add",
"path": "/paths/~1user/put/x-typescript",
"value": {
"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",
"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",
"libDocsLink": ""
}
},
Expand Down Expand Up @@ -411,7 +411,7 @@
"op": "add",
"path": "/paths/~1oauth2~1device~1confirm/post/x-typescript",
"value": {
"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",
"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",
"libDocsLink": ""
}
},
Expand Down Expand Up @@ -555,7 +555,7 @@
"op": "add",
"path": "/paths/~1ai~1text-to-cad~1{output_format}/post/x-typescript",
"value": {
"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",
"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",
"libDocsLink": ""
}
},
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kittycad/lib",
"version": "0.0.48",
"version": "0.0.49",
"description": "Javascript library for KittyCAD API",
"type": "module",
"keywords": [
Expand Down Expand Up @@ -66,7 +66,7 @@
"build:js": "rollup -c",
"build:types": "tsc --emitDeclarationOnly",
"build": "rimraf dist && npm run build:types && npm run build:js",
"gen": "node --experimental-loader ts-node/esm.mjs ./src/modelsGen.ts && yarn fmt",
"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",
"test": "vitest",
"tsc": "tsc",
"fmt": "prettier --config .prettierrc --write './src' './__tests__' './kittycad.ts.patch.json' './rollup.config.js'"
Expand Down
2 changes: 1 addition & 1 deletion spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -19313,7 +19313,7 @@
"tags": [
{
"name": "ai",
"description": "AI uses machine learning to generate 3D meshes.",
"description": "AI uses machine learning to generate CAD models.",
"externalDocs": {
"url": "https://docs.kittycad.io/api/ai"
}
Expand Down
4 changes: 4 additions & 0 deletions src/api/ai/create_text_to_cad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,22 @@ import {
TextToCad_type,
Error_type,
FileExportFormat_type,
TextToCadCreateBody_type,
} from '../../models.js';
import { Client } from '../../client.js';

interface Create_text_to_cad_params {
client?: Client;
output_format: FileExportFormat_type;
body: TextToCadCreateBody_type;
}

type Create_text_to_cad_return = TextToCad_type | Error_type;

export default async function create_text_to_cad({
client,
output_format,
body,
}: Create_text_to_cad_params): Promise<Create_text_to_cad_return> {
const url = `/ai/text-to-cad/${output_format}`;
const urlBase = process?.env?.BASE_URL || 'https://api.kittycad.io';
Expand All @@ -29,6 +32,7 @@ export default async function create_text_to_cad({
const fetchOptions = {
method: 'POST',
headers,
body: JSON.stringify(body),
};
const response = await fetch(fullUrl, fetchOptions);
const result = (await response.json()) as Create_text_to_cad_return;
Expand Down
40 changes: 0 additions & 40 deletions src/api/modeling/modeling_commands_ws.ts

This file was deleted.

7 changes: 5 additions & 2 deletions src/api/oauth2/device_auth_confirm.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import fetch from 'node-fetch';
import { Error_type } from '../../models.js';
import { Error_type, DeviceAuthVerifyParams_type } from '../../models.js';
import { Client } from '../../client.js';

interface Device_auth_confirm_params {
client?: Client;
body: DeviceAuthVerifyParams_type;
}

type Device_auth_confirm_return = Error_type;

export default async function device_auth_confirm({
client,
}: Device_auth_confirm_params = {}): Promise<Device_auth_confirm_return> {
body,
}: Device_auth_confirm_params): Promise<Device_auth_confirm_return> {
const url = `/oauth2/device/confirm`;
const urlBase = process?.env?.BASE_URL || 'https://api.kittycad.io';
const fullUrl = urlBase + url;
Expand All @@ -23,6 +25,7 @@ export default async function device_auth_confirm({
const fetchOptions = {
method: 'POST',
headers,
body: JSON.stringify(body),
};
const response = await fetch(fullUrl, fetchOptions);
const result = (await response.json()) as Device_auth_confirm_return;
Expand Down
7 changes: 5 additions & 2 deletions src/api/payments/create_payment_information_for_user.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import fetch from 'node-fetch';
import { Customer_type, Error_type } from '../../models.js';
import { Customer_type, Error_type, BillingInfo_type } from '../../models.js';
import { Client } from '../../client.js';

interface Create_payment_information_for_user_params {
client?: Client;
body: BillingInfo_type;
}

type Create_payment_information_for_user_return = Customer_type | Error_type;

export default async function create_payment_information_for_user({
client,
}: Create_payment_information_for_user_params = {}): Promise<Create_payment_information_for_user_return> {
body,
}: Create_payment_information_for_user_params): Promise<Create_payment_information_for_user_return> {
const url = `/user/payment`;
const urlBase = process?.env?.BASE_URL || 'https://api.kittycad.io';
const fullUrl = urlBase + url;
Expand All @@ -23,6 +25,7 @@ export default async function create_payment_information_for_user({
const fetchOptions = {
method: 'POST',
headers,
body: JSON.stringify(body),
};
const response = await fetch(fullUrl, fetchOptions);
const result =
Expand Down
7 changes: 5 additions & 2 deletions src/api/payments/update_payment_information_for_user.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import fetch from 'node-fetch';
import { Customer_type, Error_type } from '../../models.js';
import { Customer_type, Error_type, BillingInfo_type } from '../../models.js';
import { Client } from '../../client.js';

interface Update_payment_information_for_user_params {
client?: Client;
body: BillingInfo_type;
}

type Update_payment_information_for_user_return = Customer_type | Error_type;

export default async function update_payment_information_for_user({
client,
}: Update_payment_information_for_user_params = {}): Promise<Update_payment_information_for_user_return> {
body,
}: Update_payment_information_for_user_params): Promise<Update_payment_information_for_user_return> {
const url = `/user/payment`;
const urlBase = process?.env?.BASE_URL || 'https://api.kittycad.io';
const fullUrl = urlBase + url;
Expand All @@ -23,6 +25,7 @@ export default async function update_payment_information_for_user({
const fetchOptions = {
method: 'PUT',
headers,
body: JSON.stringify(body),
};
const response = await fetch(fullUrl, fetchOptions);
const result =
Expand Down
7 changes: 5 additions & 2 deletions src/api/users/update_user_self.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import fetch from 'node-fetch';
import { User_type, Error_type } from '../../models.js';
import { User_type, Error_type, UpdateUser_type } from '../../models.js';
import { Client } from '../../client.js';

interface Update_user_self_params {
client?: Client;
body: UpdateUser_type;
}

type Update_user_self_return = User_type | Error_type;

export default async function update_user_self({
client,
}: Update_user_self_params = {}): Promise<Update_user_self_return> {
body,
}: Update_user_self_params): Promise<Update_user_self_return> {
const url = `/user`;
const urlBase = process?.env?.BASE_URL || 'https://api.kittycad.io';
const fullUrl = urlBase + url;
Expand All @@ -23,6 +25,7 @@ export default async function update_user_self({
const fetchOptions = {
method: 'PUT',
headers,
body: JSON.stringify(body),
};
const response = await fetch(fullUrl, fetchOptions);
const result = (await response.json()) as Update_user_self_return;
Expand Down
Loading

0 comments on commit 5207069

Please sign in to comment.