From 7f1e8e4a0d3071ca0820770b691b47a45ece8dd6 Mon Sep 17 00:00:00 2001 From: alansemenov Date: Wed, 2 Oct 2024 13:24:16 +0200 Subject: [PATCH] Linter errors after turning on strict mode #10718 --- .../src/main/resources/lib/xp/admin.ts | 24 +++++++- .../lib-app/src/main/resources/lib/xp/app.ts | 14 ++--- .../src/main/resources/lib/xp/auditlog.ts | 6 +- .../src/main/resources/lib/xp/auth.ts | 46 +++++++------- .../src/main/resources/lib/xp/cluster.ts | 2 +- .../src/main/resources/lib/xp/common.ts | 2 +- .../src/main/resources/lib/xp/content.ts | 60 +++++++++---------- .../src/main/resources/lib/xp/context.ts | 4 +- .../src/main/resources/lib/xp/event.ts | 4 +- .../src/main/resources/lib/xp/export.ts | 4 +- .../src/main/resources/lib/xp/grid.ts | 7 ++- .../src/main/resources/lib/xp/i18n.ts | 6 +- .../lib-io/src/main/resources/lib/xp/io.ts | 4 +- .../src/main/resources/lib/xp/mail.ts | 4 +- .../src/main/resources/lib/xp/node.ts | 24 ++++---- .../src/main/resources/lib/xp/portal.ts | 48 +++++++-------- .../src/main/resources/lib/xp/project.ts | 18 +++--- .../src/main/resources/lib/xp/repo.ts | 18 +++--- .../src/main/resources/lib/xp/scheduler.ts | 10 ++-- .../src/main/resources/lib/xp/schema.ts | 32 +++++----- .../src/main/resources/lib/xp/task.ts | 18 +++--- .../src/main/resources/lib/xp/value.ts | 18 +++--- .../src/main/resources/lib/xp/vhost.ts | 4 +- .../src/main/resources/lib/xp/websocket.ts | 10 ++-- 24 files changed, 204 insertions(+), 183 deletions(-) diff --git a/modules/lib/lib-admin/src/main/resources/lib/xp/admin.ts b/modules/lib/lib-admin/src/main/resources/lib/xp/admin.ts index eac68cc086b..8cd43afe792 100644 --- a/modules/lib/lib-admin/src/main/resources/lib/xp/admin.ts +++ b/modules/lib/lib-admin/src/main/resources/lib/xp/admin.ts @@ -13,8 +13,26 @@ declare global { * @module admin */ -const i18n = require('/lib/xp/i18n'); -const portal = require('/lib/xp/portal'); +interface ApiUrlParams { + application: string; + api?: string; + type?: 'server' | 'absolute' | 'websocket'; + params?: object; + path?: string | string[]; +} + +interface Portal { + apiUrl(options: ApiUrlParams): string; + assetUrl(options: { application: string; path: string }): string; + url(options: { path: string; type?: string }): string; +} + +interface I18n { + getPhrases(locale: string[], bundles: string[]): Record; +} + +const i18n: I18n = require('/lib/xp/i18n'); +const portal: Portal = require('/lib/xp/portal'); function checkRequired(obj: T, name: keyof T): void { if (obj == null || obj[name] == null) { @@ -22,7 +40,7 @@ function checkRequired(obj: T, name: keyof T): void { } } -const helper = __.newBean('com.enonic.xp.lib.admin.AdminLibHelper'); +const helper: AdminLibHelper = __.newBean('com.enonic.xp.lib.admin.AdminLibHelper'); interface AdminLibHelper { getHomeAppName(): string; diff --git a/modules/lib/lib-app/src/main/resources/lib/xp/app.ts b/modules/lib/lib-app/src/main/resources/lib/xp/app.ts index b74c20e6e26..1a852f10996 100644 --- a/modules/lib/lib-app/src/main/resources/lib/xp/app.ts +++ b/modules/lib/lib-app/src/main/resources/lib/xp/app.ts @@ -59,7 +59,7 @@ interface CreateVirtualApplicationHandler { export function createVirtualApplication(params: CreateVirtualApplicationParams): Application { checkRequired(params, 'key'); - const bean = __.newBean('com.enonic.xp.lib.app.CreateVirtualApplicationHandler'); + const bean: CreateVirtualApplicationHandler = __.newBean('com.enonic.xp.lib.app.CreateVirtualApplicationHandler'); bean.setKey(params.key); return __.toNativeObject(bean.execute()); } @@ -85,7 +85,7 @@ interface DeleteVirtualApplicationHandler { export function deleteVirtualApplication(params: DeleteVirtualApplicationParams): boolean { checkRequired(params, 'key'); - const bean = __.newBean('com.enonic.xp.lib.app.DeleteVirtualApplicationHandler'); + const bean: DeleteVirtualApplicationHandler = __.newBean('com.enonic.xp.lib.app.DeleteVirtualApplicationHandler'); bean.setKey(params.key); return __.toNativeObject(bean.execute()); } @@ -111,7 +111,7 @@ interface GetApplicationHandler { export function get(params: GetApplicationParams): Application { checkRequired(params, 'key'); - const bean = __.newBean('com.enonic.xp.lib.app.GetApplicationHandler'); + const bean: GetApplicationHandler = __.newBean('com.enonic.xp.lib.app.GetApplicationHandler'); bean.setKey(params.key); return __.toNativeObject(bean.execute()); } @@ -126,7 +126,7 @@ interface ListApplicationsHandler { * @returns {object[]} applications list. */ export function list(): Application[] { - const bean = __.newBean('com.enonic.xp.lib.app.ListApplicationsHandler'); + const bean: ListApplicationsHandler = __.newBean('com.enonic.xp.lib.app.ListApplicationsHandler'); return __.toNativeObject(bean.execute()); } @@ -161,7 +161,7 @@ interface GetApplicationDescriptorHandler { * @returns {object} fetched application descriptor. */ export function getDescriptor(params: GetApplicationDescriptorParams): ApplicationDescriptor { - const bean = __.newBean('com.enonic.xp.lib.app.GetApplicationDescriptorHandler'); + const bean: GetApplicationDescriptorHandler = __.newBean('com.enonic.xp.lib.app.GetApplicationDescriptorHandler'); bean.setKey(params.key); return __.toNativeObject(bean.execute()); } @@ -187,7 +187,7 @@ interface HasVirtualApplicationHandler { export function hasVirtual(params: HasVirtualApplicationParams): boolean { checkRequired(params, 'key'); - const bean = __.newBean('com.enonic.xp.lib.app.HasVirtualApplicationHandler'); + const bean: HasVirtualApplicationHandler = __.newBean('com.enonic.xp.lib.app.HasVirtualApplicationHandler'); bean.setKey(params.key); return __.toNativeObject(bean.execute()); } @@ -213,7 +213,7 @@ interface GetApplicationModeHandler { export function getApplicationMode(params: GetApplicationModeParams): string | null { checkRequired(params, 'key'); - const bean = __.newBean('com.enonic.xp.lib.app.GetApplicationModeHandler'); + const bean: GetApplicationModeHandler = __.newBean('com.enonic.xp.lib.app.GetApplicationModeHandler'); bean.setKey(params.key); return __.toNativeObject(bean.execute()); } diff --git a/modules/lib/lib-auditlog/src/main/resources/lib/xp/auditlog.ts b/modules/lib/lib-auditlog/src/main/resources/lib/xp/auditlog.ts index d060bb1cde3..cbe4b7dd29d 100644 --- a/modules/lib/lib-auditlog/src/main/resources/lib/xp/auditlog.ts +++ b/modules/lib/lib-auditlog/src/main/resources/lib/xp/auditlog.ts @@ -78,7 +78,7 @@ interface CreateAuditLogHandler> { export function log = Record>(params: AuditLogParams): AuditLog { checkRequired(params, 'type'); - const bean = __.newBean>('com.enonic.xp.lib.audit.CreateAuditLogHandler'); + const bean: CreateAuditLogHandler = __.newBean>('com.enonic.xp.lib.audit.CreateAuditLogHandler'); bean.setType(params.type); bean.setTime(__.nullOrValue(params.time)); bean.setSource(params.source ?? app.name); @@ -112,7 +112,7 @@ interface GetAuditLogHandler { export function get(params: GetAuditLogParams): AuditLog | null { checkRequired(params, 'id'); - const bean = __.newBean('com.enonic.xp.lib.audit.GetAuditLogHandler'); + const bean: GetAuditLogHandler = __.newBean('com.enonic.xp.lib.audit.GetAuditLogHandler'); bean.setId(params.id); return __.toNativeObject(bean.execute()); } @@ -191,7 +191,7 @@ export function find(params: FindAuditLogParams): AuditLogs { objects, } = params ?? {}; - const bean = __.newBean('com.enonic.xp.lib.audit.FindAuditLogHandler'); + const bean: FindAuditLogHandler = __.newBean('com.enonic.xp.lib.audit.FindAuditLogHandler'); bean.setStart(start); bean.setCount(count); bean.setIds(__.toScriptValue(ids)); diff --git a/modules/lib/lib-auth/src/main/resources/lib/xp/auth.ts b/modules/lib/lib-auth/src/main/resources/lib/xp/auth.ts index efac2678701..4e06711ad66 100644 --- a/modules/lib/lib-auth/src/main/resources/lib/xp/auth.ts +++ b/modules/lib/lib-auth/src/main/resources/lib/xp/auth.ts @@ -93,7 +93,7 @@ export function login(params: LoginParams): LoginResult { sessionTimeout, } = params ?? {}; - const bean = __.newBean('com.enonic.xp.lib.auth.LoginHandler'); + const bean: LoginHandler = __.newBean('com.enonic.xp.lib.auth.LoginHandler'); bean.setUser(user); @@ -125,7 +125,7 @@ interface LogoutHandler { * @example-ref examples/auth/logout.js */ export function logout(): void { - const bean = __.newBean('com.enonic.xp.lib.auth.LogoutHandler'); + const bean: LogoutHandler = __.newBean('com.enonic.xp.lib.auth.LogoutHandler'); bean.logout(); } @@ -157,7 +157,7 @@ export function getUser(params?: GetUserParams): User | null { includeProfile = false, } = params ?? {}; - const bean = __.newBean('com.enonic.xp.lib.auth.GetUserHandler'); + const bean: GetUserHandler = __.newBean('com.enonic.xp.lib.auth.GetUserHandler'); bean.setIncludeProfile(includeProfile); @@ -179,7 +179,7 @@ interface HasRoleHandler { * @returns {boolean} True if the user has specified role, false otherwise. */ export function hasRole(role: string): boolean { - const bean = __.newBean('com.enonic.xp.lib.auth.HasRoleHandler'); + const bean: HasRoleHandler = __.newBean('com.enonic.xp.lib.auth.HasRoleHandler'); bean.setRole(__.nullOrValue(role)); @@ -198,7 +198,7 @@ interface GeneratePasswordHandler { * @returns {string} A secure generated password. */ export function generatePassword(): string { - const bean = __.newBean('com.enonic.xp.lib.auth.GeneratePasswordHandler'); + const bean: GeneratePasswordHandler = __.newBean('com.enonic.xp.lib.auth.GeneratePasswordHandler'); return __.toNativeObject(bean.generatePassword()); } @@ -226,7 +226,7 @@ interface ChangePasswordHandler { * @param {string} params.password New password to set. */ export function changePassword(params: ChangePasswordParams): void { - const bean = __.newBean('com.enonic.xp.lib.auth.ChangePasswordHandler'); + const bean: ChangePasswordHandler = __.newBean('com.enonic.xp.lib.auth.ChangePasswordHandler'); checkRequired(params, 'userKey'); checkRequired(params, 'password'); @@ -259,7 +259,7 @@ export function getPrincipal(roleKey: RoleKey): Role | null; export function getPrincipal(principalKey: PrincipalKey): Principal | null { checkRequiredValue(principalKey, 'principalKey'); - const bean = __.newBean('com.enonic.xp.lib.auth.GetPrincipalHandler'); + const bean: GetPrincipalHandler = __.newBean('com.enonic.xp.lib.auth.GetPrincipalHandler'); bean.setPrincipalKey(principalKey); @@ -286,7 +286,7 @@ interface GetMembershipsHandler { export function getMemberships(principalKey: UserKey | GroupKey, transitive = false): (Group | Role)[] { checkRequiredValue(principalKey, 'principalKey'); - const bean = __.newBean('com.enonic.xp.lib.auth.GetMembershipsHandler'); + const bean: GetMembershipsHandler = __.newBean('com.enonic.xp.lib.auth.GetMembershipsHandler'); bean.setPrincipalKey(principalKey); bean.setTransitive(transitive); @@ -311,7 +311,7 @@ interface GetMembersHandler { export function getMembers(principalKey: GroupKey | RoleKey): (User | Group)[] { checkRequiredValue(principalKey, 'principalKey'); - const bean = __.newBean('com.enonic.xp.lib.auth.GetMembersHandler'); + const bean: GetMembersHandler = __.newBean('com.enonic.xp.lib.auth.GetMembersHandler'); bean.setPrincipalKey(principalKey); @@ -352,7 +352,7 @@ export function createUser(params: CreateUserParams): User { checkRequired(params, 'name'); checkRequired(params, 'idProvider'); - const bean = __.newBean('com.enonic.xp.lib.auth.CreateUserHandler'); + const bean: CreateUserHandler = __.newBean('com.enonic.xp.lib.auth.CreateUserHandler'); bean.setIdProvider(params.idProvider); bean.setName(params.name); @@ -389,7 +389,7 @@ export function modifyUser(params: ModifyUserParams): User | null { checkRequired(params, 'key'); checkRequired(params, 'editor'); - const bean = __.newBean('com.enonic.xp.lib.auth.ModifyUserHandler'); + const bean: ModifyUserHandler = __.newBean('com.enonic.xp.lib.auth.ModifyUserHandler'); bean.setPrincipalKey(params.key); bean.setEditor(__.toScriptValue(params.editor)); @@ -431,7 +431,7 @@ export function createGroup(params: CreateGroupParams): Group { checkRequired(params, 'idProvider'); checkRequired(params, 'name'); - const bean = __.newBean('com.enonic.xp.lib.auth.CreateGroupHandler'); + const bean: CreateGroupHandler = __.newBean('com.enonic.xp.lib.auth.CreateGroupHandler'); bean.setIdProvider(params.idProvider); bean.setName(params.name); @@ -468,7 +468,7 @@ export function modifyGroup(params: ModifyGroupParams): Group | null { checkRequired(params, 'key'); checkRequired(params, 'editor'); - const bean = __.newBean('com.enonic.xp.lib.auth.ModifyGroupHandler'); + const bean: ModifyGroupHandler = __.newBean('com.enonic.xp.lib.auth.ModifyGroupHandler'); bean.setPrincipalKey(params.key); bean.setEditor(__.toScriptValue(params.editor)); @@ -495,7 +495,7 @@ interface AddMembersHandler { export function addMembers(principalKey: GroupKey | RoleKey, members: (UserKey | GroupKey)[]): void { checkRequiredValue(principalKey, 'principalKey'); - const bean = __.newBean('com.enonic.xp.lib.auth.AddMembersHandler'); + const bean: AddMembersHandler = __.newBean('com.enonic.xp.lib.auth.AddMembersHandler'); bean.setPrincipalKey(principalKey); bean.setMembers(([] as (UserKey | GroupKey)[]).concat(members)); @@ -522,7 +522,7 @@ interface RemoveMembersHandler { export function removeMembers(principalKey: GroupKey | RoleKey, members: (UserKey | GroupKey)[]): void { checkRequiredValue(principalKey, 'principalKey'); - const bean = __.newBean('com.enonic.xp.lib.auth.RemoveMembersHandler'); + const bean: RemoveMembersHandler = __.newBean('com.enonic.xp.lib.auth.RemoveMembersHandler'); bean.setPrincipalKey(principalKey); bean.setMembers(([] as (UserKey | GroupKey)[]).concat(members)); @@ -576,7 +576,7 @@ interface FindPrincipalsHandler { * @returns {FindPrincipalsResult} The "total" number of principals matching the search, the "count" of principals included, and an array of "hits" containing the principals. */ export function findPrincipals(params: FindPrincipalsParams): FindPrincipalsResult { - const bean = __.newBean('com.enonic.xp.lib.auth.FindPrincipalsHandler'); + const bean: FindPrincipalsHandler = __.newBean('com.enonic.xp.lib.auth.FindPrincipalsHandler'); const { type, @@ -614,7 +614,7 @@ interface DeletePrincipalHandler { export function deletePrincipal(principalKey: PrincipalKey): boolean { checkRequiredValue(principalKey, 'principalKey'); - const bean = __.newBean('com.enonic.xp.lib.auth.DeletePrincipalHandler'); + const bean: DeletePrincipalHandler = __.newBean('com.enonic.xp.lib.auth.DeletePrincipalHandler'); bean.setPrincipalKey(principalKey); return __.toNativeObject(bean.deletePrincipal()); } @@ -632,7 +632,7 @@ interface GetIdProviderConfigHandler>(): IdProviderConfig | null { - const bean = __.newBean>('com.enonic.xp.lib.auth.GetIdProviderConfigHandler'); + const bean: GetIdProviderConfigHandler = __.newBean>('com.enonic.xp.lib.auth.GetIdProviderConfigHandler'); return __.toNativeObject(bean.execute()); } @@ -662,7 +662,7 @@ interface GetProfileHandler> { export function getProfile = Record>(params: GetProfileParams): Profile | null { checkRequired(params, 'key'); - const bean = __.newBean>('com.enonic.xp.lib.auth.GetProfileHandler'); + const bean: GetProfileHandler = __.newBean>('com.enonic.xp.lib.auth.GetProfileHandler'); bean.setKey(params.key); bean.setScope(__.nullOrValue(params.scope)); @@ -701,7 +701,7 @@ export function modifyProfile = Record>('com.enonic.xp.lib.auth.ModifyProfileHandler'); + const bean: ModifyProfileHandler = __.newBean>('com.enonic.xp.lib.auth.ModifyProfileHandler'); bean.setKey(params.key); bean.setScope(__.nullOrValue(params.scope)); @@ -757,7 +757,7 @@ export function findUsers(params: FindUsersParams): FindPrincipalsResult('com.enonic.xp.lib.auth.FindUsersHandler'); + const bean: FindUsersHandler = __.newBean('com.enonic.xp.lib.auth.FindUsersHandler'); bean.setStart(start); bean.setCount(count); @@ -795,7 +795,7 @@ interface CreateRoleHandler { export function createRole(params: CreateRoleParams): Role { checkRequired(params, 'name'); - const bean = __.newBean('com.enonic.xp.lib.auth.CreateRoleHandler'); + const bean: CreateRoleHandler = __.newBean('com.enonic.xp.lib.auth.CreateRoleHandler'); bean.setName(params.name); bean.setDisplayName(__.nullOrValue(params.displayName)); @@ -831,7 +831,7 @@ export function modifyRole(params: ModifyRoleParams): Role | null { checkRequired(params, 'key'); checkRequired(params, 'editor'); - const bean = __.newBean('com.enonic.xp.lib.auth.ModifyRoleHandler'); + const bean: ModifyRoleHandler = __.newBean('com.enonic.xp.lib.auth.ModifyRoleHandler'); bean.setPrincipalKey(params.key); bean.setEditor(__.toScriptValue(params.editor)); diff --git a/modules/lib/lib-cluster/src/main/resources/lib/xp/cluster.ts b/modules/lib/lib-cluster/src/main/resources/lib/xp/cluster.ts index ef5f53f24a3..757f4fbccd4 100644 --- a/modules/lib/lib-cluster/src/main/resources/lib/xp/cluster.ts +++ b/modules/lib/lib-cluster/src/main/resources/lib/xp/cluster.ts @@ -25,6 +25,6 @@ interface ClusterIsMasterHandler { * @returns {boolean} true if the current node is master; false otherwise. */ export function isMaster(): boolean { - const bean = __.newBean('com.enonic.xp.lib.cluster.ClusterIsMasterHandler'); + const bean: ClusterIsMasterHandler = __.newBean('com.enonic.xp.lib.cluster.ClusterIsMasterHandler'); return __.toNativeObject(bean.isMaster()); } diff --git a/modules/lib/lib-common/src/main/resources/lib/xp/common.ts b/modules/lib/lib-common/src/main/resources/lib/xp/common.ts index 2f669bc31d3..cdfcfe64426 100644 --- a/modules/lib/lib-common/src/main/resources/lib/xp/common.ts +++ b/modules/lib/lib-common/src/main/resources/lib/xp/common.ts @@ -17,7 +17,7 @@ interface NamePrettyfier { * @module common */ -const NamePrettyfier = __.newBean('com.enonic.xp.lib.common.NamePrettyfierHandler'); +const NamePrettyfier: NamePrettyfier = __.newBean('com.enonic.xp.lib.common.NamePrettyfierHandler'); /** * Transform a text string so that it can be safely used in cases where the range of accepted characters is restricted. diff --git a/modules/lib/lib-content/src/main/resources/lib/xp/content.ts b/modules/lib/lib-content/src/main/resources/lib/xp/content.ts index 80f288443ea..47c1ddaec21 100644 --- a/modules/lib/lib-content/src/main/resources/lib/xp/content.ts +++ b/modules/lib/lib-content/src/main/resources/lib/xp/content.ts @@ -182,7 +182,7 @@ interface GetAttachmentsHandler { export function get = Content>(params: GetContentParams): Hit | null { checkRequired(params, 'key'); - const bean = __.newBean('com.enonic.xp.lib.content.GetContentHandler'); + const bean: GetContentHandler = __.newBean('com.enonic.xp.lib.content.GetContentHandler'); bean.setKey(params.key); bean.setVersionId(__.nullOrValue(params.versionId)); @@ -200,7 +200,7 @@ export function get = Content>(params: GetContentPa * @returns {object} An object with all the attachments that belong to the content, where the key is the attachment name. Or null if the content cannot be found. */ export function getAttachments(key: string): Attachments | null { - const bean = __.newBean('com.enonic.xp.lib.content.GetAttachmentsHandler'); + const bean: GetAttachmentsHandler = __.newBean('com.enonic.xp.lib.content.GetAttachmentsHandler'); bean.setKey(__.nullOrValue(key)); return __.toNativeObject(bean.execute()); } @@ -233,7 +233,7 @@ export function getAttachmentStream(params: GetAttachmentStreamParams): ByteSour checkRequired(params, 'key'); checkRequired(params, 'name'); - const bean = __.newBean('com.enonic.xp.lib.content.GetAttachmentStreamHandler'); + const bean: GetAttachmentStreamHandler = __.newBean('com.enonic.xp.lib.content.GetAttachmentStreamHandler'); bean.setKey(params.key); bean.setName(params.name); @@ -281,7 +281,7 @@ export function addAttachment(params: AddAttachmentParam): void { checkRequired(params, 'mimeType'); checkRequired(params, 'data'); - const bean = __.newBean('com.enonic.xp.lib.content.AddAttachmentHandler'); + const bean: AddAttachmentHandler = __.newBean('com.enonic.xp.lib.content.AddAttachmentHandler'); bean.setKey(params.key); bean.setName(params.name); @@ -323,7 +323,7 @@ export function removeAttachment(params: RemoveAttachmentParams): void { name = [], } = params ?? {}; - const bean = __.newBean('com.enonic.xp.lib.content.RemoveAttachmentHandler'); + const bean: RemoveAttachmentHandler = __.newBean('com.enonic.xp.lib.content.RemoveAttachmentHandler'); bean.setKey(key); bean.setName(([] as string[]).concat(name)); bean.execute(); @@ -362,7 +362,7 @@ interface GetSiteHandler { export function getSite>(params: GetSiteParams): Site | null { checkRequired(params, 'key'); - const bean = __.newBean('com.enonic.xp.lib.content.GetSiteHandler'); + const bean: GetSiteHandler = __.newBean('com.enonic.xp.lib.content.GetSiteHandler'); bean.setKey(params.key); return __.toNativeObject(bean.execute()); } @@ -392,7 +392,7 @@ interface GetSiteConfigHandler { * @returns {object} The site configuration for current application as JSON. */ export function getSiteConfig>(params: GetSiteConfigParams): Config | null { - const bean = __.newBean('com.enonic.xp.lib.content.GetSiteConfigHandler'); + const bean: GetSiteConfigHandler = __.newBean('com.enonic.xp.lib.content.GetSiteConfigHandler'); bean.setKey(__.nullOrValue(params.key)); bean.setApplicationKey(__.nullOrValue(params.applicationKey)); @@ -423,7 +423,7 @@ interface DeleteContentHandler { function _delete(params: DeleteContentParams): boolean { checkRequired(params, 'key'); - const bean = __.newBean('com.enonic.xp.lib.content.DeleteContentHandler'); + const bean: DeleteContentHandler = __.newBean('com.enonic.xp.lib.content.DeleteContentHandler'); bean.setKey(params.key); return bean.execute(); } @@ -491,7 +491,7 @@ export function getChildren< sort, } = params ?? {}; - const bean = __.newBean('com.enonic.xp.lib.content.GetChildContentHandler'); + const bean: GetChildContentHandler = __.newBean('com.enonic.xp.lib.content.GetChildContentHandler'); bean.setKey(key); bean.setStart(start); bean.setCount(count); @@ -590,7 +590,7 @@ export function create< workflow, } = params ?? {}; - const bean = __.newBean('com.enonic.xp.lib.content.CreateContentHandler'); + const bean: CreateContentHandler = __.newBean('com.enonic.xp.lib.content.CreateContentHandler'); bean.setName(__.nullOrValue(name)); bean.setParentPath(__.nullOrValue(parentPath)); @@ -665,7 +665,7 @@ export function query< Hit extends Content = Content, AggregationInput extends Aggregations = never >(params: QueryContentParams): ContentsResult> { - const bean = __.newBean('com.enonic.xp.lib.content.QueryContentHandler'); + const bean: QueryContentHandler = __.newBean('com.enonic.xp.lib.content.QueryContentHandler'); bean.setStart(params.start); bean.setCount(params.count); @@ -716,7 +716,7 @@ export function modify, Type extends string = str requireValid = true, } = params ?? {}; - const bean = __.newBean('com.enonic.xp.lib.content.ModifyContentHandler'); + const bean: ModifyContentHandler = __.newBean('com.enonic.xp.lib.content.ModifyContentHandler'); bean.setKey(key); bean.setEditor(__.toScriptValue(editor)); @@ -776,7 +776,7 @@ interface PublishContentHandler { export function publish(params: PublishContentParams): PublishContentResult { checkRequired(params, 'keys'); - const bean = __.newBean('com.enonic.xp.lib.content.PublishContentHandler'); + const bean: PublishContentHandler = __.newBean('com.enonic.xp.lib.content.PublishContentHandler'); bean.setKeys(params.keys); if (params.schedule) { bean.setContentPublishInfo(__.toScriptValue(params.schedule)); @@ -818,7 +818,7 @@ interface UnpublishContentHandler { export function unpublish(params: UnpublishContentParams): string[] { checkRequired(params, 'keys'); - const bean = __.newBean('com.enonic.xp.lib.content.UnpublishContentHandler'); + const bean: UnpublishContentHandler = __.newBean('com.enonic.xp.lib.content.UnpublishContentHandler'); bean.setKeys(params.keys); return __.toNativeObject(bean.execute()); } @@ -846,7 +846,7 @@ interface ContentExistsHandler { export function exists(params: ContentExistsParams): boolean { checkRequired(params, 'key'); - const bean = __.newBean('com.enonic.xp.lib.content.ContentExistsHandler'); + const bean: ContentExistsHandler = __.newBean('com.enonic.xp.lib.content.ContentExistsHandler'); bean.setKey(params.key); @@ -899,7 +899,7 @@ interface CreateMediaHandler { export function createMedia, Type extends string = string>(params: CreateMediaParams): Content { checkRequired(params, 'name'); - const bean = __.newBean('com.enonic.xp.lib.content.CreateMediaHandler'); + const bean: CreateMediaHandler = __.newBean('com.enonic.xp.lib.content.CreateMediaHandler'); bean.setName(params.name); bean.setParentPath(__.nullOrValue(params.parentPath)); @@ -945,7 +945,7 @@ export function move, Type extends string = strin checkRequired(params, 'source'); checkRequired(params, 'target'); - const bean = __.newBean('com.enonic.xp.lib.content.MoveContentHandler'); + const bean: MoveContentHandler = __.newBean('com.enonic.xp.lib.content.MoveContentHandler'); bean.setSource(params.source); bean.setTarget(params.target); @@ -976,7 +976,7 @@ interface ArchiveContentHandler { export function archive(params: ArchiveContentParams): string[] { checkRequired(params, 'content'); - const bean = __.newBean('com.enonic.xp.lib.content.ArchiveContentHandler'); + const bean: ArchiveContentHandler = __.newBean('com.enonic.xp.lib.content.ArchiveContentHandler'); bean.setContent(params.content); return __.toNativeObject(bean.execute()); } @@ -1008,7 +1008,7 @@ interface RestoreContentHandler { export function restore(params: RestoreContentParams): string[] { checkRequired(params, 'content'); - const bean = __.newBean('com.enonic.xp.lib.content.RestoreContentHandler'); + const bean: RestoreContentHandler = __.newBean('com.enonic.xp.lib.content.RestoreContentHandler'); bean.setContent(params.content); bean.setPath(__.nullOrValue(params.path)); return __.toNativeObject(bean.execute()); @@ -1085,7 +1085,7 @@ interface ApplyPermissionsHandler { * @returns {boolean} True if successful, false otherwise. */ export function setPermissions(params: SetPermissionsParams): boolean { - const bean = __.newBean('com.enonic.xp.lib.content.ApplyPermissionsHandler'); + const bean: ApplyPermissionsHandler = __.newBean('com.enonic.xp.lib.content.ApplyPermissionsHandler'); if (params.key) { bean.setKey(params.key); @@ -1093,10 +1093,10 @@ export function setPermissions(params: SetPermissionsParams): boolean { if (params.permissions) { bean.setPermissions(__.toScriptValue(params.permissions)); } - const result = bean.execute(); + const result: ApplyPermissionsResult = bean.execute(); for (const nodeId in result) { - const branchResults = result[nodeId]; + const branchResults: BranchResult[] = result.nodeId; for (const branchResult of branchResults) { if (branchResult.content !== null) { return true; @@ -1125,7 +1125,7 @@ export function setPermissions(params: SetPermissionsParams): boolean { * @returns {object} Result of the apply permissions operation. */ export function applyPermissions(params: ApplyPermissionsParams): ApplyPermissionsResult { - const bean = __.newBean('com.enonic.xp.lib.content.ApplyPermissionsHandler'); + const bean: ApplyPermissionsHandler = __.newBean('com.enonic.xp.lib.content.ApplyPermissionsHandler'); if (params.key) { bean.setKey(params.key); @@ -1166,7 +1166,7 @@ interface GetPermissionsHandler { * @returns {object} Content permissions. */ export function getPermissions(params: GetPermissionsParams): Permissions | null { - const bean = __.newBean('com.enonic.xp.lib.content.GetPermissionsHandler'); + const bean: GetPermissionsHandler = __.newBean('com.enonic.xp.lib.content.GetPermissionsHandler'); if (params.key) { bean.setKey(params.key); @@ -1228,7 +1228,7 @@ interface ContentTypeHandler { * @returns {ContentType} The content type object if found, or null otherwise. See ContentType type definition below. */ export function getType(name: string): ContentType | null { - const bean = __.newBean('com.enonic.xp.lib.content.ContentTypeHandler'); + const bean: ContentTypeHandler = __.newBean('com.enonic.xp.lib.content.ContentTypeHandler'); bean.setName(__.nullOrValue(name)); return __.toNativeObject(bean.getContentType()); } @@ -1241,7 +1241,7 @@ export function getType(name: string): ContentType | null { * @returns {ContentType[]} Array with all the content types found. See ContentType type definition below. */ export function getTypes(): ContentType[] { - const bean = __.newBean('com.enonic.xp.lib.content.ContentTypeHandler'); + const bean: ContentTypeHandler = __.newBean('com.enonic.xp.lib.content.ContentTypeHandler'); return __.toNativeObject(bean.getAllContentTypes()); } @@ -1265,7 +1265,7 @@ interface GetOutboundDependenciesHandler { export function getOutboundDependencies(params: GetOutboundDependenciesParams): string[] { checkRequired(params, 'key'); - const bean = __.newBean('com.enonic.xp.lib.content.GetOutboundDependenciesHandler'); + const bean: GetOutboundDependenciesHandler = __.newBean('com.enonic.xp.lib.content.GetOutboundDependenciesHandler'); bean.setKey(params.key); @@ -1300,7 +1300,7 @@ export function resetInheritance(params: ResetInheritanceParams): void { checkRequired(params, 'projectName'); checkRequired(params, 'inherit'); - const bean = __.newBean('com.enonic.xp.lib.content.ResetInheritanceHandler'); + const bean: ResetInheritanceHandler = __.newBean('com.enonic.xp.lib.content.ResetInheritanceHandler'); bean.setKey(params.key); bean.setProjectName(params.projectName); @@ -1392,7 +1392,7 @@ export function modifyMedia, Type extends string tags = [], } = params; - const bean = __.newBean('com.enonic.xp.lib.content.ModifyMediaHandler'); + const bean: ModifyMediaHandler = __.newBean('com.enonic.xp.lib.content.ModifyMediaHandler'); bean.setKey(key); bean.setName(name); @@ -1471,7 +1471,7 @@ export function duplicate(params: DuplicateContentParams): DuplicateContentsResu name, } = params ?? {}; - const bean = __.newBean('com.enonic.xp.lib.content.DuplicateContentHandler'); + const bean: DuplicateContentHandler = __.newBean('com.enonic.xp.lib.content.DuplicateContentHandler'); bean.setContentId(contentId); bean.setWorkflow(__.toScriptValue(workflow)); diff --git a/modules/lib/lib-context/src/main/resources/lib/xp/context.ts b/modules/lib/lib-context/src/main/resources/lib/xp/context.ts index 8b0b4f818d7..6415b886aea 100644 --- a/modules/lib/lib-context/src/main/resources/lib/xp/context.ts +++ b/modules/lib/lib-context/src/main/resources/lib/xp/context.ts @@ -68,7 +68,7 @@ interface ContextHandler { newRunParams(): ContextRunParams; } -const bean = __.newBean('com.enonic.xp.lib.context.ContextHandlerBean'); +const bean: ContextHandler = __.newBean('com.enonic.xp.lib.context.ContextHandlerBean'); /** * Runs a function within a specified context. @@ -87,7 +87,7 @@ const bean = __.newBean('com.enonic.xp.lib.context.ContextHandle * @returns {object} Result of the function execution. */ export function run(context: ContextParams, callback: () => T): T { - const params = bean.newRunParams(); + const params: ContextRunParams = bean.newRunParams(); params.setCallback(callback); if (context.repository) { diff --git a/modules/lib/lib-event/src/main/resources/lib/xp/event.ts b/modules/lib/lib-event/src/main/resources/lib/xp/event.ts index 4230ccbcd05..caa15ac277f 100644 --- a/modules/lib/lib-event/src/main/resources/lib/xp/event.ts +++ b/modules/lib/lib-event/src/main/resources/lib/xp/event.ts @@ -93,7 +93,7 @@ interface EventListenerHelper { * @param {boolean} params.localOnly Local events only (default to false). */ export function listener(params: ListenerParams): void { - const helper = __.newBean('com.enonic.xp.lib.event.EventListenerHelper'); + const helper: EventListenerHelper = __.newBean('com.enonic.xp.lib.event.EventListenerHelper'); helper.setType(params.type ?? ''); helper.setLocalOnly(params.localOnly === true); @@ -113,7 +113,7 @@ export function listener(params: Lis * @param {object} event.data Additional data for event. */ export function send(event: SendParams): void { - const helper = __.newBean('com.enonic.xp.lib.event.EventSenderHelper'); + const helper: EventSenderHelper = __.newBean('com.enonic.xp.lib.event.EventSenderHelper'); helper.setType(event.type ?? 'test'); helper.setDistributed(event.distributed === true); diff --git a/modules/lib/lib-export/src/main/resources/lib/xp/export.ts b/modules/lib/lib-export/src/main/resources/lib/xp/export.ts index 754c6b5aacc..f00aea0ede6 100644 --- a/modules/lib/lib-export/src/main/resources/lib/xp/export.ts +++ b/modules/lib/lib-export/src/main/resources/lib/xp/export.ts @@ -101,7 +101,7 @@ export function importNodes(params: ImportNodesParams): ImportNodesResult { nodeImported, } = params ?? {}; - const bean = __.newBean('com.enonic.xp.lib.export.ImportHandler'); + const bean: ImportHandler = __.newBean('com.enonic.xp.lib.export.ImportHandler'); bean.setSource(source); bean.setTargetNodePath(targetNodePath); @@ -179,7 +179,7 @@ export function exportNodes(params: ExportNodesParams): ExportNodesResult { nodeExported, } = params ?? {}; - const bean = __.newBean('com.enonic.xp.lib.export.ExportHandler'); + const bean: ExportHandler = __.newBean('com.enonic.xp.lib.export.ExportHandler'); bean.setSourceNodePath(sourceNodePath); bean.setExportName(exportName); diff --git a/modules/lib/lib-grid/src/main/resources/lib/xp/grid.ts b/modules/lib/lib-grid/src/main/resources/lib/xp/grid.ts index a1806cb7e80..37a360ad91b 100644 --- a/modules/lib/lib-grid/src/main/resources/lib/xp/grid.ts +++ b/modules/lib/lib-grid/src/main/resources/lib/xp/grid.ts @@ -6,6 +6,7 @@ * * @module grid */ +import {ScriptValue} from '@enonic-types/core'; declare global { interface XpLibraries { @@ -160,9 +161,11 @@ function convertValue(value: SharedMapValueType): ConvertedType { if (typeof value === 'undefined' || value === null) { return null; } else if (Array.isArray(value)) { - return __.toScriptValue(value).getList(); + const sv: ScriptValue = __.toScriptValue(value); + return sv.getList(); } else if (typeof value === 'object') { - return __.toScriptValue(value).getMap(); + const sv: ScriptValue = __.toScriptValue(value); + return sv.getMap(); } else { return value; } diff --git a/modules/lib/lib-i18n/src/main/resources/lib/xp/i18n.ts b/modules/lib/lib-i18n/src/main/resources/lib/xp/i18n.ts index 3149f6e5612..3d86498e21d 100644 --- a/modules/lib/lib-i18n/src/main/resources/lib/xp/i18n.ts +++ b/modules/lib/lib-i18n/src/main/resources/lib/xp/i18n.ts @@ -50,7 +50,7 @@ interface LocaleScriptBean { * @returns {string} The localized string. */ export function localize(params: LocalizeParams): string { - const bean = __.newBean('com.enonic.xp.lib.i18n.LocaleScriptBean'); + const bean: LocaleScriptBean = __.newBean('com.enonic.xp.lib.i18n.LocaleScriptBean'); const { key, @@ -82,7 +82,7 @@ export function localize(params: LocalizeParams): string { * i18nLib.getPhrases('en', ['i18n/phrases']) */ export function getPhrases(locale: string | string[], bundles: string[]): Record { - const bean = __.newBean('com.enonic.xp.lib.i18n.LocaleScriptBean'); + const bean: LocaleScriptBean = __.newBean('com.enonic.xp.lib.i18n.LocaleScriptBean'); const locales: string[] = ([] as string[]).concat(locale); return __.toNativeObject(bean.getPhrases(locales, bundles)); } @@ -95,6 +95,6 @@ export function getPhrases(locale: string | string[], bundles: string[]): Record * @returns {string[]} A list of supported locale codes for the specified bundles. */ export function getSupportedLocales(bundles: string[]): string[] { - const bean = __.newBean('com.enonic.xp.lib.i18n.LocaleScriptBean'); + const bean: LocaleScriptBean = __.newBean('com.enonic.xp.lib.i18n.LocaleScriptBean'); return __.toNativeObject(bean.getSupportedLocales(bundles)); } diff --git a/modules/lib/lib-io/src/main/resources/lib/xp/io.ts b/modules/lib/lib-io/src/main/resources/lib/xp/io.ts index 64fae2bba7a..7c2e05fa9d2 100644 --- a/modules/lib/lib-io/src/main/resources/lib/xp/io.ts +++ b/modules/lib/lib-io/src/main/resources/lib/xp/io.ts @@ -51,7 +51,7 @@ interface IOHandlerBean { getResource(key: string | ResourceKey): JavaResource; } -const bean = __.newBean('com.enonic.xp.lib.io.IOHandlerBean'); +const bean: IOHandlerBean = __.newBean('com.enonic.xp.lib.io.IOHandlerBean'); /** * Looks up a resource. @@ -65,7 +65,7 @@ class ResourceImpl private res: JavaResource; constructor(key: string | ResourceKey) { - this.res = bean.getResource(key); + this.res = bean.getResource(key) ; } /** diff --git a/modules/lib/lib-mail/src/main/resources/lib/xp/mail.ts b/modules/lib/lib-mail/src/main/resources/lib/xp/mail.ts index 65cc0b8e2a8..f95db170384 100644 --- a/modules/lib/lib-mail/src/main/resources/lib/xp/mail.ts +++ b/modules/lib/lib-mail/src/main/resources/lib/xp/mail.ts @@ -100,7 +100,7 @@ export interface SendMessageParams { * @returns {boolean} True if the message was sent successfully, false otherwise. */ export function send(params: SendMessageParams): boolean { - const bean = __.newBean('com.enonic.xp.lib.mail.SendMailHandler'); + const bean: SendMailHandler = __.newBean('com.enonic.xp.lib.mail.SendMailHandler'); checkRequired(params, 'from'); checkRequired(params, 'to'); @@ -143,6 +143,6 @@ interface GetDefaultFromEmailHandler { * @returns {string} The default from mail address, or null if not set. */ export function getDefaultFromEmail(): string | null { - const bean = __.newBean('com.enonic.xp.lib.mail.GetDefaultFromEmailHandler'); + const bean: GetDefaultFromEmailHandler = __.newBean('com.enonic.xp.lib.mail.GetDefaultFromEmailHandler'); return bean.execute(); } diff --git a/modules/lib/lib-node/src/main/resources/lib/xp/node.ts b/modules/lib/lib-node/src/main/resources/lib/xp/node.ts index e6961239f3f..9e36886bdaa 100644 --- a/modules/lib/lib-node/src/main/resources/lib/xp/node.ts +++ b/modules/lib/lib-node/src/main/resources/lib/xp/node.ts @@ -100,7 +100,7 @@ function assertStringArray(value: unknown, name: string): asserts value is strin if (!Array.isArray(value)) { throw new TypeError(`${name} must be an array of strings! Isn't even an array!`); } - + if (!value.every(item => typeof item === 'string')) { throw new TypeError(`${name} must be an array of strings! Is an array, but contains non-string elements!`); } @@ -181,9 +181,9 @@ interface MultiRepoNodeHandleFactory { create(context: MultiRepoNodeHandleContext): MultiRepoNodeHandler; } -const factory = __.newBean('com.enonic.xp.lib.node.NodeHandleFactory'); +const factory: NodeHandleFactory = __.newBean('com.enonic.xp.lib.node.NodeHandleFactory'); -const multiRepoConnectFactory = __.newBean('com.enonic.xp.lib.node.MultiRepoNodeHandleFactory'); +const multiRepoConnectFactory: MultiRepoNodeHandleFactory = __.newBean('com.enonic.xp.lib.node.MultiRepoNodeHandleFactory'); function argsToStringArray(argsArray: (string | string[])[]): string[] { const array: string[] = []; @@ -779,7 +779,7 @@ class RepoConnectionImpl throw "Parameter key' or 'keys' is required"; } - const handlerParams = __.newBean('com.enonic.xp.lib.node.PushNodeHandlerParams'); + const handlerParams: PushNodeHandlerParams = __.newBean('com.enonic.xp.lib.node.PushNodeHandlerParams'); handlerParams.setKey(__.nullOrValue(key)); handlerParams.setKeys(__.nullOrValue(keys)); @@ -810,7 +810,7 @@ class RepoConnectionImpl includeChildren = false, } = params ?? {}; - const handlerParams = __.newBean('com.enonic.xp.lib.node.DiffBranchesHandlerParams'); + const handlerParams: DiffBranchesHandlerParams = __.newBean('com.enonic.xp.lib.node.DiffBranchesHandlerParams'); handlerParams.setKey(key); handlerParams.setTargetBranch(target); @@ -901,7 +901,7 @@ class RepoConnectionImpl explain = false, } = params ?? {}; - const handlerParams = __.newBean('com.enonic.xp.lib.node.QueryNodeHandlerParams'); + const handlerParams: QueryNodeHandlerParams = __.newBean('com.enonic.xp.lib.node.QueryNodeHandlerParams'); handlerParams.setStart(start); handlerParams.setCount(count); @@ -949,7 +949,7 @@ class RepoConnectionImpl count = 10, } = params ?? {}; - const handlerParams = __.newBean('com.enonic.xp.lib.node.FindVersionsHandlerParams'); + const handlerParams: FindVersionsHandlerParams = __.newBean('com.enonic.xp.lib.node.FindVersionsHandlerParams'); handlerParams.setKey(key); handlerParams.setStart(start); @@ -1016,7 +1016,7 @@ class RepoConnectionImpl recursive = false, } = params ?? {}; - const handlerParams = __.newBean('com.enonic.xp.lib.node.FindChildrenHandlerParams'); + const handlerParams: FindChildrenHandlerParams = __.newBean('com.enonic.xp.lib.node.FindChildrenHandlerParams'); handlerParams.setParentKey(parentKey); handlerParams.setStart(start); @@ -1142,7 +1142,7 @@ class RepoConnectionImpl refresh, } = params ?? {}; - const handlerParams = __.newBean('com.enonic.xp.lib.node.DuplicateNodeHandlerParams'); + const handlerParams: DuplicateNodeHandlerParams = __.newBean('com.enonic.xp.lib.node.DuplicateNodeHandlerParams'); handlerParams.setNodeId(nodeId); handlerParams.setIncludeChildren(includeChildren); @@ -1211,7 +1211,7 @@ class MultiRepoConnectionImpl explain = false, } = params ?? {}; - const handlerParams = __.newBean('com.enonic.xp.lib.node.QueryNodeHandlerParams'); + const handlerParams: QueryNodeHandlerParams = __.newBean('com.enonic.xp.lib.node.QueryNodeHandlerParams'); handlerParams.setStart(start); handlerParams.setCount(count); @@ -1267,7 +1267,7 @@ export function connect(params: ConnectParams): RepoConnection { checkRequired(params, 'repoId'); checkRequired(params, 'branch'); - const nodeHandleContext = __.newBean('com.enonic.xp.lib.node.NodeHandleContext'); + const nodeHandleContext: NodeHandleContext = __.newBean('com.enonic.xp.lib.node.NodeHandleContext'); nodeHandleContext.setRepoId(params.repoId); nodeHandleContext.setBranch(params.branch); @@ -1306,7 +1306,7 @@ export interface MultiRepoConnectParams { * @returns {MultiRepoConnection} Returns a new multirepo-connection. */ export function multiRepoConnect(params: MultiRepoConnectParams): MultiRepoConnection { - const multiRepoNodeHandleContext = __.newBean('com.enonic.xp.lib.node.MultiRepoNodeHandleContext'); + const multiRepoNodeHandleContext: MultiRepoNodeHandleContext = __.newBean('com.enonic.xp.lib.node.MultiRepoNodeHandleContext'); params.sources.forEach((source: ConnectParams) => { checkRequired(source, 'repoId'); diff --git a/modules/lib/lib-portal/src/main/resources/lib/xp/portal.ts b/modules/lib/lib-portal/src/main/resources/lib/xp/portal.ts index 89d89b490c4..fca9d82b3a7 100644 --- a/modules/lib/lib-portal/src/main/resources/lib/xp/portal.ts +++ b/modules/lib/lib-portal/src/main/resources/lib/xp/portal.ts @@ -76,7 +76,7 @@ interface AssetUrlHandler { * @returns {string} The generated URL. */ export function assetUrl(params: AssetUrlParams): string { - const bean = __.newBean('com.enonic.xp.lib.portal.url.AssetUrlHandler'); + const bean: AssetUrlHandler = __.newBean('com.enonic.xp.lib.portal.url.AssetUrlHandler'); return bean.createUrl(__.toScriptValue(params)); } @@ -121,7 +121,7 @@ interface ImageUrlHandler { * @returns {string} The generated URL. */ export function imageUrl(params: ImageUrlParams): string { - const bean = __.newBean('com.enonic.xp.lib.portal.url.ImageUrlHandler'); + const bean: ImageUrlHandler = __.newBean('com.enonic.xp.lib.portal.url.ImageUrlHandler'); return bean.createUrl(__.toScriptValue(params)); } @@ -152,7 +152,7 @@ interface ComponentUrlHandler { * @returns {string} The generated URL. */ export function componentUrl(params: ComponentUrlParams): string { - const bean = __.newBean('com.enonic.xp.lib.portal.url.ComponentUrlHandler'); + const bean: ComponentUrlHandler = __.newBean('com.enonic.xp.lib.portal.url.ComponentUrlHandler'); return bean.createUrl(__.toScriptValue(params)); } @@ -187,7 +187,7 @@ interface AttachmentUrlHandler { * @returns {string} The generated URL. */ export function attachmentUrl(params: AttachmentUrlParams): string { - const bean = __.newBean('com.enonic.xp.lib.portal.url.AttachmentUrlHandler'); + const bean: AttachmentUrlHandler = __.newBean('com.enonic.xp.lib.portal.url.AttachmentUrlHandler'); return bean.createUrl(__.toScriptValue(params)); } @@ -214,7 +214,7 @@ interface PageUrlHandler { * @returns {string} The generated URL. */ export function pageUrl(params: PageUrlParams): string { - const bean = __.newBean('com.enonic.xp.lib.portal.url.PageUrlHandler'); + const bean: PageUrlHandler = __.newBean('com.enonic.xp.lib.portal.url.PageUrlHandler'); return bean.createUrl(__.toScriptValue(params)); } @@ -243,7 +243,7 @@ interface ServiceUrlHandler { * @returns {string} The generated URL. */ export function serviceUrl(params: ServiceUrlParams): string { - const bean = __.newBean('com.enonic.xp.lib.portal.url.ServiceUrlHandler'); + const bean: ServiceUrlHandler = __.newBean('com.enonic.xp.lib.portal.url.ServiceUrlHandler'); return bean.createUrl(__.toScriptValue(params)); } @@ -272,7 +272,7 @@ interface IdProviderUrlHandler { * @returns {string} The generated URL. */ export function idProviderUrl(params: IdProviderUrlParams): string { - const bean = __.newBean('com.enonic.xp.lib.portal.url.IdProviderUrlHandler'); + const bean: IdProviderUrlHandler = __.newBean('com.enonic.xp.lib.portal.url.IdProviderUrlHandler'); return bean.createUrl(__.toScriptValue(params ?? {})); } @@ -303,7 +303,7 @@ interface LoginUrlHandler { * @returns {string} The generated URL. */ export function loginUrl(params: LoginUrlParams): string { - const bean = __.newBean('com.enonic.xp.lib.portal.url.LoginUrlHandler'); + const bean: LoginUrlHandler = __.newBean('com.enonic.xp.lib.portal.url.LoginUrlHandler'); return bean.createUrl(__.toScriptValue(params ?? {})); } @@ -331,7 +331,7 @@ interface LogoutUrlHandler { * @returns {string} The generated URL. */ export function logoutUrl(params: LogoutUrlParams): string { - const bean = __.newBean('com.enonic.xp.lib.portal.url.LogoutUrlHandler'); + const bean: LogoutUrlHandler = __.newBean('com.enonic.xp.lib.portal.url.LogoutUrlHandler'); return bean.createUrl(__.toScriptValue(params ?? {})); } @@ -358,7 +358,7 @@ interface UrlHandler { * @returns {string} The generated URL. */ export function url(params: UrlParams): string { - const bean = __.newBean('com.enonic.xp.lib.portal.url.UrlHandler'); + const bean: UrlHandler = __.newBean('com.enonic.xp.lib.portal.url.UrlHandler'); return bean.createUrl(__.toScriptValue(params)); } @@ -389,7 +389,7 @@ interface ProcessHtmlHandler { * @returns {string} The processed HTML. */ export function processHtml(params: ProcessHtmlParams): string { - const bean = __.newBean('com.enonic.xp.lib.portal.url.ProcessHtmlHandler'); + const bean: ProcessHtmlHandler = __.newBean('com.enonic.xp.lib.portal.url.ProcessHtmlHandler'); return bean.createUrl(__.toScriptValue(params)); } @@ -409,7 +409,7 @@ interface SanitizeHtmlHandler { * @returns {string} The sanitized HTML. */ export function sanitizeHtml(html: string): string { - const bean = __.newBean('com.enonic.xp.lib.portal.SanitizeHtmlHandler'); + const bean: SanitizeHtmlHandler = __.newBean('com.enonic.xp.lib.portal.SanitizeHtmlHandler'); return __.toNativeObject(bean.sanitizeHtml(html)); } @@ -426,7 +426,7 @@ interface GetCurrentSiteHandler { * @returns {object|null} The current site as JSON. */ export function getSite>(): Site | null { - const bean = __.newBean('com.enonic.xp.lib.portal.current.GetCurrentSiteHandler'); + const bean: GetCurrentSiteHandler = __.newBean('com.enonic.xp.lib.portal.current.GetCurrentSiteHandler'); return __.toNativeObject(bean.execute()); } @@ -443,7 +443,7 @@ interface GetCurrentSiteConfigHandler { * @returns {object|null} The site configuration for current application as JSON. */ export function getSiteConfig>(): Config | null { - const bean = __.newBean('com.enonic.xp.lib.portal.current.GetCurrentSiteConfigHandler'); + const bean: GetCurrentSiteConfigHandler = __.newBean('com.enonic.xp.lib.portal.current.GetCurrentSiteConfigHandler'); return __.toNativeObject(bean.execute()); } @@ -460,7 +460,7 @@ interface GetCurrentContentHandler { * @returns {object|null} The current content as JSON. */ export function getContent = Content>(): Hit | null { - const bean = __.newBean('com.enonic.xp.lib.portal.current.GetCurrentContentHandler'); + const bean: GetCurrentContentHandler = __.newBean('com.enonic.xp.lib.portal.current.GetCurrentContentHandler'); return __.toNativeObject(bean.execute()); } @@ -479,7 +479,7 @@ interface GetCurrentComponentHandler<_Component extends Component = Component> { export function getComponent< _Component extends Component = Component >(): _Component | null { - const bean = __.newBean>('com.enonic.xp.lib.portal.current.GetCurrentComponentHandler'); + const bean: GetCurrentComponentHandler<_Component> = __.newBean>('com.enonic.xp.lib.portal.current.GetCurrentComponentHandler'); return __.toNativeObject(bean.execute()); } @@ -495,7 +495,7 @@ interface GetCurrentIdProviderKeyHandler { * @returns {string|null} The current id provider as JSON. */ export function getIdProviderKey(): string | null { - const bean = __.newBean('com.enonic.xp.lib.portal.current.GetCurrentIdProviderKeyHandler'); + const bean: GetCurrentIdProviderKeyHandler = __.newBean('com.enonic.xp.lib.portal.current.GetCurrentIdProviderKeyHandler'); return __.toNativeObject(bean.execute()); } @@ -528,7 +528,7 @@ interface MultipartHandler { * @returns {object} The multipart form items. */ export function getMultipartForm(): MultipartForm { - const bean = __.newBean('com.enonic.xp.lib.portal.multipart.MultipartHandler'); + const bean: MultipartHandler = __.newBean('com.enonic.xp.lib.portal.multipart.MultipartHandler'); return __.toNativeObject(bean.getForm()); } @@ -543,7 +543,7 @@ export function getMultipartForm(): MultipartForm { * @returns {object|null} The named multipart form item. */ export function getMultipartItem(name: string, index = 0): MultipartItem | null { - const bean = __.newBean('com.enonic.xp.lib.portal.multipart.MultipartHandler'); + const bean: MultipartHandler = __.newBean('com.enonic.xp.lib.portal.multipart.MultipartHandler'); return __.toNativeObject(bean.getItem(name, index)); } @@ -558,7 +558,7 @@ export function getMultipartItem(name: string, index = 0): MultipartItem | null * @returns {*} Stream of multipart item data. */ export function getMultipartStream(name: string, index = 0): ByteSource | null { - const bean = __.newBean('com.enonic.xp.lib.portal.multipart.MultipartHandler'); + const bean: MultipartHandler = __.newBean('com.enonic.xp.lib.portal.multipart.MultipartHandler'); return bean.getBytes(name, index); } @@ -573,7 +573,7 @@ export function getMultipartStream(name: string, index = 0): ByteSource | null { * @returns {string|null} Text for multipart item data. */ export function getMultipartText(name: string, index = 0): string | null { - const bean = __.newBean('com.enonic.xp.lib.portal.multipart.MultipartHandler'); + const bean: MultipartHandler = __.newBean('com.enonic.xp.lib.portal.multipart.MultipartHandler'); return bean.getText(name, index); } @@ -602,7 +602,7 @@ interface ImagePlaceholderHandler { * @returns {string} Placeholder image URL. */ export function imagePlaceholder(params: ImagePlaceholderParams): string { - const bean = __.newBean('com.enonic.xp.lib.portal.url.ImagePlaceholderHandler'); + const bean: ImagePlaceholderHandler = __.newBean('com.enonic.xp.lib.portal.url.ImagePlaceholderHandler'); bean.setWidth(params?.width ?? 0); bean.setHeight(params?.height ?? 0); return bean.createImagePlaceholder(); @@ -647,12 +647,12 @@ export function apiUrl(urlParams: ApiUrlParams): string { params, } = urlParams ?? {}; - const bean = __.newBean('com.enonic.xp.lib.portal.url.ApiUrlHandler'); + const bean: ApiUrlHandler = __.newBean('com.enonic.xp.lib.portal.url.ApiUrlHandler'); if (path) { if (Array.isArray(path)) { bean.setPath(__.toScriptValue(path)); } else { - bean.setPath(path as string); + bean.setPath(path); } } diff --git a/modules/lib/lib-project/src/main/resources/lib/xp/project.ts b/modules/lib/lib-project/src/main/resources/lib/xp/project.ts index 71949739d87..0120ff2106b 100644 --- a/modules/lib/lib-project/src/main/resources/lib/xp/project.ts +++ b/modules/lib/lib-project/src/main/resources/lib/xp/project.ts @@ -111,7 +111,7 @@ export function create = Record>('com.enonic.xp.lib.project.CreateProjectHandler'); + const bean: CreateProjectHandler = __.newBean>('com.enonic.xp.lib.project.CreateProjectHandler'); bean.setId(params.id); bean.setDisplayName(params.displayName); bean.setDescription(__.nullOrValue(params.description)); @@ -169,7 +169,7 @@ interface ModifyProjectHandler> { export function modify = Record>(params: ModifyProjectParams): Project { checkRequired(params, 'id'); - const bean = __.newBean>('com.enonic.xp.lib.project.ModifyProjectHandler'); + const bean: ModifyProjectHandler = __.newBean>('com.enonic.xp.lib.project.ModifyProjectHandler'); bean.setId(params.id); bean.setDisplayName(__.nullOrValue(params.displayName)); bean.setDescription(__.nullOrValue(params.description)); @@ -203,7 +203,7 @@ interface DeleteProjectHandler { export function _delete(params: DeleteProjectParams): boolean { checkRequired(params, 'id'); - const bean = __.newBean('com.enonic.xp.lib.project.DeleteProjectHandler'); + const bean: DeleteProjectHandler = __.newBean('com.enonic.xp.lib.project.DeleteProjectHandler'); bean.setId(params.id); @@ -238,7 +238,7 @@ interface GetProjectHandler { export function get(params: GetProjectParams): Project | null { checkRequired(params, 'id'); - const bean = __.newBean('com.enonic.xp.lib.project.GetProjectHandler'); + const bean: GetProjectHandler = __.newBean('com.enonic.xp.lib.project.GetProjectHandler'); bean.setId(params.id); return __.toNativeObject(bean.execute()); } @@ -268,7 +268,7 @@ interface GetAvailableApplicationsHandler { export function getAvailableApplications(params: GetAvailableApplicationsParams): string[] { checkRequired(params, 'id'); - const bean = __.newBean('com.enonic.xp.lib.project.GetAvailableApplicationsHandler'); + const bean: GetAvailableApplicationsHandler = __.newBean('com.enonic.xp.lib.project.GetAvailableApplicationsHandler'); bean.setId(params.id); return __.toNativeObject(bean.execute()); } @@ -287,7 +287,7 @@ interface ListProjectsHandler { * @returns {Project[]} Array of Content Project objects. */ export function list(): Project[] { - const bean = __.newBean('com.enonic.xp.lib.project.ListProjectsHandler'); + const bean: ListProjectsHandler = __.newBean('com.enonic.xp.lib.project.ListProjectsHandler'); return __.toNativeObject(bean.execute()); } @@ -323,7 +323,7 @@ interface AddProjectPermissionsHandler { export function addPermissions(params: AddProjectPermissionsParams): ProjectPermissions | null { checkRequired(params, 'id'); - const bean = __.newBean('com.enonic.xp.lib.project.AddProjectPermissionsHandler'); + const bean: AddProjectPermissionsHandler = __.newBean('com.enonic.xp.lib.project.AddProjectPermissionsHandler'); bean.setId(params.id); bean.setPermissions(__.toScriptValue(params.permissions)); return __.toNativeObject(bean.execute()); @@ -359,7 +359,7 @@ interface RemoveProjectPermissionsHandler { export function removePermissions(params: RemoveProjectPermissionsParams): ProjectPermissions | null { checkRequired(params, 'id'); - const bean = __.newBean('com.enonic.xp.lib.project.RemoveProjectPermissionsHandler'); + const bean: RemoveProjectPermissionsHandler = __.newBean('com.enonic.xp.lib.project.RemoveProjectPermissionsHandler'); bean.setId(params.id); bean.setPermissions(__.toScriptValue(params.permissions)); @@ -396,7 +396,7 @@ interface ModifyProjectReadAccessHandler { export function modifyReadAccess(params: ModifyProjectReadAccessParams): ProjectReadAccess | null { checkRequired(params, 'id'); - const bean = __.newBean('com.enonic.xp.lib.project.ModifyProjectReadAccessHandler'); + const bean: ModifyProjectReadAccessHandler = __.newBean('com.enonic.xp.lib.project.ModifyProjectReadAccessHandler'); bean.setId(params.id); bean.setReadAccess(__.toScriptValue(params.readAccess)); return __.toNativeObject(bean.execute()); diff --git a/modules/lib/lib-repo/src/main/resources/lib/xp/repo.ts b/modules/lib/lib-repo/src/main/resources/lib/xp/repo.ts index aaeb7e123b5..86539ec3106 100644 --- a/modules/lib/lib-repo/src/main/resources/lib/xp/repo.ts +++ b/modules/lib/lib-repo/src/main/resources/lib/xp/repo.ts @@ -86,7 +86,7 @@ export function refresh(params: RefreshParams): void { branch, } = params ?? {}; - const bean = __.newBean('com.enonic.xp.lib.repo.RefreshHandler'); + const bean: RefreshHandler = __.newBean('com.enonic.xp.lib.repo.RefreshHandler'); bean.setMode(__.nullOrValue(mode)); bean.setRepoId(__.nullOrValue(repo)); @@ -150,7 +150,7 @@ interface CreateRepositoryHandler { export function create(params: CreateRepositoryParams): Repository { checkRequired(params, 'id'); - const bean = __.newBean('com.enonic.xp.lib.repo.CreateRepositoryHandler'); + const bean: CreateRepositoryHandler = __.newBean('com.enonic.xp.lib.repo.CreateRepositoryHandler'); bean.setRepositoryId(params.id); bean.setRootChildOrder(__.nullOrValue(params.rootChildOrder)); @@ -181,7 +181,7 @@ interface DeleteRepositoryHandler { */ function _delete(id: string): boolean { checkRequiredValue(id, 'id'); - const bean = __.newBean('com.enonic.xp.lib.repo.DeleteRepositoryHandler'); + const bean: DeleteRepositoryHandler = __.newBean('com.enonic.xp.lib.repo.DeleteRepositoryHandler'); bean.setRepositoryId(id); return bean.execute(); } @@ -202,7 +202,7 @@ interface ListRepositoriesHandler { * */ export function list(): Repository[] { - const bean = __.newBean('com.enonic.xp.lib.repo.ListRepositoriesHandler'); + const bean: ListRepositoriesHandler = __.newBean('com.enonic.xp.lib.repo.ListRepositoriesHandler'); return __.toNativeObject(bean.execute()); } @@ -224,7 +224,7 @@ interface GetRepositoryHandler { export function get(id: string): Repository | null { checkRequiredValue(id, 'id'); - const bean = __.newBean('com.enonic.xp.lib.repo.GetRepositoryHandler'); + const bean: GetRepositoryHandler = __.newBean('com.enonic.xp.lib.repo.GetRepositoryHandler'); bean.setRepositoryId(id); return __.toNativeObject(bean.execute()); } @@ -261,7 +261,7 @@ export function createBranch(params: CreateBranchParams): BranchResult { checkRequired(params, 'repoId'); checkRequired(params, 'branchId'); - const bean = __.newBean('com.enonic.xp.lib.repo.CreateBranchHandler'); + const bean: CreateBranchHandler = __.newBean('com.enonic.xp.lib.repo.CreateBranchHandler'); bean.setBranchId(params.branchId); bean.setRepoId(params.repoId); @@ -297,7 +297,7 @@ export function deleteBranch(params: DeleteBranchParams): BranchResult { checkRequired(params, 'repoId'); checkRequired(params, 'branchId'); - const bean = __.newBean('com.enonic.xp.lib.repo.DeleteBranchHandler'); + const bean: DeleteBranchHandler = __.newBean('com.enonic.xp.lib.repo.DeleteBranchHandler'); bean.setBranchId(params.branchId); bean.setRepoId(params.repoId); return __.toNativeObject(bean.execute()); @@ -338,7 +338,7 @@ export function modify(params: ModifyRepositoryParams): Repository { checkRequired(params, 'id'); checkRequired(params, 'editor'); - const bean = __.newBean('com.enonic.xp.lib.repo.ModifyRepositoryHandler'); + const bean: ModifyRepositoryHandler = __.newBean('com.enonic.xp.lib.repo.ModifyRepositoryHandler'); bean.setId(params.id); bean.setEditor(__.toScriptValue(params.editor)); @@ -375,7 +375,7 @@ export function getBinary(params: GetRepositoryBinaryParams): object { checkRequired(params, 'repoId'); checkRequired(params, 'binaryReference'); - const bean = __.newBean('com.enonic.xp.lib.repo.GetRepositoryBinaryHandler'); + const bean: GetRepositoryBinaryHandler = __.newBean('com.enonic.xp.lib.repo.GetRepositoryBinaryHandler'); bean.setRepositoryId(params.repoId); bean.setBinaryReference(params.binaryReference); diff --git a/modules/lib/lib-scheduler/src/main/resources/lib/xp/scheduler.ts b/modules/lib/lib-scheduler/src/main/resources/lib/xp/scheduler.ts index 1120273e076..2bc41d6cb69 100644 --- a/modules/lib/lib-scheduler/src/main/resources/lib/xp/scheduler.ts +++ b/modules/lib/lib-scheduler/src/main/resources/lib/xp/scheduler.ts @@ -103,7 +103,7 @@ export function create = Record>('com.enonic.xp.lib.scheduler.CreateScheduledJobHandler'); + const bean: CreateScheduledJobHandler = __.newBean>('com.enonic.xp.lib.scheduler.CreateScheduledJobHandler'); bean.setName(params.name); bean.setSchedule(params.schedule); @@ -141,7 +141,7 @@ interface ModifyScheduledJobHandler> { export function modify = Record>(params: ModifyScheduledJobParams): ScheduledJob { checkRequired(params, 'name'); - const bean = __.newBean>('com.enonic.xp.lib.scheduler.ModifyScheduledJobHandler'); + const bean: ModifyScheduledJobHandler = __.newBean>('com.enonic.xp.lib.scheduler.ModifyScheduledJobHandler'); bean.setName(params.name); bean.setEditor(__.toScriptValue(params.editor)); @@ -170,7 +170,7 @@ interface DeleteScheduledJobHandler { function _delete(params: DeleteScheduledJobParams): boolean { checkRequired(params, 'name'); - const bean = __.newBean('com.enonic.xp.lib.scheduler.DeleteScheduledJobHandler'); + const bean: DeleteScheduledJobHandler = __.newBean('com.enonic.xp.lib.scheduler.DeleteScheduledJobHandler'); bean.setName(params.name); @@ -202,7 +202,7 @@ interface GetScheduledJobHandler> { export function get = Record>(params: GetScheduledJobParams): ScheduledJob | null { checkRequired(params, 'name'); - const bean = __.newBean>('com.enonic.xp.lib.scheduler.GetScheduledJobHandler'); + const bean: GetScheduledJobHandler = __.newBean>('com.enonic.xp.lib.scheduler.GetScheduledJobHandler'); bean.setName(params.name); @@ -220,7 +220,7 @@ interface ListScheduledJobsHandler> { * */ export function list = Record>(): ScheduledJob[] { - const bean = __.newBean>('com.enonic.xp.lib.scheduler.ListScheduledJobsHandler'); + const bean: ListScheduledJobsHandler = __.newBean>('com.enonic.xp.lib.scheduler.ListScheduledJobsHandler'); return __.toNativeObject(bean.execute()); } diff --git a/modules/lib/lib-schema/src/main/resources/lib/xp/schema.ts b/modules/lib/lib-schema/src/main/resources/lib/xp/schema.ts index 240a34bdc64..a06358826ce 100644 --- a/modules/lib/lib-schema/src/main/resources/lib/xp/schema.ts +++ b/modules/lib/lib-schema/src/main/resources/lib/xp/schema.ts @@ -113,7 +113,7 @@ export function createSchema(params: CreateDynamicContentSchemaParams): ContentT checkRequired(params, 'type'); checkRequired(params, 'resource'); - const bean = __.newBean('com.enonic.xp.lib.schema.CreateDynamicContentSchemaHandler'); + const bean: CreateDynamicContentSchemaHandler = __.newBean('com.enonic.xp.lib.schema.CreateDynamicContentSchemaHandler'); bean.setName(params.name); bean.setType(params.type); if (params.resource != null) { @@ -189,7 +189,7 @@ export function createComponent(params: CreateDynamicComponentParams): LayoutDes checkRequired(params, 'type'); checkRequired(params, 'resource'); - const bean = __.newBean('com.enonic.xp.lib.schema.CreateDynamicComponentHandler'); + const bean: CreateDynamicComponentHandler = __.newBean('com.enonic.xp.lib.schema.CreateDynamicComponentHandler'); bean.setKey(params.key); bean.setType(params.type); @@ -235,7 +235,7 @@ export function createStyles(params: CreateDynamicStylesParams): StyleDescriptor checkRequired(params, 'application'); checkRequired(params, 'resource'); - const bean = __.newBean('com.enonic.xp.lib.schema.CreateDynamicStylesHandler'); + const bean: CreateDynamicStylesHandler = __.newBean('com.enonic.xp.lib.schema.CreateDynamicStylesHandler'); bean.setApplication(params.application); bean.setResource(params.resource); return __.toNativeObject(bean.execute()); @@ -267,7 +267,7 @@ export function getSchema(params: GetDynamicContentSchemaParams): ContentTypeSch checkRequired(params, 'name'); checkRequired(params, 'type'); - const bean = __.newBean('com.enonic.xp.lib.schema.GetDynamicContentSchemaHandler'); + const bean: GetDynamicContentSchemaHandler = __.newBean('com.enonic.xp.lib.schema.GetDynamicContentSchemaHandler'); bean.setName(params.name); bean.setType(params.type); return __.toNativeObject(bean.execute()); @@ -299,7 +299,7 @@ export function getComponent(params: GetDynamicComponentParams): unknown { checkRequired(params, 'key'); checkRequired(params, 'type'); - const bean = __.newBean('com.enonic.xp.lib.schema.GetDynamicComponentHandler'); + const bean: GetDynamicComponentHandler = __.newBean('com.enonic.xp.lib.schema.GetDynamicComponentHandler'); bean.setKey(params.key); bean.setType(params.type); return __.toNativeObject(bean.execute()); @@ -338,7 +338,7 @@ interface GetDynamicSiteHandler { export function getSite(params: GetDynamicSiteParams): SiteDescriptor | null { checkRequired(params, 'application'); - const bean = __.newBean('com.enonic.xp.lib.schema.GetDynamicSiteHandler'); + const bean: GetDynamicSiteHandler = __.newBean('com.enonic.xp.lib.schema.GetDynamicSiteHandler'); bean.setApplication(params.application); return __.toNativeObject(bean.execute()); } @@ -364,7 +364,7 @@ interface GetDynamicStylesHandler { export function getStyles(params: GetDynamicStylesParams): StyleDescriptor | null { checkRequired(params, 'application'); - const bean = __.newBean('com.enonic.xp.lib.schema.GetDynamicStylesHandler'); + const bean: GetDynamicStylesHandler = __.newBean('com.enonic.xp.lib.schema.GetDynamicStylesHandler'); bean.setApplication(params.application); return __.toNativeObject(bean.execute()); } @@ -395,7 +395,7 @@ export function deleteSchema(params: DeleteDynamicContentSchemaParams): boolean checkRequired(params, 'name'); checkRequired(params, 'type'); - const bean = __.newBean('com.enonic.xp.lib.schema.DeleteDynamicContentSchemaHandler'); + const bean: DeleteDynamicContentSchemaHandler = __.newBean('com.enonic.xp.lib.schema.DeleteDynamicContentSchemaHandler'); bean.setName(params.name); bean.setType(params.type); return __.toNativeObject(bean.execute()); @@ -427,7 +427,7 @@ export function deleteComponent(params: DeleteDynamicComponentParams): boolean { checkRequired(params, 'key'); checkRequired(params, 'type'); - const bean = __.newBean('com.enonic.xp.lib.schema.DeleteDynamicComponentHandler'); + const bean: DeleteDynamicComponentHandler = __.newBean('com.enonic.xp.lib.schema.DeleteDynamicComponentHandler'); bean.setKey(params.key); bean.setType(params.type); return __.toNativeObject(bean.execute()); @@ -454,7 +454,7 @@ interface DeleteDynamicStylesHandler { export function deleteStyles(params: DeleteDynamicStylesParams): boolean { checkRequired(params, 'application'); - const bean = __.newBean('com.enonic.xp.lib.schema.DeleteDynamicStylesHandler'); + const bean: DeleteDynamicStylesHandler = __.newBean('com.enonic.xp.lib.schema.DeleteDynamicStylesHandler'); bean.setApplication(params.application); return __.toNativeObject(bean.execute()); } @@ -490,7 +490,7 @@ export function updateSchema(params: UpdateDynamicContentSchemaParams): ContentT checkRequired(params, 'type'); checkRequired(params, 'resource'); - const bean = __.newBean('com.enonic.xp.lib.schema.UpdateDynamicContentSchemaHandler'); + const bean: UpdateDynamicContentSchemaHandler = __.newBean('com.enonic.xp.lib.schema.UpdateDynamicContentSchemaHandler'); bean.setName(params.name); bean.setType(params.type); bean.setResource(params.resource); @@ -528,7 +528,7 @@ export function updateComponent(params: UpdateDynamicComponentParams): LayoutDes checkRequired(params, 'type'); checkRequired(params, 'resource'); - const bean = __.newBean('com.enonic.xp.lib.schema.UpdateDynamicComponentHandler'); + const bean: UpdateDynamicComponentHandler = __.newBean('com.enonic.xp.lib.schema.UpdateDynamicComponentHandler'); bean.setKey(params.key); bean.setType(params.type); bean.setResource(params.resource); @@ -562,7 +562,7 @@ export function updateSite(params: UpdateDynamicSiteParams): SiteDescriptor { checkRequired(params, 'application'); checkRequired(params, 'resource'); - const bean = __.newBean('com.enonic.xp.lib.schema.UpdateDynamicSiteHandler'); + const bean: UpdateDynamicSiteHandler = __.newBean('com.enonic.xp.lib.schema.UpdateDynamicSiteHandler'); bean.setApplication(params.application); bean.setResource(params.resource); return __.toNativeObject(bean.execute()); @@ -594,7 +594,7 @@ export function updateStyles(params: UpdateDynamicStylesParams): StyleDescriptor checkRequired(params, 'application'); checkRequired(params, 'resource'); - const bean = __.newBean('com.enonic.xp.lib.schema.UpdateDynamicStylesHandler'); + const bean: UpdateDynamicStylesHandler = __.newBean('com.enonic.xp.lib.schema.UpdateDynamicStylesHandler'); bean.setApplication(params.application); bean.setResource(params.resource); return __.toNativeObject(bean.execute()); @@ -626,7 +626,7 @@ export function listComponents(params: ListDynamicComponentsParams): PartDescrip checkRequired(params, 'application'); checkRequired(params, 'type'); - const bean = __.newBean('com.enonic.xp.lib.schema.ListDynamicComponentsHandler'); + const bean: ListDynamicComponentsHandler = __.newBean('com.enonic.xp.lib.schema.ListDynamicComponentsHandler'); bean.setApplication(params.application); bean.setType(params.type); return __.toNativeObject(bean.execute()); @@ -658,7 +658,7 @@ export function listSchemas(params: ListDynamicSchemasParams): ContentSchemaType checkRequired(params, 'application'); checkRequired(params, 'type'); - const bean = __.newBean('com.enonic.xp.lib.schema.ListDynamicSchemasHandler'); + const bean: ListDynamicSchemasHandler = __.newBean('com.enonic.xp.lib.schema.ListDynamicSchemasHandler'); bean.setApplication(params.application); bean.setType(params.type); return __.toNativeObject(bean.execute()); diff --git a/modules/lib/lib-task/src/main/resources/lib/xp/task.ts b/modules/lib/lib-task/src/main/resources/lib/xp/task.ts index 4f4e9508442..b60e1249a1b 100644 --- a/modules/lib/lib-task/src/main/resources/lib/xp/task.ts +++ b/modules/lib/lib-task/src/main/resources/lib/xp/task.ts @@ -75,7 +75,7 @@ interface ExecuteFunctionHandler { * @returns {string} Id of the task that will be executed. */ export function submit(params: SubmitParams): string { - const bean = __.newBean('com.enonic.xp.lib.task.ExecuteFunctionHandler'); + const bean: ExecuteFunctionHandler = __.newBean('com.enonic.xp.lib.task.ExecuteFunctionHandler'); checkRequired(params, 'description'); checkRequired(params, 'task'); @@ -100,7 +100,7 @@ export function submit(params: SubmitParams): string { * @returns {string} Id of the task that will be executed. */ export function executeFunction(params: ExecuteFunctionParams): string { - const bean = __.newBean('com.enonic.xp.lib.task.ExecuteFunctionHandler'); + const bean: ExecuteFunctionHandler = __.newBean('com.enonic.xp.lib.task.ExecuteFunctionHandler'); checkRequired(params, 'description'); checkRequired(params, 'func'); @@ -144,7 +144,7 @@ interface SubmitTaskHandler { export function submitNamed = Record>(params: SubmitNamedTaskParams): string { checkRequired(params, 'name'); - const bean = __.newBean('com.enonic.xp.lib.task.SubmitTaskHandler'); + const bean: SubmitTaskHandler = __.newBean('com.enonic.xp.lib.task.SubmitTaskHandler'); bean.setDescriptor(__.nullOrValue(params.name)); bean.setConfig(__.toScriptValue(params.config)); @@ -175,7 +175,7 @@ export interface SubmitTaskParams> { export function submitTask = Record>(params: SubmitTaskParams): string { checkRequired(params, 'descriptor'); - const bean = __.newBean('com.enonic.xp.lib.task.SubmitTaskHandler'); + const bean: SubmitTaskHandler = __.newBean('com.enonic.xp.lib.task.SubmitTaskHandler'); bean.setDescriptor(__.nullOrValue(params.descriptor)); bean.setName(__.nullOrValue(params.name)); @@ -230,7 +230,7 @@ export interface TaskInfo { export function list(params?: ListTasksParams): TaskInfo[] { const {name, state} = params ?? {}; - const bean = __.newBean('com.enonic.xp.lib.task.ListTasksHandler'); + const bean: ListTasksHandler = __.newBean('com.enonic.xp.lib.task.ListTasksHandler'); bean.setName(__.nullOrValue(name)); bean.setState(__.nullOrValue(state)); @@ -259,7 +259,7 @@ export function get(taskId: string): TaskInfo | null { throw 'Parameter taskId is required'; } - const bean = __.newBean('com.enonic.xp.lib.task.GetTaskHandler'); + const bean: GetTaskHandler = __.newBean('com.enonic.xp.lib.task.GetTaskHandler'); bean.setTaskId(__.nullOrValue(taskId)); return __.toNativeObject(bean.getTask()); } @@ -278,7 +278,7 @@ interface SleepHandler { * @param {number} timeMillis The length of time to sleep in milliseconds. */ export function sleep(timeMillis: number): void { - const bean = __.newBean('com.enonic.xp.lib.task.SleepHandler'); + const bean: SleepHandler = __.newBean('com.enonic.xp.lib.task.SleepHandler'); bean.setTimeMillis(__.nullOrValue(timeMillis) ?? 0); @@ -313,7 +313,7 @@ interface TaskProgressHandler { * @param {string} [params.info] Text describing the current progress for the task. */ export function progress(params: TaskProgressParams): void { - const bean = __.newBean('com.enonic.xp.lib.task.TaskProgressHandler'); + const bean: TaskProgressHandler = __.newBean('com.enonic.xp.lib.task.TaskProgressHandler'); bean.setCurrent(__.nullOrValue(params.current)); bean.setTotal(__.nullOrValue(params.total)); @@ -336,7 +336,7 @@ interface IsRunningHandler { * @returns {boolean} True if there is a task with the specified name or id, and state 'RUNNING'; False otherwise. */ export function isRunning(task: string): boolean { - const bean = __.newBean('com.enonic.xp.lib.task.IsRunningHandler'); + const bean: IsRunningHandler = __.newBean('com.enonic.xp.lib.task.IsRunningHandler'); if (task === undefined) { throw 'Parameter task is required'; diff --git a/modules/lib/lib-value/src/main/resources/lib/xp/value.ts b/modules/lib/lib-value/src/main/resources/lib/xp/value.ts index cbc96b681ef..af98321be98 100644 --- a/modules/lib/lib-value/src/main/resources/lib/xp/value.ts +++ b/modules/lib/lib-value/src/main/resources/lib/xp/value.ts @@ -58,7 +58,7 @@ interface GeoPointHandler { * @returns {*} GeoPoint java-type */ export function geoPoint(lat: number, lon: number): GeoPoint { - const bean = __.newBean('com.enonic.xp.lib.value.GeoPointHandler'); + const bean: GeoPointHandler = __.newBean('com.enonic.xp.lib.value.GeoPointHandler'); return bean.newInstance(lat, lon); } @@ -69,7 +69,7 @@ export function geoPoint(lat: number, lon: number): GeoPoint { * @returns {*} GeoPoint java-type */ export function geoPointString(value: string): GeoPoint { - const bean = __.newBean('com.enonic.xp.lib.value.GeoPointHandler'); + const bean: GeoPointHandler = __.newBean('com.enonic.xp.lib.value.GeoPointHandler'); return bean.from(value); } @@ -93,7 +93,7 @@ interface InstantHandler { * @returns {*} Instant java-type */ export function instant(value: string | Date): Instant { - const bean = __.newBean('com.enonic.xp.lib.value.InstantHandler'); + const bean: InstantHandler = __.newBean('com.enonic.xp.lib.value.InstantHandler'); if (typeof value === 'string') { return bean.parse(value); @@ -119,7 +119,7 @@ interface ReferenceHandler { * @returns {*} Reference java-type */ export function reference(value: string): Reference { - const refBean = __.newBean('com.enonic.xp.lib.value.ReferenceHandler'); + const refBean: ReferenceHandler = __.newBean('com.enonic.xp.lib.value.ReferenceHandler'); return refBean.from(value); } @@ -170,7 +170,7 @@ interface LocalDateTimeHandler { * @returns {*} LocalDateTime java-type */ export function localDateTime(value: string | Date): LocalDateTime { - const bean = __.newBean('com.enonic.xp.lib.value.LocalDateTimeHandler'); + const bean: LocalDateTimeHandler = __.newBean('com.enonic.xp.lib.value.LocalDateTimeHandler'); if (typeof value === 'string') { return bean.parse(value); } else { @@ -205,7 +205,7 @@ interface LocalDateHandler { * @returns {*} LocalDate java-type */ export function localDate(value: string | Date): LocalDate { - const bean = __.newBean('com.enonic.xp.lib.value.LocalDateHandler'); + const bean: LocalDateHandler = __.newBean('com.enonic.xp.lib.value.LocalDateHandler'); if (typeof value === 'string') { return bean.parse(value); @@ -235,7 +235,7 @@ interface LocalTimeHandler { * @returns {*} LocalTime java-type */ export function localTime(value: string | Date): LocalTime { - const bean = __.newBean('com.enonic.xp.lib.value.LocalTimeHandler'); + const bean: LocalTimeHandler = __.newBean('com.enonic.xp.lib.value.LocalTimeHandler'); if (typeof value === 'string') { return bean.parse(value); } else { @@ -269,8 +269,8 @@ interface BinaryAttachmentHandler { * @returns {*} BinaryAttachment java-type */ export function binary(name: string, stream: ByteSource): BinaryAttachment { - const binaryReferenceBean = __.newBean('com.enonic.xp.lib.value.BinaryReferenceHandler'); - const binaryAttachmentBean = __.newBean('com.enonic.xp.lib.value.BinaryAttachmentHandler'); + const binaryReferenceBean: BinaryReferenceHandler = __.newBean('com.enonic.xp.lib.value.BinaryReferenceHandler'); + const binaryAttachmentBean: BinaryAttachmentHandler = __.newBean('com.enonic.xp.lib.value.BinaryAttachmentHandler'); return binaryAttachmentBean.newInstance(binaryReferenceBean.from(name), stream); } diff --git a/modules/lib/lib-vhost/src/main/resources/lib/xp/vhost.ts b/modules/lib/lib-vhost/src/main/resources/lib/xp/vhost.ts index 467af4eb718..244ec59d244 100644 --- a/modules/lib/lib-vhost/src/main/resources/lib/xp/vhost.ts +++ b/modules/lib/lib-vhost/src/main/resources/lib/xp/vhost.ts @@ -48,7 +48,7 @@ export interface VirtualHost { * @returns {boolean} `true` if vhost mapping is enabled, otherwise `false`. */ export function isEnabled(): boolean { - const bean = __.newBean('com.enonic.xp.lib.vhost.VirtualHostHandler'); + const bean: VirtualHostHandler = __.newBean('com.enonic.xp.lib.vhost.VirtualHostHandler'); return __.toNativeObject(bean.isEnabled()); } @@ -58,6 +58,6 @@ export function isEnabled(): boolean { * @returns {VirtualHosts} An object with all the virtual hosts. */ export function list(): VirtualHosts { - const bean = __.newBean('com.enonic.xp.lib.vhost.VirtualHostHandler'); + const bean: VirtualHostHandler = __.newBean('com.enonic.xp.lib.vhost.VirtualHostHandler'); return __.toNativeObject(bean.getVirtualHosts()); } diff --git a/modules/lib/lib-websocket/src/main/resources/lib/xp/websocket.ts b/modules/lib/lib-websocket/src/main/resources/lib/xp/websocket.ts index 6724fde67d9..b0270164426 100644 --- a/modules/lib/lib-websocket/src/main/resources/lib/xp/websocket.ts +++ b/modules/lib/lib-websocket/src/main/resources/lib/xp/websocket.ts @@ -34,7 +34,7 @@ interface WebSocketManagerBean { * @param {string} id Socket id. */ export function addToGroup(group: string, id: string): void { - const bean = __.newBean('com.enonic.xp.lib.websocket.WebSocketManagerBean'); + const bean: WebSocketManagerBean = __.newBean('com.enonic.xp.lib.websocket.WebSocketManagerBean'); bean.addToGroup(group, id); } @@ -47,7 +47,7 @@ export function addToGroup(group: string, id: string): void { * @param {string} id Socket id. */ export function removeFromGroup(group: string, id: string): void { - const bean = __.newBean('com.enonic.xp.lib.websocket.WebSocketManagerBean'); + const bean: WebSocketManagerBean = __.newBean('com.enonic.xp.lib.websocket.WebSocketManagerBean'); bean.removeFromGroup(group, id); } @@ -60,7 +60,7 @@ export function removeFromGroup(group: string, id: string): void { * @param {string} message Message as text. */ export function send(id: string, message: string): void { - const bean = __.newBean('com.enonic.xp.lib.websocket.WebSocketManagerBean'); + const bean: WebSocketManagerBean = __.newBean('com.enonic.xp.lib.websocket.WebSocketManagerBean'); bean.send(id, message); } @@ -73,7 +73,7 @@ export function send(id: string, message: string): void { * @param {string} message Message as text. */ export function sendToGroup(group: string, message: string): void { - const bean = __.newBean('com.enonic.xp.lib.websocket.WebSocketManagerBean'); + const bean: WebSocketManagerBean = __.newBean('com.enonic.xp.lib.websocket.WebSocketManagerBean'); bean.sendToGroup(group, message); } @@ -85,6 +85,6 @@ export function sendToGroup(group: string, message: string): void { * @param {string} group Group name. */ export function getGroupSize(group: string): number { - const bean = __.newBean('com.enonic.xp.lib.websocket.WebSocketManagerBean'); + const bean: WebSocketManagerBean = __.newBean('com.enonic.xp.lib.websocket.WebSocketManagerBean'); return bean.getGroupSize(group); }