studiocms
Version:
Astro Native CMS for AstroDB. Built from the ground up by the Astro community.
202 lines (201 loc) • 6.37 kB
TypeScript
import { z } from 'astro/zod';
export declare const TimeUnitSchema: z.ZodUnion<[z.ZodLiteral<"m">, z.ZodLiteral<"h">]>;
export declare const TimeStringSchema: z.ZodEffects<z.ZodString, number, string>;
export type TimeString = typeof TimeStringSchema._input;
/**
* Schema for cache configuration.
*/
export declare const CacheConfigSchema: z.ZodObject<{
/**
* Cache Lifetime
*
* `{number}{unit}` - e.g. '5m' for 5 minutes or '1h' for 1 hour
* @default '5m'
*/
lifetime: z.ZodDefault<z.ZodOptional<z.ZodEffects<z.ZodString, number, string>>>;
}, "strip", z.ZodTypeAny, {
lifetime: number;
}, {
lifetime?: string | undefined;
}>;
/**
* Schema for processed cache configuration.
*
* Extends the base CacheConfigSchema with additional properties.
*
* Properties:
* - `enabled` (boolean): Indicates if the cache is enabled.
* - @default true
*/
export declare const ProcessedCacheConfigSchema: z.ZodObject<{
/**
* Cache Enabled
*
* @default true
*/
enabled: z.ZodDefault<z.ZodBoolean>;
/**
* Cache Lifetime
*
* `{number}{unit}` - e.g. '5m' for 5 minutes or '1h' for 1 hour
* @default '5m'
*/
lifetime: z.ZodDefault<z.ZodEffects<z.ZodString, number, string>>;
}, "strip", z.ZodTypeAny, {
enabled: boolean;
lifetime: number;
}, {
enabled?: boolean | undefined;
lifetime?: string | undefined;
}>;
/**
* Represents the configuration for the cache.
*
* This type is inferred from the `CacheConfigSchema` using Zod's `infer` method.
* It ensures that the cache configuration adheres to the schema defined in `CacheConfigSchema`.
*/
export type CacheConfig = z.infer<typeof CacheConfigSchema>;
/**
* Represents the processed cache configuration inferred from the ProcessedCacheConfigSchema.
*
* This type is used to define the structure of the cache configuration after it has been
* processed and validated by the schema.
*/
export type ProcessedCacheConfig = z.infer<typeof ProcessedCacheConfigSchema>;
/**
* Schema for SDK cache configuration.
*
* This schema allows for either a boolean value or a more detailed cache configuration object.
*
* - If a boolean value is provided:
* - `true`: Enables caching with a default lifetime.
* - `false`: Disables caching.
* - If a cache configuration object is provided, it must conform to `CacheConfigSchema`.
*
* The schema is optional and defaults to `true` (enabled with default lifetime).
*
* The transformation ensures that the resulting configuration is of type `ProcessedCacheConfig`:
* - If a boolean value is provided, it is transformed into an object with `enabled` and `lifetime` properties.
* - If a cache configuration object is provided, it is transformed to ensure `enabled` is always `true`.
*/
export declare const SDKCacheSchema: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodObject<{
/**
* Cache Lifetime
*
* `{number}{unit}` - e.g. '5m' for 5 minutes or '1h' for 1 hour
* @default '5m'
*/
lifetime: z.ZodDefault<z.ZodOptional<z.ZodEffects<z.ZodString, number, string>>>;
}, "strip", z.ZodTypeAny, {
lifetime: number;
}, {
lifetime?: string | undefined;
}>]>>>, {
enabled: boolean;
lifetime: number;
}, boolean | {
lifetime?: string | undefined;
} | undefined>;
/**
* Schema for processing SDK configuration.
*/
export declare const ProcessedSDKSchema: z.ZodObject<{
/**
* Cache Configuration
*
* @default cacheConfig: { lifetime: '5m' }
*/
cacheConfig: z.ZodObject<{
/**
* Cache Enabled
*
* @default true
*/
enabled: z.ZodDefault<z.ZodBoolean>;
/**
* Cache Lifetime
*
* `{number}{unit}` - e.g. '5m' for 5 minutes or '1h' for 1 hour
* @default '5m'
*/
lifetime: z.ZodDefault<z.ZodEffects<z.ZodString, number, string>>;
}, "strip", z.ZodTypeAny, {
enabled: boolean;
lifetime: number;
}, {
enabled?: boolean | undefined;
lifetime?: string | undefined;
}>;
}, "strip", z.ZodTypeAny, {
cacheConfig: {
enabled: boolean;
lifetime: number;
};
}, {
cacheConfig: {
enabled?: boolean | undefined;
lifetime?: string | undefined;
};
}>;
/**
* Type definition for the processed SDK configuration.
*
* This type is inferred from the `ProcessedSDKSchema` using Zod's `infer` method.
* It represents the structure of the SDK configuration after it has been processed.
*/
export type ProcessedSDKConfig = z.infer<typeof ProcessedSDKSchema>;
/**
* SDKSchema is a Zod schema that validates the SDK configuration.
* It can either be a boolean or an object containing cache configuration.
*
* If it is a boolean, it defaults to `true` and transforms into an object
* with default cache configuration.
*
* If it is an object, it must contain the `cacheConfig` property which is
* validated by the `SDKCacheSchema`.
*/
export declare const SDKSchema: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodObject<{
/**
* Cache Configuration
*
* @default cacheConfig: { lifetime: '5m' }
*/
cacheConfig: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodObject<{
/**
* Cache Lifetime
*
* `{number}{unit}` - e.g. '5m' for 5 minutes or '1h' for 1 hour
* @default '5m'
*/
lifetime: z.ZodDefault<z.ZodOptional<z.ZodEffects<z.ZodString, number, string>>>;
}, "strip", z.ZodTypeAny, {
lifetime: number;
}, {
lifetime?: string | undefined;
}>]>>>, {
enabled: boolean;
lifetime: number;
}, boolean | {
lifetime?: string | undefined;
} | undefined>;
}, "strip", z.ZodTypeAny, {
cacheConfig: {
enabled: boolean;
lifetime: number;
};
}, {
cacheConfig?: boolean | {
lifetime?: string | undefined;
} | undefined;
}>]>>>, {
cacheConfig: {
enabled: boolean;
lifetime: number;
};
}, boolean | {
cacheConfig?: boolean | {
lifetime?: string | undefined;
} | undefined;
} | undefined>;
export type StudioCMS_SDKOptions = typeof SDKSchema._input;
export type StudioCMS_SDKConfig = typeof SDKSchema._output;