diff --git a/.github/workflows/update-api-spec.yml b/.github/workflows/update-api-spec.yml index d989d03..882b76a 100644 --- a/.github/workflows/update-api-spec.yml +++ b/.github/workflows/update-api-spec.yml @@ -18,7 +18,7 @@ jobs: - uses: actions/setup-node@v4 with: node-version: "18" - - working-directory: "./packages/openapi-gen-ts" + - working-directory: "./oxide-openapi-gen-ts" run: 'npm install' - run: ./tools/gen.sh - uses: EndBug/add-and-commit@v9 diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 99586ba..b7e2bab 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -19,16 +19,16 @@ jobs: - uses: actions/setup-node@v4 with: node-version: "18" - - working-directory: "./packages/openapi-gen-ts" + - working-directory: "./oxide-openapi-gen-ts" run: npm install - name: Generate client run: "./tools/gen.sh" - name: Typecheck - working-directory: "./packages/openapi-gen-ts" + working-directory: "./oxide-openapi-gen-ts" run: npm run tsc - name: Lint - working-directory: "./packages/openapi-gen-ts" + working-directory: "./oxide-openapi-gen-ts" run: npm run lint - name: Test - working-directory: "./packages/openapi-gen-ts" + working-directory: "./oxide-openapi-gen-ts" run: npm test run diff --git a/README.md b/README.md index 243b11f..65b8c3e 100644 --- a/README.md +++ b/README.md @@ -9,12 +9,12 @@ any other specs and is unlikely to handle them well. |Package| Description| |---|---| -| [`@oxide/openapi-gen-ts`](./packages/openapi-gen-ts) | TypeScript OpenAPI client generator | -| [`@oxide/api`](./packages/api) | The client generated for the Omicron commit specified in `OMICRON_VERSION` | +| [`@oxide/openapi-gen-ts`](./oxide-openapi-gen-ts) | TypeScript OpenAPI client generator | +| [`@oxide/api`](./oxide-api) | The client generated for the Omicron commit specified in `OMICRON_VERSION` | ## Using the API client -See the [README](./package/api/README.md) for the `@oxide/api` package. +See the [README](./oxide-api/README.md) for the `@oxide/api` package. ## Contributing diff --git a/packages/api/README.md b/oxide-api/README.md similarity index 85% rename from packages/api/README.md rename to oxide-api/README.md index bfd6c0c..71b3bd6 100644 --- a/packages/api/README.md +++ b/oxide-api/README.md @@ -41,14 +41,17 @@ const result = await api.methods.projectList({}) if (result.type === "success") { console.log(result.data.items.map((p) => p.name)) -} else if (result.type === "error") { - console.log(result.data.errorCode) - console.log(result.data.message) -} else { // result.type === client_error - console.log(result.error) } ``` +## How does it all work? + +### Methods + +### Request bodies + +### Responses: `ApiResult` + ## Other stuff in the package Most likely nobody but us wants this, and we should take it out of the npm package. diff --git a/packages/api/package-lock.json b/oxide-api/package-lock.json similarity index 100% rename from packages/api/package-lock.json rename to oxide-api/package-lock.json diff --git a/packages/api/package.json b/oxide-api/package.json similarity index 100% rename from packages/api/package.json rename to oxide-api/package.json diff --git a/packages/api/src/Api.ts b/oxide-api/src/Api.ts similarity index 100% rename from packages/api/src/Api.ts rename to oxide-api/src/Api.ts diff --git a/packages/api/src/http-client.ts b/oxide-api/src/http-client.ts similarity index 100% rename from packages/api/src/http-client.ts rename to oxide-api/src/http-client.ts diff --git a/packages/api/src/msw-handlers.ts b/oxide-api/src/msw-handlers.ts similarity index 100% rename from packages/api/src/msw-handlers.ts rename to oxide-api/src/msw-handlers.ts diff --git a/packages/api/src/type-test.ts b/oxide-api/src/type-test.ts similarity index 100% rename from packages/api/src/type-test.ts rename to oxide-api/src/type-test.ts diff --git a/packages/api/src/util.ts b/oxide-api/src/util.ts similarity index 100% rename from packages/api/src/util.ts rename to oxide-api/src/util.ts diff --git a/packages/api/src/validate.ts b/oxide-api/src/validate.ts similarity index 100% rename from packages/api/src/validate.ts rename to oxide-api/src/validate.ts diff --git a/packages/api/tsconfig.json b/oxide-api/tsconfig.json similarity index 100% rename from packages/api/tsconfig.json rename to oxide-api/tsconfig.json diff --git a/packages/openapi-gen-ts/.eslintrc.cjs b/oxide-openapi-gen-ts/.eslintrc.cjs similarity index 100% rename from packages/openapi-gen-ts/.eslintrc.cjs rename to oxide-openapi-gen-ts/.eslintrc.cjs diff --git a/packages/openapi-gen-ts/README.md b/oxide-openapi-gen-ts/README.md similarity index 97% rename from packages/openapi-gen-ts/README.md rename to oxide-openapi-gen-ts/README.md index 371cb42..3684e99 100644 --- a/packages/openapi-gen-ts/README.md +++ b/oxide-openapi-gen-ts/README.md @@ -40,7 +40,7 @@ one, so writing one was easier than existing generators made it look. ./tools/gen.sh ``` -The TypeScript client code will be written to `packages/api/src`. +The TypeScript client code will be written to `oxide-api/src`. ## Publishing to npm diff --git a/packages/openapi-gen-ts/package-lock.json b/oxide-openapi-gen-ts/package-lock.json similarity index 100% rename from packages/openapi-gen-ts/package-lock.json rename to oxide-openapi-gen-ts/package-lock.json diff --git a/packages/openapi-gen-ts/package.json b/oxide-openapi-gen-ts/package.json similarity index 97% rename from packages/openapi-gen-ts/package.json rename to oxide-openapi-gen-ts/package.json index 211b53a..7ea1933 100644 --- a/packages/openapi-gen-ts/package.json +++ b/oxide-openapi-gen-ts/package.json @@ -34,7 +34,7 @@ "scripts": { "build": "tsup-node && mkdir -p dist/static/ && cp src/client/static/util.ts dist/static/ && cp src/client/static/http-client.ts dist/static/", "lint": "eslint .", - "pretest": "../../tools/gen.sh", + "pretest": "../tools/gen.sh", "test": "vitest", "test:ui": "vitest --ui", "tsc": "tsc" diff --git a/packages/openapi-gen-ts/src/client/api.ts b/oxide-openapi-gen-ts/src/client/api.ts similarity index 100% rename from packages/openapi-gen-ts/src/client/api.ts rename to oxide-openapi-gen-ts/src/client/api.ts diff --git a/packages/openapi-gen-ts/src/client/base.ts b/oxide-openapi-gen-ts/src/client/base.ts similarity index 100% rename from packages/openapi-gen-ts/src/client/base.ts rename to oxide-openapi-gen-ts/src/client/base.ts diff --git a/packages/openapi-gen-ts/src/client/msw-handlers.ts b/oxide-openapi-gen-ts/src/client/msw-handlers.ts similarity index 100% rename from packages/openapi-gen-ts/src/client/msw-handlers.ts rename to oxide-openapi-gen-ts/src/client/msw-handlers.ts diff --git a/packages/openapi-gen-ts/src/client/static/README.md b/oxide-openapi-gen-ts/src/client/static/README.md similarity index 100% rename from packages/openapi-gen-ts/src/client/static/README.md rename to oxide-openapi-gen-ts/src/client/static/README.md diff --git a/packages/openapi-gen-ts/src/client/static/http-client.test.ts b/oxide-openapi-gen-ts/src/client/static/http-client.test.ts similarity index 100% rename from packages/openapi-gen-ts/src/client/static/http-client.test.ts rename to oxide-openapi-gen-ts/src/client/static/http-client.test.ts diff --git a/packages/openapi-gen-ts/src/client/static/http-client.ts b/oxide-openapi-gen-ts/src/client/static/http-client.ts similarity index 100% rename from packages/openapi-gen-ts/src/client/static/http-client.ts rename to oxide-openapi-gen-ts/src/client/static/http-client.ts diff --git a/packages/openapi-gen-ts/src/client/static/util.test.ts b/oxide-openapi-gen-ts/src/client/static/util.test.ts similarity index 100% rename from packages/openapi-gen-ts/src/client/static/util.test.ts rename to oxide-openapi-gen-ts/src/client/static/util.test.ts diff --git a/packages/openapi-gen-ts/src/client/static/util.ts b/oxide-openapi-gen-ts/src/client/static/util.ts similarity index 100% rename from packages/openapi-gen-ts/src/client/static/util.ts rename to oxide-openapi-gen-ts/src/client/static/util.ts diff --git a/packages/openapi-gen-ts/src/client/type-tests.ts b/oxide-openapi-gen-ts/src/client/type-tests.ts similarity index 100% rename from packages/openapi-gen-ts/src/client/type-tests.ts rename to oxide-openapi-gen-ts/src/client/type-tests.ts diff --git a/packages/openapi-gen-ts/src/client/zodValidators.ts b/oxide-openapi-gen-ts/src/client/zodValidators.ts similarity index 100% rename from packages/openapi-gen-ts/src/client/zodValidators.ts rename to oxide-openapi-gen-ts/src/client/zodValidators.ts diff --git a/packages/openapi-gen-ts/src/index.ts b/oxide-openapi-gen-ts/src/index.ts similarity index 100% rename from packages/openapi-gen-ts/src/index.ts rename to oxide-openapi-gen-ts/src/index.ts diff --git a/packages/openapi-gen-ts/src/io.ts b/oxide-openapi-gen-ts/src/io.ts similarity index 100% rename from packages/openapi-gen-ts/src/io.ts rename to oxide-openapi-gen-ts/src/io.ts diff --git a/packages/openapi-gen-ts/src/schema/base.ts b/oxide-openapi-gen-ts/src/schema/base.ts similarity index 100% rename from packages/openapi-gen-ts/src/schema/base.ts rename to oxide-openapi-gen-ts/src/schema/base.ts diff --git a/packages/openapi-gen-ts/src/schema/types.ts b/oxide-openapi-gen-ts/src/schema/types.ts similarity index 100% rename from packages/openapi-gen-ts/src/schema/types.ts rename to oxide-openapi-gen-ts/src/schema/types.ts diff --git a/packages/openapi-gen-ts/src/schema/zod.test.ts b/oxide-openapi-gen-ts/src/schema/zod.test.ts similarity index 100% rename from packages/openapi-gen-ts/src/schema/zod.test.ts rename to oxide-openapi-gen-ts/src/schema/zod.test.ts diff --git a/packages/openapi-gen-ts/src/schema/zod.ts b/oxide-openapi-gen-ts/src/schema/zod.ts similarity index 100% rename from packages/openapi-gen-ts/src/schema/zod.ts rename to oxide-openapi-gen-ts/src/schema/zod.ts diff --git a/packages/openapi-gen-ts/src/util.test.ts b/oxide-openapi-gen-ts/src/util.test.ts similarity index 100% rename from packages/openapi-gen-ts/src/util.test.ts rename to oxide-openapi-gen-ts/src/util.test.ts diff --git a/packages/openapi-gen-ts/src/util.ts b/oxide-openapi-gen-ts/src/util.ts similarity index 100% rename from packages/openapi-gen-ts/src/util.ts rename to oxide-openapi-gen-ts/src/util.ts diff --git a/packages/openapi-gen-ts/tsconfig.json b/oxide-openapi-gen-ts/tsconfig.json similarity index 100% rename from packages/openapi-gen-ts/tsconfig.json rename to oxide-openapi-gen-ts/tsconfig.json diff --git a/tools/gen.sh b/tools/gen.sh index 6754ff9..bf5bec3 100755 --- a/tools/gen.sh +++ b/tools/gen.sh @@ -11,7 +11,7 @@ set -o pipefail ROOT_DIR="$(dirname "$0")/.." OMICRON_SHA=$(cat "$ROOT_DIR/OMICRON_VERSION") -DEST_DIR="$ROOT_DIR/packages/api/src" +DEST_DIR="$ROOT_DIR/oxide-api/src" SPEC_URL="https://raw.githubusercontent.com/oxidecomputer/omicron/$OMICRON_SHA/openapi/nexus.json" SPEC_FILE="./spec.json" @@ -19,5 +19,5 @@ SPEC_FILE="./spec.json" # TODO: we could get rid of this DL if a test didn't rely on it curl --fail "$SPEC_URL" -o $SPEC_FILE -npx tsx "$ROOT_DIR/packages/openapi-gen-ts/src/index.ts" $SPEC_FILE $DEST_DIR +npx tsx "$ROOT_DIR/oxide-openapi-gen-ts/src/index.ts" $SPEC_FILE $DEST_DIR npx prettier --write --log-level error "$DEST_DIR"