@dangreaves/groq-query-builder
Advanced tools
Comparing version 0.13.0 to 0.13.1
@@ -38,3 +38,3 @@ import { Logger } from 'pino'; | ||
type SanityParams = Record<string, string | number | null> | undefined; | ||
declare function makeSafeSanityFetch(fn: (query: string, params?: SanityParams) => Promise<any>, { logger, validationMode, }?: { | ||
declare function makeSafeSanityFetch(fn: (query: string, params?: SanityParams) => Promise<any>, { validationMode, logger, }?: { | ||
logger?: Logger; | ||
@@ -54,3 +54,3 @@ validationMode?: "ERROR" | "WARN"; | ||
*/ | ||
type TCollection<T extends TSchema = TSchema> = TArray<T extends TObject ? TIntersect<[T, TObject<{ | ||
type TCollection<T extends TSchema = TSchema> = TArray<T extends TObject | TUnion ? TIntersect<[T, TObject<{ | ||
_key: TNullable<TString>; | ||
@@ -57,0 +57,0 @@ }>]> : T> & { |
@@ -23,4 +23,4 @@ var __defProp = Object.defineProperty; | ||
function makeSafeSanityFetch(fn, { | ||
logger = pino(), | ||
validationMode = "ERROR" | ||
validationMode = "ERROR", | ||
logger = pino({ level: "info" }) | ||
} = {}) { | ||
@@ -109,4 +109,8 @@ return async function fetchSanity(schema, params) { | ||
} | ||
if (TypeGuard.IsObject(this.__inner_schema__)) { | ||
groq.push(`{_key,...@${this.__inner_schema__.serialize?.() ?? ""}}`); | ||
const innerGroq = this.__inner_schema__.serialize?.(); | ||
if (innerGroq) { | ||
if (TypeGuard.IsObject(this.__inner_schema__) || TypeGuard.IsUnion(this.__inner_schema__)) { | ||
groq.push(`{_key,...@${innerGroq}}`); | ||
} else | ||
groq.push(innerGroq); | ||
} | ||
@@ -113,0 +117,0 @@ return groq.join(""); |
{ | ||
"name": "@dangreaves/groq-query-builder", | ||
"version": "0.13.0", | ||
"version": "0.13.1", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "author": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
41275
818