export type JsonNode = unknown; export type ResourceExportData = {link?: string | undefined, title?: string | undefined, type?: ('LWM2M_MODEL' | 'JKS' | 'PKCS_12' | 'JS_MODULE' | 'IMAGE' | 'DASHBOARD' | 'GENERAL') | undefined, subType?: ('IMAGE' | 'SCADA_SYMBOL' | 'EXTENSION' | 'MODULE') | undefined, resourceKey?: string | undefined, fileName?: string | undefined, publicResourceKey?: string | undefined, isPublic?: boolean | undefined, mediaType?: string | undefined, data?: string | undefined, public?: boolean | undefined}; export type DashboardId = {id: string, entityType: 'DASHBOARD'}; export type TenantId = {id: string, entityType: 'TENANT'}; export type CustomerId = {id: string, entityType: 'CUSTOMER'}; export type ShortCustomerInfo = {customerId?: CustomerId | undefined, title?: string | undefined, isPublic?: boolean | undefined, public?: boolean | undefined}; export type Dashboard = {title: string, image?: string | undefined, mobileHide?: boolean | undefined, mobileOrder?: number | undefined, configuration?: JsonNode | undefined, name?: string | undefined, resources?: Array | undefined, id?: DashboardId | undefined, createdTime?: number | undefined, tenantId?: TenantId | undefined, assignedCustomers?: Array | undefined, version?: number | undefined}; export type CreateApiApiDashboardArgs = {'Accept-Encoding'?: string | undefined, body: Dashboard}; export type CreateApiApiDashboardOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create Or Update Dashboard (saveDashboard) * * POST /api/dashboard */ export const createApiApiDashboard = async (args: CreateApiApiDashboardArgs, options?: CreateApiApiDashboardOptions) => { const {baseUrl = "https://demo.thingsboard.io", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['Accept-Encoding'] != null) headers.set("Accept-Encoding", String(args['Accept-Encoding'])) const url = `${baseUrl.replace(/\/+$/, '')}/api/dashboard${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };