Skip to content

Commit

Permalink
(chore, internal): move openapi-ir to use local typescript sdk code…
Browse files Browse the repository at this point in the history
…gen (#3033)

* setup local gen

* move openapi ir gen to snapshot

* fix

* yarn lint:monorepo:fix

* remove ms from datetime

* prettier

* fix tests

* eslint ignore sdk
  • Loading branch information
dsinghvi authored Feb 22, 2024
1 parent 9c2dd78 commit cd900a3
Show file tree
Hide file tree
Showing 434 changed files with 249,957 additions and 266,324 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ generated
bundle.c?js
.pnp*
packages/ir-sdk/**
packages/cli/openapi-ir-sdk/**
packages/seed/**
generators/typescript/utils/core-utilities/**
seed/**
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ir-check.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: ir
name: IR Check

on:
workflow_dispatch:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ir-publish.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: ir-publish
name: IR Publish

on:
workflow_dispatch:
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/openapi-ir-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: OpenAPI IR Check

on:
workflow_dispatch:
pull_request:
paths:
- "packages/cli/openapi-ir-sdk/fern/**"
branches:
- main
push:
paths:
- "packages/cli/openapi-ir-sdk/fern/**"
branches:
- main

jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Fern
run: npm install -g fern-api

- name: Check IR Definitions
run: |
cd packages/cli/openapi-ir-sdk
fern check
- name: Check IR Definitions
env:
FERN_TOKEN: dummy
run: |
cd packages/cli/openapi-ir-sdk
yarn generate
- name: Ensure no changes to git-tracked files
run: git --no-pager diff --exit-code
53 changes: 39 additions & 14 deletions .pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Binary file not shown.
12 changes: 0 additions & 12 deletions fern/apis/openapi-ir/generators.yml

This file was deleted.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"demo-setup": "yarn workspace @fern-api/demo-setup dist:cli && node $(yarn workspace @fern-api/demo-setup bin demo-setup)",
"seed:local": "yarn workspace @fern-api/seed-cli dist:cli && node $(yarn workspace @fern-api/seed-cli bin seed)",
"ir:generate": "yarn workspace @fern-api/ir-sdk generate",
"openapi-ir:generate": "yarn workspace @fern-api/openapi-ir-sdk generate",
"seed-config:generate": "yarn workspace @fern-api/seed-cli generate"
},
"devDependencies": {
Expand Down Expand Up @@ -100,6 +101,7 @@
}
},
"dependencies": {
"terminal-link": "^3.0.0"
"terminal-link": "^3.0.0",
"workspace": "^0.0.1-preview.1"
}
}
1 change: 1 addition & 0 deletions packages/cli/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"@fern-api/login": "workspace:*",
"@fern-api/manage-generator": "workspace:*",
"@fern-api/mock": "workspace:*",
"@fern-api/openapi-ir-sdk": "workspace:*",
"@fern-api/openapi-ir-to-fern": "workspace:*",
"@fern-api/posthog-manager": "workspace:*",
"@fern-api/project-configuration": "workspace:*",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { AbsoluteFilePath, stringifyLargeObject } from "@fern-api/fs-utils";
import { serialization } from "@fern-api/openapi-ir-sdk";
import { Project } from "@fern-api/project-loader";
import { getOpenAPIIRFromOpenAPIWorkspace } from "@fern-api/workspace-loader";
import { writeFile } from "fs/promises";
Expand All @@ -25,7 +26,10 @@ export async function generateOpenAPIIrForWorkspaces({
const openAPIIr = getOpenAPIIRFromOpenAPIWorkspace(workspace, context);

const irOutputFilePath = path.resolve(irFilepath);
await writeFile(irOutputFilePath, await stringifyLargeObject(openAPIIr, { pretty: true }));
const openApiIrJson = await serialization.OpenApiIntermediateRepresentation.jsonOrThrow(openAPIIr, {
skipValidation: true
});
await writeFile(irOutputFilePath, await stringifyLargeObject(openApiIrJson, { pretty: true }));
context.logger.info(`Wrote IR to ${irOutputFilePath}`);
});
})
Expand Down
1 change: 1 addition & 0 deletions packages/cli/cli/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
{ "path": "../logger" },
{ "path": "../login" },
{ "path": "../mock" },
{ "path": "../openapi-ir-sdk" },
{ "path": "../openapi-ir-to-fern" },
{ "path": "../posthog-manager" },
{ "path": "../project-loader" },
Expand Down
1 change: 1 addition & 0 deletions packages/cli/openapi-ir-sdk/.depcheckrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "ignores": ["@types/jest", "@types/node"], "ignore-patterns": ["lib"] }
11 changes: 11 additions & 0 deletions packages/cli/openapi-ir-sdk/.mrlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"type": "library",
"private": true,
"rules": {
"package-json": {
"scripts": {
"generate": "fern generate --local"
}
}
}
}
1 change: 1 addition & 0 deletions packages/cli/openapi-ir-sdk/.prettierrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("../../../.prettierrc.json");
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions packages/cli/openapi-ir-sdk/fern/fern.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"organization": "fern",
"version": "0.17.7"
}
13 changes: 13 additions & 0 deletions packages/cli/openapi-ir-sdk/fern/generators.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
default-group: local
groups:
local:
generators:
- name: fernapi/fern-typescript-node-sdk
version: 0.8.13
output:
location: local-file-system
path: ../src/sdk
config:
noOptionalProperties: true
outputSourceFiles: true
includeUtilsOnUnionMembers: true
1 change: 1 addition & 0 deletions packages/cli/openapi-ir-sdk/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from "../../../shared/jest.config.shared";
40 changes: 40 additions & 0 deletions packages/cli/openapi-ir-sdk/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "@fern-api/openapi-ir-sdk",
"version": "0.0.0",
"repository": {
"type": "git",
"url": "https://github.com/fern-api/fern.git",
"directory": "packages/cli/openapi-ir-sdk"
},
"private": true,
"files": [
"lib"
],
"type": "module",
"source": "src/index.ts",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"sideEffects": false,
"scripts": {
"clean": "rm -rf ./lib && tsc --build --clean",
"compile": "tsc --build",
"test": "yarn compile && jest --passWithNoTests",
"lint:eslint": "eslint --max-warnings 0 . --ignore-path=../../../.eslintignore --report-unused-disable-directives",
"lint:eslint:fix": "yarn lint:eslint --fix",
"format": "prettier --write --ignore-unknown --ignore-path ../../../shared/.prettierignore \"**\"",
"format:check": "prettier --check --ignore-unknown --ignore-path ../../../shared/.prettierignore \"**\"",
"organize-imports": "organize-imports-cli tsconfig.json",
"depcheck": "depcheck",
"generate": "fern generate --local"
},
"devDependencies": {
"@types/jest": "^29.0.3",
"@types/node": "^18.7.18",
"depcheck": "^1.4.6",
"eslint": "^8.56.0",
"jest": "^29.7.0",
"organize-imports-cli": "^0.10.0",
"prettier": "^2.7.1",
"typescript": "4.6.4"
}
}
3 changes: 3 additions & 0 deletions packages/cli/openapi-ir-sdk/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from "./sdk";
export * from "./sdk/api";
export * as serialization from "./sdk/serialization";
1 change: 1 addition & 0 deletions packages/cli/openapi-ir-sdk/src/sdk/api/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./resources";
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./types";
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

export interface BasicSecurityScheme {
usernameVariableName: string | undefined;
usernameEnvVar: string | undefined;
passwordVariableName: string | undefined;
passwordEnvVar: string | undefined;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

export interface BearerSecurityScheme {
tokenVariableName: string | undefined;
tokenEnvVar: string | undefined;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

export interface HeaderSecurityScheme {
headerName: string;
prefix: string | undefined;
headerVariableName: string | undefined;
headerEnvVar: string | undefined;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

import * as FernOpenapiIr from "../../..";

export interface OauthSecurityScheme {
scopesEnum: FernOpenapiIr.EnumSchema | undefined;
}
Loading

0 comments on commit cd900a3

Please sign in to comment.