From b8dd5f0bd55f2c56eb4ab2a792ece94244510456 Mon Sep 17 00:00:00 2001 From: Mohd Salauddin Date: Sun, 30 Aug 2026 23:42:21 +0530 Subject: [PATCH] fix(types): support fluent-json-schema Signed-off-by: Mohd Salauddin --- types/index.d.ts | 7 ++++++- types/index.tst.ts | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/types/index.d.ts b/types/index.d.ts index 90cdcf4..935781c 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -17,6 +17,11 @@ interface DotenvOptions { type EnvSchema = typeof envSchema +type FluentSchema = { + isFluentSchema: boolean; + isFluentJSONSchema: boolean; +} + declare namespace envSchema { export type { JSONSchemaType } @@ -25,7 +30,7 @@ declare namespace envSchema { } export type EnvSchemaOpt = { - schema?: JSONSchemaType | AnySchema; + schema?: JSONSchemaType | AnySchema | FluentSchema; data?: [EnvSchemaData, ...EnvSchemaData[]] | EnvSchemaData; env?: boolean; dotenv?: boolean | DotenvOptions; diff --git a/types/index.tst.ts b/types/index.tst.ts index 2cc1ff7..9004ae3 100644 --- a/types/index.tst.ts +++ b/types/index.tst.ts @@ -7,6 +7,7 @@ import envSchema, { default as envSchemaDefault, } from '.' import Ajv, { KeywordDefinition, JSONSchemaType } from 'ajv' +import S from 'fluent-json-schema' import { Static, Type } from 'typebox' interface EnvData { @@ -46,6 +47,11 @@ const optWithSchemaTypebox: EnvSchemaOpt = { } expect(optWithSchemaTypebox).type.toBe() +const optWithFluentSchema: EnvSchemaOpt = { + schema: S.object().prop('PORT', S.number().default(3000).required()), +} +expect(optWithFluentSchema).type.toBe() + const optWithSchemaWithType: EnvSchemaOpt = { schema: schemaWithType, } @@ -113,5 +119,13 @@ expect(envSchemaWithType).type.toBe() const envSchemaTypebox = envSchema({ schema: schemaTypebox }) expect(envSchemaTypebox).type.toBe() +const envSchemaFluent = envSchema({ + schema: S.object().prop( + 'PORT', + S.number().default(3000).required() + ), +}) +expect(envSchemaFluent).type.toBe() + expect(keywords.separator).type.toBe() expect(envSchema.keywords.separator).type.toBe()