kittycad / kittycad.ts Goto Github PK
View Code? Open in Web Editor NEWThe TypeScript API client for Zoo.
Home Page: https://zoo.dev/docs/api?lang=typescript
License: MIT License
The TypeScript API client for Zoo.
Home Page: https://zoo.dev/docs/api?lang=typescript
License: MIT License
I discovered this while creating this fix: KittyCAD/text-to-cad-ui#91.
VS Code shows that type as string
but it is actually string | undefined
because GMail users for example can have an account without a name.
When running npm install @kittycad/lib
the package.json file comes with
{
"dependencies": {
"@kittycad/lib": "^0.0.19"
}
}
but I have to manually add "type": "module"
to the package.json any time I download it. Can we have that in the file already when they run the npm command?
I haven't been able to use our API commands using require
or import
when the "type": "module"
is missing, so it seems like it's required?
We should export a JS library alongside our TS library, for JS customers who don't want to set up all the webpack/transpilation stuff locally. We're already setting this all up on our end, so we should use it.
When running yarn
I get the following warning:
warning "@kittycad/lib > [email protected]" has unmet peer dependency "@types/node@*".
Just want to make sure it doesn't break other use cases it might be nbd
This is consistent with all the other libraries, for backwards compatibility we should make KITTYCAD_TOKEN and KITTYCAD_API_TOKEN work
just a heads up @Irev-Dev in the latest spec, enums with descriptions on each variant are generateed differently
here is an example:
{
"description": "An account provider.",
"oneOf": [
{
"description": "The Google account provider.",
"enum": [
"google"
],
"type": "string"
},
{
"description": "The GitHub account provider.",
"enum": [
"github"
],
"type": "string"
}
]
}
which would become the following rust type for example
#[doc = "An account provider."]
#[derive(
serde :: Serialize,
serde :: Deserialize,
PartialEq,
Hash,
Debug,
Clone,
schemars :: JsonSchema,
tabled :: Tabled,
clap :: ValueEnum,
parse_display :: FromStr,
parse_display :: Display,
)]
pub enum AccountProvier {
#[doc = "The Google account provider."]
#[serde(rename = "google")]
#[display("google")]
Google,
#[doc = "The GitHub account provider."]
#[serde(rename = "github")]
#[display("github")]
Github,
}
what I am doing in the other libs is checking if its a oneof where each individual element is an enum of one.
This client lib is hardcoded to use kittycad.io, which is good default behaviour, but the automated tests for this lib should really go to dev.kittycad.io.
It's probably just a matter of having the template look to see if KITTYCAD_URL
is defined or not.
Adam and Jess shared these example actions that use tailscale
https://github.com/KittyCAD/api-deux/blob/main/.github/workflows/waypoint.yml#L35-L38
https://github.com/KittyCAD/api-deux/blob/main/.github/workflows/cargo-test.yml#L40
Some issues with the ts client, I think mostly related to ES modules and how the lib is bundled. Though not 100% sure on details at this point.
Something else to note is that while this repo has tests, what it's missing is tests for installing and running after an install from npm, adding samples to the litter box repo is on the TODO list anyway, so I might as samples as way of getting this verification.
This is a pretty good round up of the issues with bundling for npm with the current ecosystem
https://www.sensedeep.com/blog/posts/2021/how-to-create-single-source-npm-module.html
They probably need to be broken now, here's an exerpt from models.ts
xport type ModelingCmd_type =
| 'StartPath'
| {
MovePathPen: {
path: ModelingCmdId_type /* The ID of the command which created the path. */;
to: Point3d_type /* Where the path's pen should be. */;
};
}
// ...
the union of a string and an object means that user's can't be more specific like
type MoreSpecificType = ModelingCmd_type['MovePathPen'] // not possible
Here are some hacks we're already using in the app to get around this
type SketchModeCmd = Extract<
EngineCommand['cmd'],
{ DefaultCameraEnableSketchMode: any }
>['DefaultCameraEnableSketchMode'];
and
const command: Models['ModelingCmdReq_type'] = {/*...*/}
const cmd: = command.cmd
if (typeof cmd !== 'string' && "CameraDragMove" in cmd && this.lossyDataChannel) {
// do stuff with CameraDragMove cmd
}
These are good work around but wouldn't want other users of this lib to have to do trick typescript stuff like this.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.