Skip to content

Commit

Permalink
update types
Browse files Browse the repository at this point in the history
  • Loading branch information
udamir committed Sep 29, 2024
1 parent c7f4425 commit dab4635
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 39 deletions.
Binary file modified bun.lockb
Binary file not shown.
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "youtrack-client",
"description": "Client library for accessing the YouTrack REST and Widget API",
"version": "0.3.4",
"version": "0.3.5",
"type": "module",
"keywords": [
"youtrack",
Expand All @@ -19,7 +19,8 @@
"browser": "dist/youtrack-client.min.js",
"types": "dist/index.d.ts",
"files": [
"dist"
"dist",
"types"
],
"exports": {
".": {
Expand Down Expand Up @@ -48,6 +49,7 @@
"@rollup/plugin-typescript": "^12.1.0",
"@types/jest": "^29.5.13",
"axios": "^1.7.7",
"hub-dashboard-addons": "^1.0.2",
"rimraf": "^6.0.1",
"rollup": "^4.21.3",
"rollup-plugin-filesize": "^10.0.0",
Expand Down
1 change: 0 additions & 1 deletion src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ export * from "./fetch"
export * from "./api"
export * from "./entities"
export * from "./utils"
export * from "./widget"
export * from "./fields"
34 changes: 0 additions & 34 deletions src/types/widget.ts

This file was deleted.

5 changes: 3 additions & 2 deletions src/youtrack.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { DashboardApi, HubService } from "hub-dashboard-addons"
import type { Axios } from "axios"

import type { DashboardApi, FetchConfig, FetchFunc, Service } from "./types"
import type { FetchConfig, FetchFunc } from "./types"
import { encodeBody, joinUrl } from "./utils"
import * as ResourceApi from "./resources"

Expand Down Expand Up @@ -78,7 +79,7 @@ export class YouTrack {
}

static async widget(api: DashboardApi) {
const { services } = await api.fetchHub<{ services: Service[] }>(
const { services } = await api.fetchHub<{ services: HubService[] }>(
`api/rest/services?query=applicationName:${"YouTrack"}`,
)

Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"module": "ESNext",
"allowJs": false,
"skipLibCheck": true,
"typeRoots": ["types"],

/* Bundler mode */
"moduleResolution": "bundler",
Expand Down
85 changes: 85 additions & 0 deletions types/hub-dashboard-addons/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
declare module "hub-dashboard-addons" {
export type WidgetApi = (props: WidgetApiProps) => void

export type WidgetApiProps = {
onRefresh?(): Promise<void>
onConfigure?(): Promise<void>
}

export interface HubService {
id: string
applicationName: string
homeUrl: string
key: string
name: string
trusted: boolean
type: string
vendor: string
version: string
}

type AlertType = "error" | "message" | "success" | "warning" | "loading"

export type DashboardApi = {
setTitle(label: string, labelUri?: string): Promise<void>
setLoadingAnimationEnabled(enabled: boolean): Promise<void>

alert(message: string, type?: AlertType, timeout?: number, options?: object): string | number
setError(e: Error): Promise<void>
clearError(): Promise<void>

enterConfigMode(): Promise<void>
exitConfigMode(): Promise<void>

readCache<T extends object>(): Promise<T | null>
storeCache(cache: object): Promise<void>

readConfig<T extends object>(): Promise<T | null>
storeConfig(config: object): Promise<void>

fetch<T>(serviceID: string, url: string, fetchConfig?: object): Promise<T>
fetchHub<T>(url: string, fetchConfig?: object): Promise<T>
downloadFile(serviceID: string, relativeURL: string, requestParams: unknown, fileName?: string): Promise<void>

loadServices(applicationName: string): Promise<HubService[]>
removeWidget(): void
}

const addon: {
locale: string
editable: boolean
registerWidget: (widget: (dashboardApi: DashboardApi, widgetApi: WidgetApi) => Promise<void>) => void
}

export default addon
}

declare module "hub-dashboard-addons/dist/localization" {
interface Dictionary {
[key: string]: string | Record<string, string>
}

interface Translations {
[lang: string]: Dictionary
}

export const i18n: {
(
text: string,
interpolationObject?: Record<string, string | number>,
numberForPlurals?: number,
context?: string,
): string
plural(
count: number,
textForUnique: string,
textForPlural: string,
interpolationObject?: Record<string, string | number>,
context?: string,
): string
}

export const i18nTimeIdentifiers: Record<string, unknown>

export function setLocale(lang: string, translations: Translations): void
}

0 comments on commit dab4635

Please sign in to comment.