2023-11-27 18:48:37 +03:00
|
|
|
import { Server } from '@open-rpc/server-js'
|
2024-04-09 15:02:11 +03:00
|
|
|
import * as random from 'lib0/random'
|
2023-11-27 18:48:37 +03:00
|
|
|
import {
|
|
|
|
methods as pmMethods,
|
|
|
|
projects,
|
|
|
|
type ProjectId,
|
|
|
|
type ProjectName,
|
|
|
|
type UTCDateTime,
|
2023-12-15 13:29:15 +03:00
|
|
|
} from '../mock/projectManager'
|
2023-11-27 18:48:37 +03:00
|
|
|
import pmSpec from './pm-openrpc.json' assert { type: 'json' }
|
|
|
|
|
|
|
|
export default function setup() {
|
|
|
|
const pm = new Server({
|
|
|
|
transportConfigs: [
|
|
|
|
{
|
|
|
|
type: 'WebSocketTransport',
|
|
|
|
options: {
|
|
|
|
id: 'websocket',
|
|
|
|
udp: true,
|
|
|
|
ipv6: true,
|
|
|
|
port: 30535,
|
|
|
|
middleware: [],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
openrpcDocument: pmSpec as typeof pmSpec & { openrpc: never },
|
|
|
|
methodMapping: pmMethods,
|
|
|
|
})
|
|
|
|
pm.start()
|
|
|
|
projects.set('mock project id 0001', {
|
|
|
|
id: random.uuidv4() as ProjectId,
|
|
|
|
created: new Date().toISOString() as UTCDateTime,
|
|
|
|
lastOpened: new Date().toISOString() as UTCDateTime,
|
|
|
|
engineVersion: '',
|
|
|
|
name: 'Mock Project Name' as ProjectName,
|
|
|
|
namespace: 'local',
|
|
|
|
})
|
|
|
|
}
|