From ab9954ade7f64940ee294fa31066c8f411e0c31f Mon Sep 17 00:00:00 2001 From: etefaghian Date: Thu, 1 Jul 2021 21:37:24 +0430 Subject: [PATCH] =?UTF-8?q?=E2=AD=90adds=20contents=20field=20to=20funreq?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/index.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index d54cf19..58ee059 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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; + }; + }; + }; }; }; }; @@ -53,19 +59,23 @@ export const funreq = () => { 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;