Skip to content

Commit

Permalink
⭐adds contents field to funreq
Browse files Browse the repository at this point in the history
  • Loading branch information
etefaghian committed Jul 1, 2021
1 parent e8e6127 commit ab9954a
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,16 @@ export interface FunReq extends RequestInit {

type Schema = {
schema: {
models: {
contents: {
[key: string]: {
doits: {
[key: string]: { details: { get?: unknown; set?: unknown } | never };
models: {
[key: string]: {
doits: {
[key: string]: {
details: { get?: unknown; set?: unknown } | never;
};
};
};
};
};
};
Expand Down Expand Up @@ -53,19 +59,23 @@ export const funreq = <T extends Schema>() => {

const api = async <
SCHEMA extends T,
MODEL extends SCHEMA["schema"]["models"],
CONTENTS extends SCHEMA["schema"]["contents"],
CONTENTSK extends keyof CONTENTS,
MODEL extends CONTENTS[CONTENTSK]["models"],
MODELK extends keyof MODEL,
DOIT extends MODEL[MODELK]["doits"],
DOITK extends keyof DOIT
>(
body: DOIT[DOITK] extends { details: never }
? {
contents: CONTENTSK;
wants: {
model: MODELK;
doit: DOITK;
};
}
: {
contents: CONTENTSK;
wants: {
model: MODELK;
doit: DOITK;
Expand Down

0 comments on commit ab9954a

Please sign in to comment.