Skip to content

Commit 6f36f41

Browse files
Update api spec (#215)
* YOYO NEW API SPEC! * Generated new lib --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent a6d2a73 commit 6f36f41

9 files changed

+403
-3
lines changed

__tests__/gen/meta-get_ipinfo.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { meta } from '../../src/index.js';
2+
3+
async function example() {
4+
const response = await meta.get_ipinfo();
5+
if ('error_code' in response) throw response;
6+
7+
return response;
8+
}
9+
10+
describe('Testing meta.get_ipinfo', () => {
11+
it('should be truthy or throw', async () => {
12+
expect(await example()).toBeTruthy();
13+
});
14+
});
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { users } from '../../src/index.js';
2+
3+
async function example() {
4+
const response = await users.get_oauth2_providers_for_user();
5+
if ('error_code' in response) throw response;
6+
7+
return response;
8+
}
9+
10+
describe('Testing users.get_oauth2_providers_for_user', () => {
11+
it('should be truthy or throw', async () => {
12+
expect(await example()).toBeTruthy();
13+
});
14+
});

__tests__/gen/users-update_user_self.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ async function example() {
77
discord: "The user's Discord handle.",
88
first_name: "The user's first name.",
99
github: "The user's GitHub handle.",
10+
image:
11+
"The image URL for the user. NOTE: If the user uses an OAuth2 provider, this will be overwritten by the provider's image URL when the user logs in next.",
1012
last_name: "The user's last name.",
1113
phone: "The user's phone number.",
1214
},

kittycad.ts.patch.json

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,14 @@
183183
"libDocsLink": ""
184184
}
185185
},
186+
{
187+
"op": "add",
188+
"path": "/paths/~1user~1oauth2~1providers/get/x-typescript",
189+
"value": {
190+
"example": "import { users } from '@kittycad/lib'\n\nasync function example() {\n const response = await users.get_oauth2_providers_for_user()\n if ('error_code' in response) throw response\n console.log(JSON.stringify(response, null, 2))\n}\n",
191+
"libDocsLink": ""
192+
}
193+
},
186194
{
187195
"op": "add",
188196
"path": "/paths/~1user~1extended/get/x-typescript",
@@ -251,7 +259,7 @@
251259
"op": "add",
252260
"path": "/paths/~1user/put/x-typescript",
253261
"value": {
254-
"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",
262+
"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 image: \"The image URL for the user. NOTE: If the user uses an OAuth2 provider, this will be overwritten by the provider's image URL when the user logs in next.\",\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",
255263
"libDocsLink": ""
256264
}
257265
},
@@ -751,6 +759,14 @@
751759
"libDocsLink": ""
752760
}
753761
},
762+
{
763+
"op": "add",
764+
"path": "/paths/~1_meta~1ipinfo/get/x-typescript",
765+
"value": {
766+
"example": "import { meta } from '@kittycad/lib'\n\nasync function example() {\n const response = await meta.get_ipinfo()\n if ('error_code' in response) throw response\n console.log(JSON.stringify(response, null, 2))\n}\n",
767+
"libDocsLink": ""
768+
}
769+
},
754770
{
755771
"op": "add",
756772
"path": "/paths/~1_meta~1info/get/x-typescript",

spec.json

Lines changed: 235 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,68 @@
132132
}
133133
}
134134
},
135+
"/_meta/ipinfo": {
136+
"get": {
137+
"tags": [
138+
"meta",
139+
"hidden"
140+
],
141+
"summary": "Get ip address information.",
142+
"operationId": "get_ipinfo",
143+
"responses": {
144+
"200": {
145+
"description": "successful operation",
146+
"headers": {
147+
"Access-Control-Allow-Credentials": {
148+
"description": "Access-Control-Allow-Credentials header.",
149+
"style": "simple",
150+
"required": true,
151+
"schema": {
152+
"type": "string"
153+
}
154+
},
155+
"Access-Control-Allow-Headers": {
156+
"description": "Access-Control-Allow-Headers header. This is a comma-separated list of headers.",
157+
"style": "simple",
158+
"required": true,
159+
"schema": {
160+
"type": "string"
161+
}
162+
},
163+
"Access-Control-Allow-Methods": {
164+
"description": "Access-Control-Allow-Methods header.",
165+
"style": "simple",
166+
"required": true,
167+
"schema": {
168+
"type": "string"
169+
}
170+
},
171+
"Access-Control-Allow-Origin": {
172+
"description": "Access-Control-Allow-Origin header.",
173+
"style": "simple",
174+
"required": true,
175+
"schema": {
176+
"type": "string"
177+
}
178+
}
179+
},
180+
"content": {
181+
"application/json": {
182+
"schema": {
183+
"$ref": "#/components/schemas/IpAddrInfo"
184+
}
185+
}
186+
}
187+
},
188+
"4XX": {
189+
"$ref": "#/components/responses/Error"
190+
},
191+
"5XX": {
192+
"$ref": "#/components/responses/Error"
193+
}
194+
}
195+
}
196+
},
135197
"/ai-prompts": {
136198
"get": {
137199
"tags": [
@@ -3956,7 +4018,7 @@
39564018
"orgs"
39574019
],
39584020
"summary": "Add a member to your org.",
3959-
"description": "This endpoint requires authentication by an org admin. It adds the specified member to the authenticated user's org.",
4021+
"description": "If the user exists, this will add them to your org. If they do not exist, this will create a new user and add them to your org.\nIn both cases the user gets an email that they have been added to the org.\nIf the user is already in your org, this will return a 400 and a message.\nIf the user is already in a different org, this will return a 400 and a message.\nThis endpoint requires authentication by an org admin. It adds the specified member to the authenticated user's org.",
39604022
"operationId": "create_org_member",
39614023
"requestBody": {
39624024
"content": {
@@ -7309,6 +7371,72 @@
73097371
}
73107372
}
73117373
},
7374+
"/user/oauth2/providers": {
7375+
"get": {
7376+
"tags": [
7377+
"users"
7378+
],
7379+
"summary": "Get the OAuth2 providers for your user.",
7380+
"description": "If this returns an empty array, then the user has not connected any OAuth2 providers and uses raw email authentication.\nThis endpoint requires authentication by any Zoo user. It gets the providers for the authenticated user.",
7381+
"operationId": "get_oauth2_providers_for_user",
7382+
"responses": {
7383+
"200": {
7384+
"description": "successful operation",
7385+
"headers": {
7386+
"Access-Control-Allow-Credentials": {
7387+
"description": "Access-Control-Allow-Credentials header.",
7388+
"style": "simple",
7389+
"required": true,
7390+
"schema": {
7391+
"type": "string"
7392+
}
7393+
},
7394+
"Access-Control-Allow-Headers": {
7395+
"description": "Access-Control-Allow-Headers header. This is a comma-separated list of headers.",
7396+
"style": "simple",
7397+
"required": true,
7398+
"schema": {
7399+
"type": "string"
7400+
}
7401+
},
7402+
"Access-Control-Allow-Methods": {
7403+
"description": "Access-Control-Allow-Methods header.",
7404+
"style": "simple",
7405+
"required": true,
7406+
"schema": {
7407+
"type": "string"
7408+
}
7409+
},
7410+
"Access-Control-Allow-Origin": {
7411+
"description": "Access-Control-Allow-Origin header.",
7412+
"style": "simple",
7413+
"required": true,
7414+
"schema": {
7415+
"type": "string"
7416+
}
7417+
}
7418+
},
7419+
"content": {
7420+
"application/json": {
7421+
"schema": {
7422+
"title": "Array_of_AccountProvider",
7423+
"type": "array",
7424+
"items": {
7425+
"$ref": "#/components/schemas/AccountProvider"
7426+
}
7427+
}
7428+
}
7429+
}
7430+
},
7431+
"4XX": {
7432+
"$ref": "#/components/responses/Error"
7433+
},
7434+
"5XX": {
7435+
"$ref": "#/components/responses/Error"
7436+
}
7437+
}
7438+
}
7439+
},
73127440
"/user/onboarding": {
73137441
"get": {
73147442
"tags": [
@@ -13967,6 +14095,102 @@
1396714095
}
1396814096
]
1396914097
},
14098+
"IpAddrInfo": {
14099+
"description": "Information about an ip address. Represents geographical and network-related information.",
14100+
"type": "object",
14101+
"properties": {
14102+
"asn": {
14103+
"nullable": true,
14104+
"description": "Autonomous System Number.",
14105+
"type": "integer",
14106+
"format": "int64"
14107+
},
14108+
"city": {
14109+
"nullable": true,
14110+
"description": "City name.",
14111+
"type": "string"
14112+
},
14113+
"continent_code": {
14114+
"nullable": true,
14115+
"description": "Continent code (e.g., \"EU\" for Europe).",
14116+
"type": "string"
14117+
},
14118+
"country": {
14119+
"nullable": true,
14120+
"description": "Country name.",
14121+
"type": "string"
14122+
},
14123+
"country_code": {
14124+
"nullable": true,
14125+
"description": "Two-letter country code (e.g., \"NL\" for Netherlands).",
14126+
"allOf": [
14127+
{
14128+
"$ref": "#/components/schemas/CountryCode"
14129+
}
14130+
]
14131+
},
14132+
"country_code3": {
14133+
"nullable": true,
14134+
"description": "Three-letter country code (e.g., \"NLD\" for Netherlands).",
14135+
"type": "string"
14136+
},
14137+
"ip": {
14138+
"title": "String",
14139+
"description": "IP address of the user.",
14140+
"default": "",
14141+
"type": "string",
14142+
"format": "ip"
14143+
},
14144+
"is_in_european_union": {
14145+
"nullable": true,
14146+
"description": "Flag indicating whether the country is in the European Union.",
14147+
"type": "boolean"
14148+
},
14149+
"latitude": {
14150+
"nullable": true,
14151+
"description": "Geographic latitude.",
14152+
"type": "number",
14153+
"format": "double"
14154+
},
14155+
"longitude": {
14156+
"nullable": true,
14157+
"description": "Geographic longitude.",
14158+
"type": "number",
14159+
"format": "double"
14160+
},
14161+
"offset": {
14162+
"nullable": true,
14163+
"description": "Time offset in seconds from UTC.",
14164+
"type": "integer",
14165+
"format": "int64"
14166+
},
14167+
"organization": {
14168+
"nullable": true,
14169+
"description": "Organization name (e.g., \"RIPE NCC\").",
14170+
"type": "string"
14171+
},
14172+
"postal_code": {
14173+
"nullable": true,
14174+
"description": "Postal code.",
14175+
"type": "string"
14176+
},
14177+
"region": {
14178+
"nullable": true,
14179+
"description": "Name of the region (e.g., \"North Holland\").",
14180+
"type": "string"
14181+
},
14182+
"region_code": {
14183+
"nullable": true,
14184+
"description": "Region code (e.g., \"NH\" for North Holland).",
14185+
"type": "string"
14186+
},
14187+
"timezone": {
14188+
"nullable": true,
14189+
"description": "Timezone (e.g., \"Europe/Amsterdam\").",
14190+
"type": "string"
14191+
}
14192+
}
14193+
},
1397014194
"Jetstream": {
1397114195
"description": "Jetstream information.",
1397214196
"type": "object",
@@ -21160,6 +21384,12 @@
2116021384
"description": "The user's GitHub handle.",
2116121385
"type": "string"
2116221386
},
21387+
"image": {
21388+
"title": "String",
21389+
"description": "The image URL for the user. NOTE: If the user uses an OAuth2 provider, this will be overwritten by the provider's image URL when the user logs in next.",
21390+
"type": "string",
21391+
"format": "uri"
21392+
},
2116321393
"last_name": {
2116421394
"description": "The user's last name.",
2116521395
"type": "string"
@@ -21171,7 +21401,10 @@
2117121401
"type": "string",
2117221402
"format": "phone"
2117321403
}
21174-
}
21404+
},
21405+
"required": [
21406+
"image"
21407+
]
2117521408
},
2117621409
"User": {
2117721410
"description": "A user.",

src/api/meta/get_ipinfo.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import fetch from 'node-fetch';
2+
import { IpAddrInfo_type, Error_type } from '../../models.js';
3+
import { Client } from '../../client.js';
4+
5+
interface Get_ipinfo_params {
6+
client?: Client;
7+
}
8+
9+
type Get_ipinfo_return = IpAddrInfo_type | Error_type;
10+
11+
export default async function get_ipinfo({
12+
client,
13+
}: Get_ipinfo_params = {}): Promise<Get_ipinfo_return> {
14+
const url = `/_meta/ipinfo`;
15+
const urlBase = process?.env?.BASE_URL || 'https://api.kittycad.io';
16+
const fullUrl = urlBase + url;
17+
const kittycadToken = client
18+
? client.token
19+
: process.env.KITTYCAD_TOKEN || '';
20+
const headers = {
21+
Authorization: `Bearer ${kittycadToken}`,
22+
};
23+
const fetchOptions = {
24+
method: 'GET',
25+
headers,
26+
};
27+
const response = await fetch(fullUrl, fetchOptions);
28+
const result = (await response.json()) as Get_ipinfo_return;
29+
return result;
30+
}

0 commit comments

Comments
 (0)