temporeest
Version:
72 lines (62 loc) • 1.98 kB
text/typescript
// SIGNED-SOURCE: <9fd6fc8c39a92c918c77453c2ee170a2>
/**
* AUTO-GENERATED FILE
* Do not modify. Update your schema and re-generate for changes.
*/
import AppState from "../AppState.js";
import { default as s } from "./AppStateSpec.js";
import { P } from "@aphro/runtime-ts";
import { UpdateMutationBuilder } from "@aphro/runtime-ts";
import { CreateMutationBuilder } from "@aphro/runtime-ts";
import { DeleteMutationBuilder } from "@aphro/runtime-ts";
import { makeSavable } from "@aphro/runtime-ts";
import { modelGenMemo } from "@aphro/runtime-ts";
import { Node } from "@aphro/runtime-ts";
import { NodeSpecWithCreate } from "@aphro/runtime-ts";
import { SID_of } from "@aphro/runtime-ts";
import { Context } from "@aphro/runtime-ts";
import Identity from "../Identity.js";
import Deck from "../Deck.js";
import Component from "../Component.js";
export type Data = {
id: SID_of<AppState>;
identity: Identity;
openDeckId: SID_of<Deck> | null;
copiedComponents: readonly Component[];
};
// @Sealed(AppState)
export default abstract class AppStateBase extends Node<Data> {
readonly spec = s as unknown as NodeSpecWithCreate<this, Data>;
get id(): SID_of<this> {
return this.data.id as unknown as SID_of<this>;
}
get identity(): Identity {
return this.data.identity;
}
get openDeckId(): SID_of<Deck> | null {
return this.data.openDeckId;
}
get copiedComponents(): readonly Component[] {
return this.data.copiedComponents;
}
update(data: Partial<Data>) {
return makeSavable(
this.ctx,
new UpdateMutationBuilder(this.ctx, this.spec, this)
.set(data)
.toChangesets()[0]
);
}
static create(ctx: Context, data: Partial<Data>) {
return makeSavable(
ctx,
new CreateMutationBuilder(ctx, s).set(data).toChangesets()[0]
);
}
delete() {
return makeSavable(
this.ctx,
new DeleteMutationBuilder(this.ctx, this.spec, this).toChangesets()[0]
);
}
}