Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP dont merge; osprey ui: WIP boot/doom 'trial' concept #16

Open
wants to merge 2 commits into
base: add-osprey-ui
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions front/src/api/ospreyAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const Scries = {
Heaps() { return scryHeaps() },
Groups() { return scryGroups() },
Diaries() { return scryDiaries() },
Trial() { return scryTrial() },
}

export const Pokes = {
Expand All @@ -27,6 +28,8 @@ export const Pokes = {
RepeatArchive(flag, typeString, schedule) { return pokeRepeatArchive(flag, typeString, schedule) },
Doom(args) { return pokeDoom(args) },
Boot(args) { return pokeBoot(args) },
Execute(args) { return pokeExec(args) },
Pardon(args) { return pokePardon(args) },

MailOpen(args) { return pokeMailOpen(args) },
MailSend(args) { return pokeMailSend(args) },
Expand All @@ -36,6 +39,11 @@ export const Pokes = {

////

export function scryTrial(): Promise<OR.OspreyStateOnTrialResponse> {
const scrier = new OS.ScryTrial()
return scrier.scry()
}

export function scrySchedule(): Promise<OR.OspreyResponseSchedule> {
const scrier = new OS.ScrySchedule()
return scrier.scry()
Expand Down Expand Up @@ -78,6 +86,18 @@ export function scryDiaries(): Promise<OR.OspreyResponseHostedDiaries> {

////

export function pokeExec(hash: string): Promise<any>
{
const poker = new OA.Execute(hash)
return poker.poke()
}

export function pokePardon(hash: string): Promise<any>
{
const poker = new OA.Pardon(hash)
return poker.poke()
}

export function pokeArchiveMine(): Promise<any>
{
const poker = new OA.ArchiveMine()
Expand Down
26 changes: 26 additions & 0 deletions front/src/api/ospreyActionPoker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,29 @@ export class Boot extends OspreyAction {
super(json)
}
}

export class Execute extends OspreyAction {
declare payload: OP.ExecutePayload['exec']['id']

constructor(args: OP.ExecutePayload['exec']['id']) {
const json: OP.ExecutePayload = {
exec: {
id: args
}
}
super(json)
}
}

export class Pardon extends OspreyAction {
declare payload: OP.PardonPayload['stop']['id']

constructor(args: OP.PardonPayload['stop']['id']) {
const json: OP.PardonPayload = {
stop: {
id: args
}
}
super(json)
}
}
10 changes: 10 additions & 0 deletions front/src/api/ospreyScrier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ class OspreyScry {
}
}

export class ScryTrial extends OspreyScry {
constructor() {
super('/on-trial')
}

scry(): Promise<OR.OspreyStateOnTrialResponse> {
return super.scry()
}
}

export class ScrySchedule extends OspreyScry {
constructor() {
super('/schedule')
Expand Down
20 changes: 18 additions & 2 deletions front/src/api/types/osprey-poke.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export interface RepeatArchivePayload {
export interface DoomPayload {
doom: {
limit: number;
age: number;
age: number; // as "~h1", "~d30", etc
group: T.Flag;
}
}
Expand All @@ -88,6 +88,19 @@ export interface BootPayload {
}
}

export interface ExecutePayload {
exec: {
id: string;
}
}

export interface PardonPayload {
stop: {
id: string;
}
}


// TODO: don't use
export interface ArchiveDmPayload {
chat: {
Expand Down Expand Up @@ -118,4 +131,7 @@ export type OspreyPoke =
MailOpenPayload |
MailSendPayload |
MailReadPayload |
MailKillPayload
MailKillPayload |
ExecutePayload |
PardonPayload

140 changes: 107 additions & 33 deletions front/src/api/types/osprey-response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,63 @@ export enum OspreyResponseFaces {
OspreyScheduleCancel = "ARCHIVE-SCHEDULE-CANCEL",
ArchiveStart = "ARCHIVE-START",
ArchiveStatusUpdate = "ARCHIVE-STATUS-UPDATE",
Dooming = "DOOMING",
DoomDone = "DOOMBOT-RESULTS",
Booting = "BOOTING",
BootDone = "BOOTBOT-RESULTS",

OspreyKickDooming = "KICK-DOOMING",
OspreyKickBooting = "KICK-BOOTING",

Dooming = "DOOMING", // TODO: remove?
DoomDone = "DOOMBOT-RESULTS", // TODO: remove?

OspreyKickExecuting = "KICK-EXECUTING",
OspreyKickPardoning = "KICK-PARDONING",

RestoreStatusUpdate = "RESTORE-STATUS-UPDATE",

OspreyStateOnTrial = "OSPREY-STATE-ON-TRIAL",
}

export interface OspreyStateOnTrialResponse {
type: Api.ResponseTypes.Scry;
face: OspreyResponseFaces.OspreyStateOnTrial
fact: {
[key: string]: O.Defendants // keys will be a hashes. can have many groups on trial
}
}

// On initial
export interface OspreyResponseKickDooming {
type: Api.ResponseTypes.Fact;
face: OspreyResponseFaces.OspreyKickDooming;
fact: {
seconds: number;
group: T.Flag;
}
}

// On initial
export interface OspreyResponseKickBooting {
type: Api.ResponseTypes.Fact;
face: OspreyResponseFaces.OspreyKickBooting;
fact: {
rank: string;
group: T.Flag;
}
}

export interface OspreyKickExecutingResponse {
type: Api.ResponseTypes.Fact;
face: OspreyResponseFaces.OspreyKickExecuting;
fact: {
id: string; // hash of defendants
}
}

export interface OspreyKickPardoningResponse {
type: Api.ResponseTypes.Fact;
face: OspreyResponseFaces.OspreyKickPardoning;
fact: {
id: string; // hash of defendants
}
}

export interface RestoredNewGroup {
Expand Down Expand Up @@ -210,7 +261,7 @@ export interface OspreyResponseArchiveStatusUpdate {

export interface OspreyResponseDoomStart {
type: Api.ResponseTypes.Fact;
face: OspreyResponseFaces.Dooming;
face: OspreyResponseFaces.OspreyKickDooming;
fact: {
seconds: number;
group: T.Flag;
Expand All @@ -228,7 +279,7 @@ export interface OspreyResponseDoomDone {

export interface OspreyResponseBootStart {
type: Api.ResponseTypes.Fact;
face: OspreyResponseFaces.Booting;
face: OspreyResponseFaces.OspreyKickBooting;
fact: {
rank: string;
group: T.Flag;
Expand All @@ -255,10 +306,12 @@ export type OspreyResponse =
| OspreyResponseHostedDiaries
| OspreyResponseArchiveStart
| OspreyResponseArchiveStatusUpdate
| OspreyResponseDoomStart
| OspreyResponseKickDooming // start
| OspreyResponseDoomDone
| OspreyResponseBootStart
| OspreyResponseBootDone
| OspreyResponseKickBooting // start
| OspreyResponseBootDone // done
| OspreyKickExecutingResponse
| OspreyKickPardoningResponse
| OspreyResponseMailslot
| OspreyResponseMailOpen
| OspreyResponseMailSending
Expand All @@ -267,6 +320,51 @@ export type OspreyResponse =
| OspreyResponseMailReading
| OspreyResponseMailReadDone
| OspreyResponseMailKilled
| OspreyStateOnTrialResponse

export const IsOspreyOnTrialResponse = (
r: OspreyResponse
): r is OspreyStateOnTrialResponse => {
return r.face === OspreyResponseFaces.OspreyStateOnTrial;
};

export const IsOspreyResponseDoomStart = (
r: OspreyResponse
): r is OspreyResponseKickDooming => {
return r.face === OspreyResponseFaces.OspreyKickDooming;
};

export const IsOspreyResponseDoomDone = (
r: OspreyResponse
): r is OspreyResponseDoomDone => {
return r.face === OspreyResponseFaces.DoomDone;
};

export const IsOspreyResponseBootStart = (
r: OspreyResponse
): r is OspreyResponseKickBooting => {
return r.face === OspreyResponseFaces.OspreyKickBooting;
};

// TODO: wut this?
export const IsOspreyResponseBootDone = (
r: OspreyResponse
): r is OspreyResponseBootDone => {
return r.face === OspreyResponseFaces.BootDone;
};

export const IsOspreyKickExecutingResponse = (
r: OspreyResponse
): r is OspreyKickExecutingResponse => {
return r.face === OspreyResponseFaces.OspreyKickExecuting;
};

export const IsOspreyKickPardoningResponse = (
r: OspreyResponse
): r is OspreyKickPardoningResponse => {
return r.face === OspreyResponseFaces.OspreyKickPardoning;
};
///

export const IsOspreyHostedEvery = (
r: OspreyResponse
Expand Down Expand Up @@ -320,30 +418,6 @@ export const IsOspreyResponseArchiveStatusUpdate = (
return r.face === OspreyResponseFaces.ArchiveStatusUpdate;
};

export const IsOspreyResponseDoomStart = (
r: OspreyResponse
): r is OspreyResponseDoomStart => {
return r.face === OspreyResponseFaces.Dooming;
};

export const IsOspreyResponseDoomDone = (
r: OspreyResponse
): r is OspreyResponseDoomDone => {
return r.face === OspreyResponseFaces.DoomDone;
};

export const IsOspreyResponseBootStart = (
r: OspreyResponse
): r is OspreyResponseBootStart => {
return r.face === OspreyResponseFaces.Booting;
};

export const IsOspreyResponseBootDone = (
r: OspreyResponse
): r is OspreyResponseBootDone => {
return r.face === OspreyResponseFaces.BootDone;
};

export const IsOspreyResponseMailslot = (
r: OspreyResponse
): r is OspreyResponseMailslot => {
Expand Down
1 change: 1 addition & 0 deletions front/src/store/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ export const actions: ActionTree<State, State> & Actions = {
if (PR.IsBirdLeftFact(data)) {
console.log('BirdLeftFact ', data)
dispatch(ActionTypes.SCRY_FLOKS)
dispatch(ActionTypes.SCRY_AVAIL_CHATS)
}
},

Expand Down
1 change: 1 addition & 0 deletions front/src/store/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { MutationTypes } from "./mutation-types";
import { State } from "./state";
import * as T from "@/types";
import * as P from "@/types/parrot-types";
import * as P from "@/types/parrot-types";

import { sigShip } from "@/helpers"

Expand Down
1 change: 1 addition & 0 deletions front/src/store/osprey-action-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ export enum OspreyActionTypes {
ScryChats = 'SCRY_CHATS',
ScryHeaps = 'SCRY_HEAPS',
ScryDiaries = 'SCRY_DIARIES',
ScryTrial = 'SCRY_TRIAL',
}
Loading