-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: provide plain resource model types (PL-000) (#15)
* feat: provide plain resource model types (PL-000) * chore: update dependencies * fix: update resource models * fix: deep model types
- Loading branch information
Showing
10 changed files
with
925 additions
and
8 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
yarnPath: .yarn/releases/yarn-3.4.1.cjs | ||
nodeLinker: node-modules | ||
|
||
plugins: | ||
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs | ||
spec: "@yarnpkg/plugin-interactive-tools" | ||
|
||
yarnPath: .yarn/releases/yarn-3.4.1.cjs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./resource-models"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import type { Model } from "chargebee-typescript/lib/resources/model"; | ||
|
||
type FilterModelKeys<T extends Model> = { | ||
[K in keyof T]: K extends keyof Model ? never : K; | ||
}[keyof T]; | ||
|
||
/** | ||
* Extracts the properties from a Chargebee resource class. | ||
*/ | ||
export type ResourceModelType<TResource extends Model> = { | ||
[K in FilterModelKeys<TResource>]: TResource[K] extends ( | ||
...args: unknown[] | ||
) => unknown | ||
? never | ||
: TResource[K] extends Model | ||
? ResourceModelType<TResource[K]> | ||
: TResource[K] extends Array<Model> | ||
? Array<ResourceModelType<TResource[K][0]>> | ||
: TResource[K]; | ||
}; |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { ChargebeeResource } from "../chargebee-resource.class"; | ||
export class EntitlementResource extends ChargebeeResource { | ||
public readonly create = super.request("entitlement", "create", { | ||
entitlement: { optional: false }, | ||
}); | ||
|
||
public readonly list = super.listRequest("entitlement", "list", { | ||
entitlement: { optional: false }, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters