middleware/utils
Esta página aún no está disponible en tu idioma.
Enumerations
Section titled “Enumerations”SetLocal
Section titled “SetLocal”Defined in: studiocms/packages/studiocms/src/middleware/utils.ts:89^
Enum representing different local settings categories.
Remarks
Section titled “Remarks”Used to specify the context for local configuration, such as general settings, security-related settings, or plugin-specific settings.
Enumeration Members
Section titled “Enumeration Members”GENERAL
Section titled “GENERAL”GENERAL: "general";
Defined in: studiocms/packages/studiocms/src/middleware/utils.ts:90^
PLUGINS
Section titled “PLUGINS”PLUGINS: "plugins";
Defined in: studiocms/packages/studiocms/src/middleware/utils.ts:92^
SECURITY
Section titled “SECURITY”SECURITY: "security";
Defined in: studiocms/packages/studiocms/src/middleware/utils.ts:91^
Type Aliases
Section titled “Type Aliases”SetLocalValues
Section titled “SetLocalValues”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.
Properties
Section titled “Properties”general
Section titled “general”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
Section titled “plugins”plugins: APIContext["locals"]["StudioCMS"]["plugins"];
Defined in: studiocms/packages/studiocms/src/middleware/utils.ts:68^
Contains plugin-related StudioCMS local values.
security
Section titled “security”security: APIContext["locals"]["StudioCMS"]["security"];
Defined in: studiocms/packages/studiocms/src/middleware/utils.ts:67^
Contains security-related StudioCMS local values.
SetLocalValuesKeys
Section titled “SetLocalValuesKeys”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.
Variables
Section titled “Variables”setLocals
Section titled “setLocals”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 ofStudioCMS
.'security'
: Merges into thesecurity
property ofStudioCMS
.'plugins'
: Merges into theplugins
property ofStudioCMS
.
Uses a deep merge strategy to combine existing and new values.
Template
Section titled “Template”The key of the section to update ('general'
, 'security'
, or 'plugins'
).
Template
Section titled “Template”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.
Functions
Section titled “Functions”getUserPermissions()
Section titled “getUserPermissions()”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.
Parameters
Section titled “Parameters”userData
Section titled “userData”The session data of the user.
Returns
Section titled “Returns”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.
makeFallbackSiteConfig()
Section titled “makeFallbackSiteConfig()”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.
Returns
Section titled “Returns”The fallback site configuration object.