-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(codegen): commit generated client types to codebase #3492
Changes from all commits
5545bfb
fe8c204
396fc7a
6e33c0d
c386c1a
238650f
d82030b
2907bca
0bee564
3632b24
e70545e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@medusajs/client-types": patch | ||
--- | ||
|
||
feat(codegen): commit generated client types to codebase |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: OAS Codegen Build Check - BETA | ||
on: | ||
pull_request: | ||
paths-ignore: | ||
- "docs/**" | ||
- "www/**" | ||
|
||
jobs: | ||
codegen-test: | ||
runs-on: ubuntu-latest | ||
env: | ||
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} | ||
TURBO_TEAM: ${{ secrets.TURBO_TEAM }} | ||
steps: | ||
- name: Cancel Previous Runs | ||
uses: styfle/[email protected] | ||
with: | ||
access_token: ${{ github.token }} | ||
|
||
- name: Checkout | ||
uses: actions/[email protected] | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Setup Node.js environment | ||
uses: actions/[email protected] | ||
with: | ||
node-version: "14" | ||
cache: "yarn" | ||
|
||
- name: Install dependencies | ||
uses: ./.github/actions/cache-deps | ||
with: | ||
extension: codegen | ||
|
||
- name: Build Packages - Force | ||
run: yarn build --force --no-cache | ||
|
||
- name: Assert latest codegen build committed | ||
run: ./scripts/assert-codegen-build-committed-actions.sh |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
node_modules | ||
/dist | ||
/src/lib | ||
/dist |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
/* istanbul ignore file */ | ||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
/** | ||
* Typing utilities from https:/sindresorhus/type-fest | ||
*/ | ||
|
||
/** | ||
* private methods for exportable dependencies | ||
*/ | ||
// https:/sindresorhus/type-fest/blob/main/source/except.d.ts | ||
type Filter<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true | ||
? never | ||
: KeyType extends ExcludeType | ||
? never | ||
: KeyType | ||
|
||
// https:/sindresorhus/type-fest/blob/main/source/enforce-optional.d.ts | ||
type RequiredFilter<Type, Key extends keyof Type> = undefined extends Type[Key] | ||
? Type[Key] extends undefined | ||
? Key | ||
: never | ||
: Key | ||
|
||
type OptionalFilter<Type, Key extends keyof Type> = undefined extends Type[Key] | ||
? Type[Key] extends undefined | ||
? never | ||
: Key | ||
: never | ||
|
||
// https:/sindresorhus/type-fest/blob/main/source/merge.d.ts | ||
type SimpleMerge<Destination, Source> = { | ||
[Key in keyof Destination | keyof Source]: Key extends keyof Source | ||
? Source[Key] | ||
: Key extends keyof Destination | ||
? Destination[Key] | ||
: never | ||
} | ||
|
||
/** | ||
* optional exportable dependencies | ||
*/ | ||
export type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {} | ||
|
||
export type IsEqual<A, B> = (<G>() => G extends A ? 1 : 2) extends < | ||
G | ||
>() => G extends B ? 1 : 2 | ||
? true | ||
: false | ||
|
||
export type Except<ObjectType, KeysType extends keyof ObjectType> = { | ||
[KeyType in keyof ObjectType as Filter< | ||
KeyType, | ||
KeysType | ||
>]: ObjectType[KeyType] | ||
} | ||
|
||
export type OmitIndexSignature<ObjectType> = { | ||
[KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> | ||
? never | ||
: KeyType]: ObjectType[KeyType] | ||
} | ||
|
||
export type PickIndexSignature<ObjectType> = { | ||
[KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> | ||
? KeyType | ||
: never]: ObjectType[KeyType] | ||
} | ||
|
||
export type EnforceOptional<ObjectType> = Simplify< | ||
{ | ||
[Key in keyof ObjectType as RequiredFilter< | ||
ObjectType, | ||
Key | ||
>]: ObjectType[Key] | ||
} & { | ||
[Key in keyof ObjectType as OptionalFilter<ObjectType, Key>]?: Exclude< | ||
ObjectType[Key], | ||
undefined | ||
> | ||
} | ||
> | ||
|
||
/** | ||
* SetRequired | ||
*/ | ||
export type SetRequired<BaseType, Keys extends keyof BaseType> = Simplify< | ||
// Pick just the keys that are optional from the base type. | ||
Except<BaseType, Keys> & | ||
// Pick the keys that should be required from the base type and make them required. | ||
Required<Pick<BaseType, Keys>> | ||
> | ||
|
||
/** | ||
* SetNonNullable | ||
*/ | ||
export type SetNonNullable< | ||
BaseType, | ||
Keys extends keyof BaseType = keyof BaseType | ||
> = { | ||
[Key in keyof BaseType]: Key extends Keys | ||
? NonNullable<BaseType[Key]> | ||
: BaseType[Key] | ||
} | ||
|
||
/** | ||
* Merge | ||
*/ | ||
export type Merge<Destination, Source> = EnforceOptional< | ||
SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>> & | ||
SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>> | ||
> | ||
|
||
/** | ||
* SetRelation | ||
* Alias combining SetRequire and SetNonNullable. | ||
*/ | ||
export type SetRelation<BaseType, Keys extends keyof BaseType> = SetRequired< | ||
SetNonNullable<BaseType, Keys>, | ||
Keys | ||
> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/* istanbul ignore file */ | ||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
|
||
export * from "./models" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question: Would it make sense in the end if we have multiple export from here, to namespace them like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One of the tenants for this initiative was to be a drop-in replacement of the current type imports from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we export something else than the models later, the user will not be able to do as Models as it would also includes the rest. I agree that it is a drop in replacement so let’s not take this comment into account for now 👍 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* istanbul ignore file */ | ||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
import { SetRelation, Merge } from "../core/ModelUtils" | ||
|
||
import type { Country } from "./Country" | ||
import type { Customer } from "./Customer" | ||
|
||
/** | ||
* An address. | ||
*/ | ||
export interface Address { | ||
/** | ||
* ID of the address | ||
*/ | ||
id: string | ||
/** | ||
* ID of the customer this address belongs to | ||
*/ | ||
customer_id: string | null | ||
/** | ||
* Available if the relation `customer` is expanded. | ||
*/ | ||
customer?: Customer | null | ||
/** | ||
* Company name | ||
*/ | ||
company: string | null | ||
/** | ||
* First name | ||
*/ | ||
first_name: string | null | ||
/** | ||
* Last name | ||
*/ | ||
last_name: string | null | ||
/** | ||
* Address line 1 | ||
*/ | ||
address_1: string | null | ||
/** | ||
* Address line 2 | ||
*/ | ||
address_2: string | null | ||
/** | ||
* City | ||
*/ | ||
city: string | null | ||
/** | ||
* The 2 character ISO code of the country in lower case | ||
*/ | ||
country_code: string | null | ||
/** | ||
* A country object. Available if the relation `country` is expanded. | ||
*/ | ||
country?: Country | null | ||
/** | ||
* Province | ||
*/ | ||
province: string | null | ||
/** | ||
* Postal Code | ||
*/ | ||
postal_code: string | null | ||
/** | ||
* Phone Number | ||
*/ | ||
phone: string | null | ||
/** | ||
* The date with timezone at which the resource was created. | ||
*/ | ||
created_at: string | ||
/** | ||
* The date with timezone at which the resource was updated. | ||
*/ | ||
updated_at: string | ||
/** | ||
* The date with timezone at which the resource was deleted. | ||
*/ | ||
deleted_at: string | null | ||
/** | ||
* An optional key-value map with additional details | ||
*/ | ||
metadata: Record<string, any> | null | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* istanbul ignore file */ | ||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
import { SetRelation, Merge } from "../core/ModelUtils" | ||
|
||
/** | ||
* Address fields used when creating an address. | ||
*/ | ||
export interface AddressCreatePayload { | ||
/** | ||
* First name | ||
*/ | ||
first_name: string | ||
/** | ||
* Last name | ||
*/ | ||
last_name: string | ||
/** | ||
* Phone Number | ||
*/ | ||
phone?: string | ||
company?: string | ||
/** | ||
* Address line 1 | ||
*/ | ||
address_1: string | ||
/** | ||
* Address line 2 | ||
*/ | ||
address_2?: string | ||
/** | ||
* City | ||
*/ | ||
city: string | ||
/** | ||
* The 2 character ISO code of the country in lower case | ||
*/ | ||
country_code: string | ||
/** | ||
* Province | ||
*/ | ||
province?: string | ||
/** | ||
* Postal Code | ||
*/ | ||
postal_code: string | ||
/** | ||
* An optional key-value map with additional details | ||
*/ | ||
metadata?: Record<string, any> | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* istanbul ignore file */ | ||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
import { SetRelation, Merge } from "../core/ModelUtils" | ||
|
||
/** | ||
* Address fields used when creating/updating an address. | ||
*/ | ||
export interface AddressPayload { | ||
/** | ||
* First name | ||
*/ | ||
first_name?: string | ||
/** | ||
* Last name | ||
*/ | ||
last_name?: string | ||
/** | ||
* Phone Number | ||
*/ | ||
phone?: string | ||
company?: string | ||
/** | ||
* Address line 1 | ||
*/ | ||
address_1?: string | ||
/** | ||
* Address line 2 | ||
*/ | ||
address_2?: string | ||
/** | ||
* City | ||
*/ | ||
city?: string | ||
/** | ||
* The 2 character ISO code of the country in lower case | ||
*/ | ||
country_code?: string | ||
/** | ||
* Province | ||
*/ | ||
province?: string | ||
/** | ||
* Postal Code | ||
*/ | ||
postal_code?: string | ||
/** | ||
* An optional key-value map with additional details | ||
*/ | ||
metadata?: Record<string, any> | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* istanbul ignore file */ | ||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
import { SetRelation, Merge } from "../core/ModelUtils" | ||
|
||
import type { OAuth } from "./OAuth" | ||
|
||
export interface AdminAppsListRes { | ||
apps: Array<OAuth> | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* istanbul ignore file */ | ||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
import { SetRelation, Merge } from "../core/ModelUtils" | ||
|
||
import type { OAuth } from "./OAuth" | ||
|
||
export interface AdminAppsRes { | ||
apps: OAuth | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Force build