跳转到内容

schemas/config/sdk

此内容尚不支持你的语言。

type CacheConfig = {
lifetime: number;
};

Defined in: studiocms/packages/studiocms/src/schemas/config/sdk.ts:81^

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.

lifetime: number;

Cache Lifetime

{number}{unit} - e.g. ‘5m’ for 5 minutes or ‘1h’ for 1 hour

'5m'

type ProcessedCacheConfig = {
enabled: boolean;
lifetime: number;
};

Defined in: studiocms/packages/studiocms/src/schemas/config/sdk.ts:89^

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.

enabled: boolean;

Cache Enabled

true

lifetime: number;

Cache Lifetime

{number}{unit} - e.g. ‘5m’ for 5 minutes or ‘1h’ for 1 hour

'5m'

type ProcessedSDKConfig = {
cacheConfig: {
enabled: boolean;
lifetime: number;
};
};

Defined in: studiocms/packages/studiocms/src/schemas/config/sdk.ts:139^

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.

cacheConfig: {
enabled: boolean;
lifetime: number;
} = ProcessedCacheConfigSchema;

Cache Configuration

cacheConfig: { lifetime: '5m' }
enabled: boolean;

Cache Enabled

true
lifetime: number;

Cache Lifetime

{number}{unit} - e.g. ‘5m’ for 5 minutes or ‘1h’ for 1 hour

'5m'

type StudioCMS_SDKConfig = typeof SDKSchema._output;

Defined in: studiocms/packages/studiocms/src/schemas/config/sdk.ts:178^


type StudioCMS_SDKOptions = typeof SDKSchema._input;

Defined in: studiocms/packages/studiocms/src/schemas/config/sdk.ts:177^


type TimeString = typeof TimeStringSchema._input;

Defined in: studiocms/packages/studiocms/src/schemas/config/sdk.ts:35^

const CacheConfigSchema: ZodObject<CacheConfig>;

Defined in: studiocms/packages/studiocms/src/schemas/config/sdk.ts:40^

Schema for cache configuration.


const ProcessedCacheConfigSchema: ZodObject<ProcessedCacheConfig>;

Defined in: studiocms/packages/studiocms/src/schemas/config/sdk.ts:59^

Schema for processed cache configuration.

Extends the base CacheConfigSchema with additional properties.

Properties:

true

const ProcessedSDKSchema: ZodObject<ProcessedSDKConfig>;

Defined in: studiocms/packages/studiocms/src/schemas/config/sdk.ts:124^

Schema for processing SDK configuration.


const SDKCacheSchema: ZodEffects<ZodDefault<ZodOptional<ZodUnion<[ZodBoolean, ZodObject<{
lifetime: ZodDefault<ZodOptional<ZodEffects<ZodString, number, string>>>;
}, "strip", ZodTypeAny, {
lifetime: number;
}, {
lifetime?: string;
}>]>>>, {
enabled: boolean;
lifetime: number;
},
| undefined
| boolean
| {
lifetime?: string;
}>;

Defined in: studiocms/packages/studiocms/src/schemas/config/sdk.ts:107^

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.

const SDKSchema: ZodEffects<ZodDefault<ZodOptional<ZodUnion<[ZodBoolean, ZodObject<{
cacheConfig: ZodEffects<ZodDefault<ZodOptional<ZodUnion<...>>>, {
enabled: boolean;
lifetime: number;
},
| undefined
| boolean
| {
lifetime?: ... | ...;
}>;
}, "strip", ZodTypeAny, {
cacheConfig: {
enabled: boolean;
lifetime: number;
};
}, {
cacheConfig?: | boolean
| {
lifetime?: string;
};
}>]>>>, {
cacheConfig: {
enabled: boolean;
lifetime: number;
};
},
| undefined
| boolean
| {
cacheConfig?: | boolean
| {
lifetime?: string;
};
}>;

Defined in: studiocms/packages/studiocms/src/schemas/config/sdk.ts:151^

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.


const TimeStringSchema: ZodEffects<ZodString, number, string>;

Defined in: studiocms/packages/studiocms/src/schemas/config/sdk.ts:8^


const TimeUnitSchema: ZodUnion<[ZodLiteral<"m">, ZodLiteral<"h">]>;

Defined in: studiocms/packages/studiocms/src/schemas/config/sdk.ts:4^