Saltearse al contenido

middleware/utils

Esta página aún no está disponible en tu idioma.

Defined in: studiocms/packages/studiocms/src/middleware/utils.ts:89^

Enum representing different local settings categories.

Used to specify the context for local configuration, such as general settings, security-related settings, or plugin-specific settings.

GENERAL: "general";

Defined in: studiocms/packages/studiocms/src/middleware/utils.ts:90^

PLUGINS: "plugins";

Defined in: studiocms/packages/studiocms/src/middleware/utils.ts:92^

SECURITY: "security";

Defined in: studiocms/packages/studiocms/src/middleware/utils.ts:91^

type SetLocalValues = {
general: Omit<APIContext["locals"]["StudioCMS"], "security" | "plugins">;
plugins: APIContext["locals"]["StudioCMS"]["plugins"];
security: APIContext["locals"]["StudioCMS"]["security"];
};

Defined in: studiocms/packages/studiocms/src/middleware/utils.ts:65^

Represents the structure for setting local values in the StudioCMS context.

general: Omit<APIContext["locals"]["StudioCMS"], "security" | "plugins">;

Defined in: studiocms/packages/studiocms/src/middleware/utils.ts:66^

Contains general StudioCMS local values, excluding ‘security’ and ‘plugins’.

plugins: APIContext["locals"]["StudioCMS"]["plugins"];

Defined in: studiocms/packages/studiocms/src/middleware/utils.ts:68^

Contains plugin-related StudioCMS local values.

security: APIContext["locals"]["StudioCMS"]["security"];

Defined in: studiocms/packages/studiocms/src/middleware/utils.ts:67^

Contains security-related StudioCMS local values.


type SetLocalValuesKeys = keyof SetLocalValues;

Defined in: studiocms/packages/studiocms/src/middleware/utils.ts:75^

Represents the keys of the SetLocalValues type. Useful for extracting valid property names from the SetLocalValues object type.

const setLocals: any;

Defined in: studiocms/packages/studiocms/src/middleware/utils.ts:118^

Updates the locals.StudioCMS property of the given API context with new values for a specified key.

Depending on the provided key, merges the new values into the corresponding section of locals.StudioCMS:

  • 'general': Merges into the root of StudioCMS.
  • 'security': Merges into the security property of StudioCMS.
  • 'plugins': Merges into the plugins property of StudioCMS.

Uses a deep merge strategy to combine existing and new values.

The key of the section to update ('general', 'security', or 'plugins').

The type of values to merge, corresponding to the section specified by T.

The API context containing the locals.StudioCMS object to update.

The section of StudioCMS to update.

The new values to merge into the specified section.

function getUserPermissions(userData: UserSessionData): Effect<AEff, [Eff] extends [never] ? never : [Eff] extends [YieldWrap<Effect<_A, E, _R>>] ? E : never, [Eff] extends [never] ? never : [Eff] extends [YieldWrap<Effect<_A, _E, R>>] ? R : never>

Defined in: studiocms/packages/studiocms/src/middleware/utils.ts:19^

Retrieves the user’s permission levels based on their session data.

UserSessionData

The session data of the user.

Effect<AEff, [Eff] extends [never] ? never : [Eff] extends [YieldWrap<Effect<_A, E, _R>>] ? E : never, [Eff] extends [never] ? never : [Eff] extends [YieldWrap<Effect<_A, _E, R>>] ? R : never>

An object containing boolean flags indicating the user’s permission levels:

  • isVisitor: True if the user has at least visitor-level permissions.
  • isEditor: True if the user has at least editor-level permissions.
  • isAdmin: True if the user has at least admin-level permissions.
  • isOwner: True if the user has owner-level permissions.

function makeFallbackSiteConfig(): SiteConfigCacheObject

Defined in: studiocms/packages/studiocms/src/middleware/utils.ts:40^

Creates a fallback site configuration object with default values.

This function is typically used when no site configuration is available, providing sensible defaults for the StudioCMS project.

SiteConfigCacheObject

The fallback site configuration object.