83d8035dc2
* root + server * frontend * frontend-2 * dui3 * dui3 * tailwind theme * ui-components * preview service * viewer * viewer-sandbox * fileimport-service * webhook service * objectloader * shared * ui-components-nuxt * WIP full config * WIP full linter * eslint projectwide util * minor fix * removing redundant ci * clean up test errors * fixed prettier formatting * CI improvements * TSC lint fix * 'buildBatch' needs to be async since some batch types (like Text) require it. Removed a disabled liniting rule from ObjLoader * removed unnecessary void --------- Co-authored-by: AlexandruPopovici <alexandrupopoviciioan@gmail.com>
79 lines
1.7 KiB
TypeScript
79 lines
1.7 KiB
TypeScript
/* eslint-disable @typescript-eslint/require-await */
|
|
|
|
import { BaseBridge } from '~~/lib/bridge/base'
|
|
import type { IBinding } from '~~/lib/bindings/definitions/IBinding'
|
|
|
|
export const IBasicConnectorBindingKey = 'baseBinding'
|
|
|
|
// Needs to be agreed between Frontend and Core
|
|
export interface IBasicConnectorBinding
|
|
extends IBinding<IBasicConnectorBindingHostEvents> {
|
|
getAccounts: () => Promise<Account[]>
|
|
getSourceApplicationName: () => Promise<string>
|
|
getSourceApplicationVersion: () => Promise<string>
|
|
getDocumentInfo: () => Promise<DocumentInfo>
|
|
}
|
|
|
|
export interface IBasicConnectorBindingHostEvents {
|
|
displayToastNotification: (args: ToastInfo) => void
|
|
documentChanged: () => void
|
|
}
|
|
|
|
// An almost 1-1 mapping of what we need from the Core accounts class.
|
|
export type Account = {
|
|
id: string
|
|
isDefault: boolean
|
|
token: string
|
|
serverInfo: {
|
|
name: string
|
|
url: string
|
|
}
|
|
userInfo: {
|
|
id: string
|
|
avatar: string
|
|
email: string
|
|
name: string
|
|
commits: { totalCount: number }
|
|
streams: { totalCount: number }
|
|
}
|
|
}
|
|
|
|
export type DocumentInfo = {
|
|
location: string
|
|
name: string
|
|
id: string
|
|
}
|
|
|
|
// NOTE: just a reminder for now
|
|
export type ToastInfo = {
|
|
text: string
|
|
details?: string
|
|
type: 'info' | 'error' | 'warning'
|
|
}
|
|
|
|
export class MockedBaseBinding extends BaseBridge {
|
|
public async getAccounts() {
|
|
return []
|
|
}
|
|
|
|
public async getSourceApplicationName() {
|
|
return 'Mocks'
|
|
}
|
|
|
|
public async getSourceApplicationVersion() {
|
|
return Math.random().toString()
|
|
}
|
|
|
|
public async getDocumentInfo() {
|
|
return {
|
|
name: 'Mocked File',
|
|
location: 'www',
|
|
id: Math.random().toString()
|
|
}
|
|
}
|
|
|
|
public async showDevTools() {
|
|
console.log('Mocked bindings cannot do this')
|
|
}
|
|
}
|