Skip to content

Commit

Permalink
Update api spec (#274)
Browse files Browse the repository at this point in the history
* YOYO NEW API SPEC!

* Add UserIdentifier test data generator

* Add CodeLanguage test code generator

* Fix up file creation executor test generator

* Add shortlink deletion to expectedToFail

* Whoops, include the new example files

* Generated new lib

* 2.0.8

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: 49lf <[email protected]>
  • Loading branch information
3 people authored Oct 11, 2024
1 parent 692924e commit 79b5873
Show file tree
Hide file tree
Showing 36 changed files with 1,506 additions and 77 deletions.
2 changes: 1 addition & 1 deletion __tests__/gen/api-calls-list_api_calls_for_user.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { api_calls } from '../../src/index.js';

async function example() {
const response = await api_calls.list_api_calls_for_user({
id: 'string',
id: '31337',
limit: 7,
page_token: 'string',
sort_by: 'created_at_ascending',
Expand Down
2 changes: 1 addition & 1 deletion __tests__/gen/executor-create_file_execution.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ async function example() {
const response = await executor.create_file_execution({
lang: 'go',
output: 'string',
body: await fsp.readFile('./example', 'base64'),
body: await fsp.readFile('./example.go', 'base64'),
});
if ('error_code' in response) throw response;

Expand Down
18 changes: 18 additions & 0 deletions __tests__/gen/orgs-get_org_shortlinks.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { orgs } from '../../src/index.js';

async function example() {
const response = await orgs.get_org_shortlinks({
limit: 7,
page_token: 'string',
sort_by: 'created_at_ascending',
});
if ('error_code' in response) throw response;

return response;
}

describe('Testing orgs.get_org_shortlinks', () => {
it('should be truthy or throw', async () => {
expect(await example()).toBeTruthy();
});
});
2 changes: 1 addition & 1 deletion __tests__/gen/payments-create_org_subscription.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { payments } from '../../src/index.js';

async function example() {
const response = await payments.create_org_subscription({
body: { modeling_app: 'team' },
body: { modeling_app: 'team', pay_annually: true },
});
if ('error_code' in response) throw response;

Expand Down
2 changes: 1 addition & 1 deletion __tests__/gen/payments-create_user_subscription.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { payments } from '../../src/index.js';

async function example() {
const response = await payments.create_user_subscription({
body: { modeling_app: 'free' },
body: { modeling_app: 'free', pay_annually: true },
});
if ('error_code' in response) throw response;

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

async function example() {
const response = await payments.get_payment_balance_for_any_user({
id: '00000000-0000-0000-0000-000000000000',
id: '31337',
});
if ('error_code' in response) throw response;

Expand Down
2 changes: 1 addition & 1 deletion __tests__/gen/payments-update_org_subscription.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { payments } from '../../src/index.js';

async function example() {
const response = await payments.update_org_subscription({
body: { modeling_app: 'team' },
body: { modeling_app: 'team', pay_annually: true },
});
if ('error_code' in response) throw response;

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

async function example() {
const response = await payments.update_payment_balance_for_any_user({
id: '00000000-0000-0000-0000-000000000000',
id: '31337',
body: {
monthly_credits_remaining: 7,
pre_pay_cash_remaining: 7,
Expand Down
2 changes: 1 addition & 1 deletion __tests__/gen/payments-update_user_subscription.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { payments } from '../../src/index.js';

async function example() {
const response = await payments.update_user_subscription({
body: { modeling_app: 'free' },
body: { modeling_app: 'free', pay_annually: true },
});
if ('error_code' in response) throw response;

Expand Down
21 changes: 21 additions & 0 deletions __tests__/gen/users-create_user_shortlink.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { users } from '../../src/index.js';

async function example() {
const response = await users.create_user_shortlink({
body: {
password:
'The password for the shortlink, if you want to restrict access to it. This can only be set if your subscription allows for it. Otherwise, it will return an error. When you access the link it will be required to enter this password through basic auth. The username will be `{anything}` and the password will be the password you set here.',
restrict_to_org: true,
url: 'The URL to redirect back to.',
},
});
if ('error_code' in response) throw response;

return response;
}

describe('Testing users.create_user_shortlink', () => {
it('should be truthy or throw', async () => {
expect(await example()).toBeTruthy();
});
});
18 changes: 18 additions & 0 deletions __tests__/gen/users-delete_user_shortlink.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { users } from '../../src/index.js';

async function example() {
const response = await users.delete_user_shortlink({ key: 'string' });
if ('error_code' in response) throw response;

return response;
}

describe('Testing users.delete_user_shortlink', () => {
it('should be truthy or throw', async () => {
try {
await example();
} catch (err) {
expect(err).toBeTruthy(); // eslint-disable-line jest/no-conditional-expect
}
});
});
2 changes: 1 addition & 1 deletion __tests__/gen/users-get_user.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { users } from '../../src/index.js';

async function example() {
const response = await users.get_user({ id: 'string' });
const response = await users.get_user({ id: '31337' });
if ('error_code' in response) throw response;

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

async function example() {
const response = await users.get_user_extended({ id: 'string' });
const response = await users.get_user_extended({ id: '31337' });
if ('error_code' in response) throw response;

return response;
Expand Down
18 changes: 18 additions & 0 deletions __tests__/gen/users-get_user_shortlinks.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { users } from '../../src/index.js';

async function example() {
const response = await users.get_user_shortlinks({
limit: 7,
page_token: 'string',
sort_by: 'created_at_ascending',
});
if ('error_code' in response) throw response;

return response;
}

describe('Testing users.get_user_shortlinks', () => {
it('should be truthy or throw', async () => {
expect(await example()).toBeTruthy();
});
});
21 changes: 21 additions & 0 deletions __tests__/gen/users-update_user_shortlink.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { users } from '../../src/index.js';

async function example() {
const response = await users.update_user_shortlink({
key: 'string',
body: {
password:
'The password for the shortlink, if you want to restrict access to it. This can only be set if your subscription allows for it. Otherwise, it will return an error. When you access the link it will be required to enter this password through basic auth. The username will be `{anything}` and the password will be the password you set here.',
restrict_to_org: true,
},
});
if ('error_code' in response) throw response;

return response;
}

describe('Testing users.update_user_shortlink', () => {
it('should be truthy or throw', async () => {
expect(await example()).toBeTruthy();
});
});
2 changes: 1 addition & 1 deletion example
Original file line number Diff line number Diff line change
@@ -1 +1 @@
example
console.log("ok")
5 changes: 5 additions & 0 deletions example.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package main
import "fmt"
func main() {
fmt.Println("lee was here")
}
1 change: 1 addition & 0 deletions example.node
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log('lee was here')
1 change: 1 addition & 0 deletions example.python
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print "lee was here"
60 changes: 50 additions & 10 deletions kittycad.ts.patch.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,39 +19,39 @@
"op": "add",
"path": "/paths/~1users~1{id}~1payment~1balance/put/x-typescript",
"value": {
"example": "import { payments } from '@kittycad/lib'\n\nasync function example() {\n const response = await payments.update_payment_balance_for_any_user({\n id: '00000000-0000-0000-0000-000000000000',\n body: {\n monthly_credits_remaining: 7,\n pre_pay_cash_remaining: 7,\n pre_pay_credits_remaining: 7,\n },\n })\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_balance_for_any_user({\n id: '31337',\n body: {\n monthly_credits_remaining: 7,\n pre_pay_cash_remaining: 7,\n pre_pay_credits_remaining: 7,\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/~1users~1{id}~1payment~1balance/get/x-typescript",
"value": {
"example": "import { payments } from '@kittycad/lib'\n\nasync function example() {\n const response = await payments.get_payment_balance_for_any_user({\n id: '00000000-0000-0000-0000-000000000000',\n })\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.get_payment_balance_for_any_user({\n id: '31337',\n })\n if ('error_code' in response) throw response\n console.log(JSON.stringify(response, null, 2))\n}\n",
"libDocsLink": ""
}
},
{
"op": "add",
"path": "/paths/~1users~1{id}~1api-calls/get/x-typescript",
"value": {
"example": "import { api_calls } from '@kittycad/lib'\n\nasync function example() {\n const response = await api_calls.list_api_calls_for_user({\n id: 'string',\n limit: 7,\n page_token: 'string',\n sort_by: 'created_at_ascending',\n })\n if ('error_code' in response) throw response\n console.log(JSON.stringify(response, null, 2))\n}\n",
"example": "import { api_calls } from '@kittycad/lib'\n\nasync function example() {\n const response = await api_calls.list_api_calls_for_user({\n id: '31337',\n limit: 7,\n page_token: 'string',\n sort_by: 'created_at_ascending',\n })\n if ('error_code' in response) throw response\n console.log(JSON.stringify(response, null, 2))\n}\n",
"libDocsLink": ""
}
},
{
"op": "add",
"path": "/paths/~1users~1{id}/get/x-typescript",
"value": {
"example": "import { users } from '@kittycad/lib'\n\nasync function example() {\n const response = await users.get_user({ id: 'string' })\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.get_user({ id: '31337' })\n if ('error_code' in response) throw response\n console.log(JSON.stringify(response, null, 2))\n}\n",
"libDocsLink": ""
}
},
{
"op": "add",
"path": "/paths/~1users-extended~1{id}/get/x-typescript",
"value": {
"example": "import { users } from '@kittycad/lib'\n\nasync function example() {\n const response = await users.get_user_extended({ id: 'string' })\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.get_user_extended({ id: '31337' })\n if ('error_code' in response) throw response\n console.log(JSON.stringify(response, null, 2))\n}\n",
"libDocsLink": ""
}
},
Expand Down Expand Up @@ -95,6 +95,38 @@
"libDocsLink": ""
}
},
{
"op": "add",
"path": "/paths/~1user~1shortlinks~1{key}/delete/x-typescript",
"value": {
"example": "import { users } from '@kittycad/lib'\n\nasync function example() {\n const response = await users.delete_user_shortlink({ key: 'string' })\n if ('error_code' in response) throw response\n console.log(JSON.stringify(response, null, 2))\n}\n",
"libDocsLink": ""
}
},
{
"op": "add",
"path": "/paths/~1user~1shortlinks~1{key}/put/x-typescript",
"value": {
"example": "import { users } from '@kittycad/lib'\n\nasync function example() {\n const response = await users.update_user_shortlink({\n key: 'string',\n body: {\n password:\n 'The password for the shortlink, if you want to restrict access to it. This can only be set if your subscription allows for it. Otherwise, it will return an error. When you access the link it will be required to enter this password through basic auth. The username will be `{anything}` and the password will be the password you set here.',\n restrict_to_org: true,\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~1shortlinks/post/x-typescript",
"value": {
"example": "import { users } from '@kittycad/lib'\n\nasync function example() {\n const response = await users.create_user_shortlink({\n body: {\n password:\n 'The password for the shortlink, if you want to restrict access to it. This can only be set if your subscription allows for it. Otherwise, it will return an error. When you access the link it will be required to enter this password through basic auth. The username will be `{anything}` and the password will be the password you set here.',\n restrict_to_org: true,\n url: 'The URL to redirect back to.',\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~1shortlinks/get/x-typescript",
"value": {
"example": "import { users } from '@kittycad/lib'\n\nasync function example() {\n const response = await users.get_user_shortlinks({\n limit: 7,\n page_token: 'string',\n sort_by: 'created_at_ascending',\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~1session~1{token}/get/x-typescript",
Expand Down Expand Up @@ -131,15 +163,15 @@
"op": "add",
"path": "/paths/~1user~1payment~1subscriptions/post/x-typescript",
"value": {
"example": "import { payments } from '@kittycad/lib'\n\nasync function example() {\n const response = await payments.create_user_subscription({\n body: { modeling_app: 'free' },\n })\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_user_subscription({\n body: { modeling_app: 'free', pay_annually: true },\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~1subscriptions/put/x-typescript",
"value": {
"example": "import { payments } from '@kittycad/lib'\n\nasync function example() {\n const response = await payments.update_user_subscription({\n body: { modeling_app: 'free' },\n })\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_user_subscription({\n body: { modeling_app: 'free', pay_annually: true },\n })\n if ('error_code' in response) throw response\n console.log(JSON.stringify(response, null, 2))\n}\n",
"libDocsLink": ""
}
},
Expand Down Expand Up @@ -495,6 +527,14 @@
"libDocsLink": ""
}
},
{
"op": "add",
"path": "/paths/~1org~1shortlinks/get/x-typescript",
"value": {
"example": "import { orgs } from '@kittycad/lib'\n\nasync function example() {\n const response = await orgs.get_org_shortlinks({\n limit: 7,\n page_token: 'string',\n sort_by: 'created_at_ascending',\n })\n if ('error_code' in response) throw response\n console.log(JSON.stringify(response, null, 2))\n}\n",
"libDocsLink": ""
}
},
{
"op": "add",
"path": "/paths/~1org~1service-accounts~1{token}/delete/x-typescript",
Expand Down Expand Up @@ -587,15 +627,15 @@
"op": "add",
"path": "/paths/~1org~1payment~1subscriptions/post/x-typescript",
"value": {
"example": "import { payments } from '@kittycad/lib'\n\nasync function example() {\n const response = await payments.create_org_subscription({\n body: { modeling_app: 'team' },\n })\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_org_subscription({\n body: { modeling_app: 'team', pay_annually: true },\n })\n if ('error_code' in response) throw response\n console.log(JSON.stringify(response, null, 2))\n}\n",
"libDocsLink": ""
}
},
{
"op": "add",
"path": "/paths/~1org~1payment~1subscriptions/put/x-typescript",
"value": {
"example": "import { payments } from '@kittycad/lib'\n\nasync function example() {\n const response = await payments.update_org_subscription({\n body: { modeling_app: 'team' },\n })\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_org_subscription({\n body: { modeling_app: 'team', pay_annually: true },\n })\n if ('error_code' in response) throw response\n console.log(JSON.stringify(response, null, 2))\n}\n",
"libDocsLink": ""
}
},
Expand Down Expand Up @@ -899,7 +939,7 @@
"op": "add",
"path": "/paths/~1file~1execute~1{lang}/post/x-typescript",
"value": {
"example": "import fsp from 'fs/promises'\nimport { executor } from '@kittycad/lib'\n\nasync function example() {\n const response = await executor.create_file_execution({\n lang: 'go',\n output: 'string',\n body: await fsp.readFile('./example', 'base64'),\n })\n if ('error_code' in response) throw response\n console.log(JSON.stringify(response, null, 2))\n}\n",
"example": "import fsp from 'fs/promises'\nimport { executor } from '@kittycad/lib'\n\nasync function example() {\n const response = await executor.create_file_execution({\n lang: 'go',\n output: 'string',\n body: await fsp.readFile('./example.go', 'base64'),\n })\n if ('error_code' in response) throw response\n console.log(JSON.stringify(response, null, 2))\n}\n",
"libDocsLink": ""
}
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kittycad/lib",
"version": "2.0.7",
"version": "2.0.8",
"description": "Javascript library for KittyCAD API",
"type": "module",
"keywords": [
Expand Down
Loading

0 comments on commit 79b5873

Please sign in to comment.